Skip to content

2026-87: feat(spawn): block opencode dispatch on unhealthy free-model entry - #87

Merged
Ivory2024 merged 4 commits into
mainfrom
fm/opencode-model-health-gate-20261004
Oct 4, 2026
Merged

Ivory2024 merged 4 commits into
mainfrom
fm/opencode-model-health-gate-20261004

Conversation

@Ivory2024

Copy link
Copy Markdown
Owner

Intent

디스패치 전 opencode-free-models.json에서 모델 살아있는지(만료/조기종료 아닌지) 확인 필요.
이거 놓치지 않게 지침이나 강제 훅 등 수정해.

What Changed

  • bin/fm-spawn.sh adds a mechanical health check before dispatching an opencode free-model candidate: it looks up the model in opencode-free-models.json (checking the same two candidate paths, in the same order, that opencode_model_router.py's load_catalog() uses), refuses dispatch (exit 1) when the entry's status isn't active or early_termination_detected is true, warns on is_expiring_soon, and warns (without blocking) when the catalog file is missing or the model isn't found.
  • docs/model-dispatch-rigor.md documents the new mechanical gate, clarifies that is_expiring_soon narrowing and scanned_at staleness remain manual judgment calls out of the gate's scope, and updates the harness-adapters opencode reference accordingly.
  • tests/fm-spawn-dispatch-profile.test.sh adds coverage for the new health-gate branches (missing catalog, inactive/terminated entries, expiring warning).

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The change is a small, well-tested, additive gate in fm-spawn.sh with good test coverage of its branches (missing catalog, active, terminated, inactive, untracked model); the only gaps are a missing staleness check (mechanical, matches documented intent) and an extra undocumented fallback path (scope question), neither of which risks breaking existing behavior.

Testing

Ran the 5 new health-gate tests end-to-end against the real fm-spawn.sh in an isolated fixture HOME/worktree; all 5 passed (missing catalog warns+proceeds, active entry proceeds, early-terminated refuses, inactive-status refuses, untracked-model warns+proceeds). Full 1849-line suite run was killed after hanging ~20min on an unrelated pre-existing ultra-batch test spawning a real subprocess tree, unrelated to this change; the targeted subset isolates and confirms the new behavior live.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Dispatch proceeds with warning when health catalog file is absent ✅ pass live test_opencode_dispatch_proceeds_without_health_catalog passed against real fm-spawn.sh
Dispatch proceeds silently when catalog entry is active and not terminated ✅ pass live test_opencode_dispatch_proceeds_on_active_health_entry passed against real fm-spawn.sh
Dispatch refuses (exit 1, no launch, no meta) when catalog flags early_termination_detected=true ✅ pass live test_opencode_refuses_early_terminated_health_entry passed against real fm-spawn.sh
Dispatch refuses when catalog status is not 'active' (e.g. retired) ✅ pass live test_opencode_refuses_inactive_health_entry passed against real fm-spawn.sh
Dispatch proceeds with warning when catalog exists but doesn't track the selected model id ✅ pass live test_opencode_dispatch_proceeds_on_untracked_health_catalog_model passed against real fm-spawn.sh
Gate checks both documented candidate paths (knowledge/ first, data/ fallback) in load_catalog() order ✅ pass live bin/fm-spawn.sh:2220-2224 loops the two candidate paths in that exact order; test_opencode_dispatch_proceeds_on_active_health_entry writes to the first (knowledge/) path and dispatch picks it up
Evidence: Targeted health-gate test run output
ok - OpenCode proceeds on models.dev check alone when the health catalog is missing
ok - OpenCode proceeds when the health catalog marks the model active
ok - OpenCode refuses dispatch when the health catalog flags early termination
ok - OpenCode refuses dispatch when the health catalog status is not active
ok - OpenCode proceeds when the health catalog does not track the selected model

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 warning
  • ⚠️ bin/fm-spawn.sh:2228 - The new gate reads status/early_termination_detected/is_expiring_soon from the opencode-free-models.json entry but never checks the catalog's scan freshness (scanned_at), even though docs/model-dispatch-rigor.md explicitly documents that rule: 'If scanned_at is older than ~10 days ... treat the data as stale ... A stale scan is a reason to narrow more, never a reason to skip the check.' As written, a catalog the weekly cron stopped refreshing will keep reporting whatever status/flags it had at last scan (e.g. status=active) even though the real model may have since expired or been early-terminated, so the 'forced' gate silently passes a dead model. This is squarely within the user's stated intent (check whether the model is alive/not expired/not early-terminated before dispatch) and the doc already defines the exact staleness rule to apply; no new state/schema is needed since scanned_at is already part of the documented catalog format.
  • ⚠️ bin/fm-spawn.sh:2221 - A second, undocumented fallback catalog path ($HOME/Developer/IMAC/data/opencode-free-models.json) was added alongside the one location docs/model-dispatch-rigor.md actually names (AutomationSync/knowledge/opencode-free-models.json, written by opencode_free_model_scanner.py). Nothing in the user intent or the existing docs calls for a second source location, and it is untested. Recommend removing the second candidate and keeping the single documented path unless there's an undocumented reason for it.

🔧 Fix applied.
1 warning still open:

  • ⚠️ bin/fm-spawn.sh:2228 - The new gate reads status/early_termination_detected/is_expiring_soon from the opencode-free-models.json entry but never checks the catalog's scan freshness (scanned_at), even though docs/model-dispatch-rigor.md explicitly documents that rule: 'If scanned_at is older than ~10 days ... treat the data as stale ... A stale scan is a reason to narrow more, never a reason to skip the check.' As written, a catalog the weekly cron stopped refreshing will keep reporting whatever status/flags it had at last scan (e.g. status=active) even though the real model may have since expired or been early-terminated, so the 'forced' gate silently passes a dead model. This is squarely within the user's stated intent (check whether the model is alive/not expired/not early-terminated before dispatch) and the doc already defines the exact staleness rule to apply; no new state/schema is needed since scanned_at is already part of the documented catalog format.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Dispatch proceeds with warning when health catalog file is absent ✅ pass live test_opencode_dispatch_proceeds_without_health_catalog passed against real fm-spawn.sh
Dispatch proceeds silently when catalog entry is active and not terminated ✅ pass live test_opencode_dispatch_proceeds_on_active_health_entry passed against real fm-spawn.sh
Dispatch refuses (exit 1, no launch, no meta) when catalog flags early_termination_detected=true ✅ pass live test_opencode_refuses_early_terminated_health_entry passed against real fm-spawn.sh
Dispatch refuses when catalog status is not 'active' (e.g. retired) ✅ pass live test_opencode_refuses_inactive_health_entry passed against real fm-spawn.sh
Dispatch proceeds with warning when catalog exists but doesn't track the selected model id ✅ pass live test_opencode_dispatch_proceeds_on_untracked_health_catalog_model passed against real fm-spawn.sh
Gate checks both documented candidate paths (knowledge/ first, data/ fallback) in load_catalog() order ✅ pass live bin/fm-spawn.sh:2220-2224 loops the two candidate paths in that exact order; test_opencode_dispatch_proceeds_on_active_health_entry writes to the first (knowledge/) path and dispatch picks it up
  • bash tests/.health-gate-test.sh (trimmed copy running only the 5 new opencode-health tests plus required setup) against the real bin/fm-spawn.sh
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

… entry

Checks the project's weekly-scanned opencode-free-models.json (IMAC
AutomationSync knowledge, falling back to data/) after the existing
models.dev zero-cost check, so a model that is still listed and free
but already flagged early_termination_detected or non-active is caught
before dispatch instead of mid-task. A missing or non-matching catalog
warns and proceeds, since it is a secondary enrichment signal.
@Ivory2024 Ivory2024 changed the title feat(spawn): block opencode dispatch on unhealthy free-model entry 2026-87: feat(spawn): block opencode dispatch on unhealthy free-model entry Oct 4, 2026
@Ivory2024
Ivory2024 merged commit b3f213a into main Oct 4, 2026
17 of 18 checks passed
@Ivory2024
Ivory2024 deleted the fm/opencode-model-health-gate-20261004 branch October 4, 2026 09:21
Ivory2024 added a commit that referenced this pull request Oct 7, 2026
… entry (#87)

* feat(spawn): refuse opencode dispatch on unhealthy free-model catalog entry

Checks the project's weekly-scanned opencode-free-models.json (IMAC
AutomationSync knowledge, falling back to data/) after the existing
models.dev zero-cost check, so a model that is still listed and free
but already flagged early_termination_detected or non-active is caught
before dispatch instead of mid-task. A missing or non-matching catalog
warns and proceeds, since it is a secondary enrichment signal.

* no-mistakes(review): docs: document mechanical fm-spawn.sh free-model gate and dual-path lookup

* no-mistakes(document): docs: sync opencode harness ref with new health-catalog gate

* fix(spawn): fix opencode mini detection regex, keep legacy interactive fallback, and support catalog override
Ivory2024 added a commit that referenced this pull request Oct 7, 2026
… entry (#87)

* feat(spawn): refuse opencode dispatch on unhealthy free-model catalog entry

Checks the project's weekly-scanned opencode-free-models.json (IMAC
AutomationSync knowledge, falling back to data/) after the existing
models.dev zero-cost check, so a model that is still listed and free
but already flagged early_termination_detected or non-active is caught
before dispatch instead of mid-task. A missing or non-matching catalog
warns and proceeds, since it is a secondary enrichment signal.

* no-mistakes(review): docs: document mechanical fm-spawn.sh free-model gate and dual-path lookup

* no-mistakes(document): docs: sync opencode harness ref with new health-catalog gate

* fix(spawn): fix opencode mini detection regex, keep legacy interactive fallback, and support catalog override
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant