Skip to content

feat: save dispatch resolver answers beside task briefs - #8846

Open
korabeland wants to merge 1 commit into
kunchenguid:mainfrom
korabeland:fm/fm-dispatch-resolve-record
Open

korabeland wants to merge 1 commit into
kunchenguid:mainfrom
korabeland:fm/fm-dispatch-resolve-record

Conversation

@korabeland

@korabeland korabeland commented Nov 28, 2026 •

Copy link
Copy Markdown

Intent

Save each answer from the dispatch resolver beside its task brief, so tools that report how tasks were routed can still read it after the supervisor's session transcript is gone.
Off resolvers and briefs outside the data directory save nothing, and a failed save warns without changing the answer or exit code.

What Changed

  • Save each printed dispatch resolver answer beside its task brief, with task, timestamp, project, and applied rules version; replace the record on reruns.
  • Skip recording for off paths and briefs outside the configured data directory. Warn on save failure without changing the answer or exit code.
  • Document the record format and add coverage for clear, escalate, error, off, and save-failure cases.

Risk Assessment

✅ Low: The change adds bounded private task records while preserving resolver answers, off behavior, and exit codes.

Testing

The focused resolver test passed. I also drove the real resolver against a disposable local endpoint and isolated home, covering all requested outcomes and save boundaries. The transcript includes the printed answers and a persisted record; temporary fixtures were removed.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
  • Local lint (bin/fm-lint.sh and bin/fm-lint.sh --changed at 175d83c4): ✅ passed with pinned ShellCheck 0.11.0 and actionlint 1.7.12 (3 workflow files valid).
Scenario Result Live Evidence
Resolve a clear task and save its answer beside the brief, including task, project, time, and rules hash ✅ pass live Live resolver transcript
Resolve a task that requires captain approval and persist the escalation answer ✅ pass live Live resolver transcript
Encounter a provider transport failure and persist the error answer while exiting successfully ✅ pass live Live resolver transcript
Run with resolution off or with a brief outside the configured data directory and save no answer ✅ pass live Live resolver transcript
Make the record unwritable and confirm the resolver warns while preserving its clear answer and exit code ✅ pass live Live resolver transcript
Evidence: Live resolver transcript

Source: Live resolver transcript


[clear exit=0]
dispatch-resolve:
  status: clear
  model: local-live-fixture   latency_ms: 9   tokens: 12/3
  rule: rule_1 (A live clear rule)   confidence: 0.96
  probabilities: rule_1=0.96 rule_2=0.02 default=0.02
  note: rule matched
  candidate: cursor:cursor-grok-4.6-medium  provider=cursor  -> eligible (quota ranking off: home declares a single shared quota)
  profile: --harness 'cursor' --model 'cursor-grok-4.6-medium'

[escalation exit=0]
dispatch-resolve:
  status: escalate
  model: local-live-fixture   latency_ms: 10   tokens: 12/3
  rule: rule_2 (A live escalation rule)   confidence: 0.96
  probabilities: rule_1=0.02 rule_2=0.96 default=0.02
  reason: rule requires the captain's explicit approval before dispatch
  candidate: claude:sonnet  provider=claude  -> eligible (quota ranking off: home declares a single shared quota)

[error exit=0]
dispatch-resolve:
  status: error
  reason: http 000 after 10 ms
dispatch-resolve: error (http 000 after 10 ms)

[off exit=0]
dispatch-resolve: off (TYPESAFE_API_KEY absent from the environment and /var/folders/rx/ccvqvvc1239_17nnckxnq4vr0000gn/T//fm-dispatch-live.AFIFNX/home/.env)

[outside exit=0]
dispatch-resolve:
  status: clear
  model: local-live-fixture   latency_ms: 13   tokens: 12/3
  rule: rule_1 (A live clear rule)   confidence: 0.96
  probabilities: rule_1=0.96 rule_2=0.02 default=0.02
  note: rule matched
  candidate: cursor:cursor-grok-4.6-medium  provider=cursor  -> eligible (quota ranking off: home declares a single shared quota)
  profile: --harness 'cursor' --model 'cursor-grok-4.6-medium'

[failed-save exit=0]
dispatch-resolve:
  status: clear
  model: local-live-fixture   latency_ms: 9   tokens: 12/3
  rule: rule_1 (A live clear rule)   confidence: 0.96
  probabilities: rule_1=0.96 rule_2=0.02 default=0.02
  note: rule matched
  candidate: cursor:cursor-grok-4.6-medium  provider=cursor  -> eligible (quota ranking off: home declares a single shared quota)
  profile: --harness 'cursor' --model 'cursor-grok-4.6-medium'
dispatch-resolve: warning (could not save the answer to /private/var/folders/rx/ccvqvvc1239_17nnckxnq4vr0000gn/T/fm-dispatch-live.AFIFNX/home/data/savefail-live/dispatch-resolve.txt)

[clear persisted record]
dispatch-resolve-record:
  task: clear-live
  recorded_at: 2026-11-28T21:06:22Z
  project: pager
  rules: /var/folders/rx/ccvqvvc1239_17nnckxnq4vr0000gn/T//fm-dispatch-live.AFIFNX/home/config/crew-dispatch.json sha256=2dbe5aeb42b9434162fc9faf3808ecf50f69d6660c0ec426caa4043e981c554c
dispatch-resolve:
  status: clear
  model: local-live-fixture   latency_ms: 9   tokens: 12/3
  rule: rule_1 (A live clear rule)   confidence: 0.96
  probabilities: rule_1=0.96 rule_2=0.02 default=0.02
  note: rule matched
  candidate: cursor:cursor-grok-4.6-medium  provider=cursor  -> eligible (quota ranking off: home declares a single shared quota)
  profile: --harness 'cursor' --model 'cursor-grok-4.6-medium'

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Resolve a clear task and save its answer beside the brief, including task, project, time, and rules hash ✅ pass live Live resolver transcript
Resolve a task that requires captain approval and persist the escalation answer ✅ pass live Live resolver transcript
Encounter a provider transport failure and persist the error answer while exiting successfully ✅ pass live Live resolver transcript
Run with resolution off or with a brief outside the configured data directory and save no answer ✅ pass live Live resolver transcript
Make the record unwritable and confirm the resolver warns while preserving its clear answer and exit code ✅ pass live Live resolver transcript
  • tests/fm-dispatch-resolve.test.sh
  • Ran bin/fm-dispatch-resolve.sh against a disposable local systemone endpoint with an isolated FM_HOME
  • Checked persisted records for clear, escalation, and transport-error outcomes; checked no records for off and out-of-data briefs; forced a save failure and checked warning, output, and exit status
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

When the brief is <data>/<task>/brief.md, fm-dispatch-resolve.sh now also
writes every printed block (clear, ambiguous, escalate, or error) to
<data>/<task>/dispatch-resolve.txt, atomically replacing the previous answer.
A short header names the task, UTC time, project, and the rules file with a
SHA-256 of the rules snapshot applied, so the rule version in force is
recoverable after the supervisor transcript is pruned.

Off paths and briefs outside the data directory save nothing, and a failed
save warns on stderr without changing the outcome or exit code.
@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Reviews (1) · Last reviewed commit: "feat: save each dispatch-resolve answer ..." · Reviewed by Greptile

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @korabeland. This is my first look, at head 175d83c4 against main 30dae608.

Diff review: safe, no P1. Every printed block (clear, ambiguous, escalate, error) now goes through emit_block, which prints exactly what it printed before. It then saves the block only when --brief resolves to <data>/<task>/brief.md inside the home's data dir (FM_DATA_OVERRIDE or $FM_HOME/data). The save is a temp file plus mv, it refuses a directory at the target, and it strips newlines from the project value. A failed save only warns on stderr. The off path saves nothing, and stdout and the exit code are unchanged. The record holds the printed answer and a rules hash, never the brief text or the key. No workflow or credential changes. The only network call is the resolver's existing one.

Fork CI: this is your first run here, so I approved this head's runs (46190189034, 46190188927, 46192322455) after that read.

Gates: the attestation binds this head with every step completed, Greptile is 5/5 with no threads, and live is 5 of 5 against a local fixture endpoint. That covers the save contract, which is what changed.

Overlap, for Kun: #7365 (@Azd325) solves the same need differently, with one JSONL line per resolution in state/dispatch-resolve.jsonl. It's already waiting on Kun's decision. He'll likely want one of the two, or both on purpose. Neither of you needs to do anything about it now.

Contract class: new-default. Once typed dispatch is configured, every resolution now also writes a file beside the brief, with no switch of its own. That's the same read as #7365. So when the quick checks and a full suite are green, it goes to Kun as a merge-or-leave decision. It won't auto-merge. VISION, rule by rule: One captain, one interface: aligns (no captain-facing change). Authority is explicit: aligns, nothing new is decided. Scripts own the mechanics: aligns, exact and bounded. A restart is a non-event: aligns, that's the point (the answer outlives the transcript). Delegation with a spine: aligns. Fleet outlives any vendor: aligns. Scope: aligns, private records under the home. Status: nothing is waiting on you. full-ci comes after the quick checks pass, within a later pass's label budget.

@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 30, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @korabeland. Head 175d83c4 is unchanged and main f6e4915f is green, so I've added full-ci. Your fork's label-triggered run needed approval, and I've approved it (46346368800). Diff review: safe, no P1 (I re-read the current diff: the atomic save beside data/<id>/brief.md, the rules SHA-256 header, and the warn-only failure path). The attestation binds this head with every step completed, and the quick checks and Greptile pass. Contract class: new-default (the resolver now writes dispatch-resolve.txt without any opt-in), so a green suite goes to Kun as a decision instead of auto-merging. Nothing is waiting on you.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: the full suite is green on 175d83c4 (run 46346368800), and the PR still merges cleanly onto main bcdeaba5. Contract class: new-default, so this goes to Kun for his merge word instead of auto-merging. Nothing is waiting on you. It's a captain decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants