Skip to content

fix(bin): key descoped events and scrub PR details in place, not sections - #2904

Closed
teseo wants to merge 3 commits into
kunchenguid:mainfrom
teseo:fm/fm-descope-visible
Closed

teseo wants to merge 3 commits into
kunchenguid:mainfrom
teseo:fm/fm-descope-visible

Conversation

@teseo

@teseo teseo commented Aug 23, 2026

Copy link
Copy Markdown

Intent

Two fleet-contract fixes in firstmate's shared tracked material, both born from the same captain incident: a worker delivered HALF of a morning-planned brief, said so only in PR prose, reported done:, and the dropped half silently vanished until rediscovered by accident at night. The captain's ruling: a worker may descope, but never silently; and the PR privacy scrub must delete details, never sections.

Change 1: descopes are keyed, durable, and cannot die in prose.

  • Generated ship briefs (bin/fm-brief.sh) must require that if the worker drops, defers, or narrows ANY requirement from the # Task section (including acceptance criteria), it MUST append a keyed status event descoped [key=descope-<slug>]: {what was dropped and why} for each dropped item, BEFORE its done: line. A done: that silently omits brief scope without a matching descoped: event is a named contract violation.
  • Keyed descoped: events join the existing open-keyed-event machinery in bin/fm-classify-lib.sh exactly like blocked:/needs-decision: holds: they fold into the drain's OPEN DECISIONS surface and keep re-presenting at session start until explicitly resolved (routed to a follow-up task or closed with the captain's word via the existing --resolve-key path). Reuse the existing keyed open/resolved semantics; do not build a parallel ledger.
  • Docs that already enumerate blocked:/needs-decision: as keyed events gain the descoped kind, pointer-style.

Change 2: PR privacy scrub deletes details, never sections.

  • In bin/fm-brief.sh's generated no-mistakes Definition-of-done scrub step, remove machine paths, home directories, usernames, and local-environment details ONLY; never remove or rewrite whole sections (Intent, What Changed, Testing) while scrubbing: redact within lines, keep the document structure. Measured incident: a privacy-heavy task's worker deleted the entire Intent section during scrub.

Acceptance: scaffold a fresh ship brief and assert the generated contract wording; a descoped: ... [key=descope-x] line surfaces in the drain's open-events fold and stays open across a simulated restart until a resolved line with the same key lands; existing scaffold, classify, and drain tests stay green; PR body uses product language with no local paths.

Deliberate decisions while implementing:

  • Put the key in the documented before-colon position (descoped [key=descope-<slug>]: {what}) rather than trailing after the note. The existing fold treats a mid-note or trailing [key=...] as prose, so a trailing example would silently fail to open the decision and recreate the incident.
  • descoped is captain-relevant so the drop wakes immediately, but it is not a terminal wait verb: the worker continues to done: after recording the drop.
  • The descoped contract is ship-only; the PR-section scrub is no-mistakes Definition of done only.
  • Tests exercise fm-brief.sh's generated brief output (its public generated-text contract) and the classify/drain public fold, not implementation-source greps of the library internals.
  • Brief tests unset ambient FM_STATE_OVERRIDE and FM_DATA_OVERRIDE so path-resolution cases own their directories when launched inside a firstmate home.

What Changed

  • Ship briefs now require a keyed descoped [key=descope-<slug>]: {what was dropped and why} status event before done: whenever task-section requirements are dropped, deferred, or narrowed, folding into the existing open-keyed-event machinery so descopes surface in the drain's OPEN DECISIONS and stay open until a matching resolved/captain-held line closes them.
  • The no-mistakes Definition-of-done PR scrub now removes only machine paths, home directories, usernames, and local-environment details in place — never whole sections — preserving the Intent/What Changed/Testing structure.
  • Descope classification is captain-relevant but non-terminal: it wakes immediately while the worker continues to done, and done:/failed: no longer suppress an open descoped decision in captain-hold inventory.

Risk Assessment

✅ Low: The change is well-bounded and mostly additive (new keyed verb, contract wording, doc updates) with one targeted, correctly-scoped behavior fix that honors the documented fold invariant without disturbing the existing suppress-on-done semantics for needs-decision/blocked, and it is covered by behavior-level tests.

Testing

I exercised the keyed-descope contract end-to-end: scaffolded a real ship brief (no-mistakes mode) to confirm the generated States list and keyed descoped: contract wording plus the details-only/keep-sections PR scrub, then drove the real wake drain over a descoped [key=descope-x] followed by done: to confirm it surfaces in OPEN DECISIONS, survives a simulated restart, and disappears once a resolved [key=descope-x] line lands. The five targeted behavior suites (classify fold, drain, triage verb classification, brief scaffold, captain-hold inventory routing) all pass, and the diff introduces no local machine paths. No issues found.

Evidence: Generated ship brief (no-mistakes mode) showing the descoped States list, keyed descoped: contract, and keep-sections PR scrub

Source: Generated ship brief (no-mistakes mode) showing the descoped States list, keyed descoped: contract, and keep-sections PR scrub

You are a crewmate: an autonomous worker agent managed by firstmate. Work on your own; do not wait for a human.

# Task
{TASK}

# Herdr lifecycle declaration - NOT ENABLED
**HARD SAFETY GATE:** this scaffold cannot inspect the task text filled in above.
If the task will start, stop, delete, restart, profile, or otherwise drive Herdr lifecycle behavior, stop and regenerate the brief with `--herdr-lab` before dispatch.
Do not add Herdr lifecycle commands to this unguarded brief by hand.

# Setup
You are in a disposable git worktree of sample-repo, at a detached HEAD on a clean default branch.

**Verify isolation before anything else.** Run `pwd -P` and `git rev-parse --show-toplevel`; both must resolve to the disposable task worktree you were launched in, such as a treehouse pool path or an Orca-managed worktree, not the primary checkout firstmate operates from.
The path check is authoritative: `git rev-parse --git-dir` and `git rev-parse --git-common-dir` can help inspect the repo, but they do not prove you are outside the primary checkout.
If the top-level path is the primary checkout or not the worktree you were launched in, STOP - do not branch or commit here - append `blocked: launched in primary checkout, not an isolated worktree` to the status file and stop.

1. First action: create your branch: `git checkout -b fm/demo-ship-descope`
2. Run `no-mistakes doctor`; if it reports the repo is not initialized here, run `no-mistakes init`.

# Rules
1. Never push to the default branch. Never merge a PR.
2. Stay inside this worktree; modify nothing outside it.
3. Use gh-axi for GitHub operations and chrome-devtools-axi for browser operations.
4. Report status by appending one line:
   `echo "{state}: {one short line}" >> '/var/folders/4m/dpx5d4mx2c3701rzh7sw3vtr0000gn/T/tmp.GKMQNyf4Nc/state/demo-ship-descope.status'`
   States: working, needs-decision, blocked, paused, descoped, done, failed.
   Each append wakes firstmate, so report sparingly: only phase changes a supervisor
   would act on (setup done, bug reproduced, fix implemented, validation passed) and the
   needs-decision/blocked/paused/descoped/done/failed states. No step-by-step FYI progress lines;
   firstmate reads your pane for that.
   A mid-task `working:` line (including setup complete) is nonterminal: do not end the
   turn after it; continue the same stage until a defined `done:` gate under Definition of done.
   Use `paused: {why}` - distinct from `blocked:` - ONLY when you are deliberately idling on a
   known external wait you expect to clear on its own (an upstream release, a rate-limit reset,
   a scheduled window): firstmate then leaves your idle pane alone and rechecks it on a long
   cadence instead of treating it as a possible wedge. Use `blocked:` when you are stuck and need help.
   If you drop, defer, or narrow ANY requirement from the `# Task` section (including acceptance criteria), you MUST append a keyed status event `descoped [key=descope-<slug>]: {what was dropped and why}` for each dropped item, BEFORE your `done:` line. A `done:` that silently omits brief scope without a matching `descoped:` event is a contract violation.
5. If you hit the same obstacle twice, append `blocked: {why}` and stop; firstmate will help.
6. If a decision belongs above the implementation worker (product choices, destructive actions, ask-user findings),
   append `needs-decision: {summary of options}` and stop. Firstmate will reply with the decision.
   A decision or blocker you opened stays open until a `resolved` line carrying its exact key lands; a later `done:` or `working:` line never closes it, even when the answer is what started that work.
   Firstmate's reply normally writes that closing line at answer time; when a blocker or wait clears WITHOUT a firstmate reply, append `resolved: {how it cleared}` yourself (same `[key=<slug>]` if you opened it with one) as you resume.
7. Never stop, restart, or update the shared `no-mistakes` daemon - it is one instance serving
   every lane/home, so restarting it kills other lanes' in-flight pipeline runs. On ANY no-mistakes
   daemon error, append `blocked: {the daemon error}` and stop; only firstmate manages the daemon.

# Firstmate instruction inbox
Firstmate steers you through durable message files in '/var/folders/4m/dpx5d4mx2c3701rzh7sw3vtr0000gn/T/tmp.GKMQNyf4Nc/state/demo-ship-descope.inbox'.
When a terminal message says an instruction is waiting there - and at any natural checkpoint when you are unsure - list '/var/folders/4m/dpx5d4mx2c3701rzh7sw3vtr0000gn/T/tmp.GKMQNyf4Nc/state/demo-ship-descope.inbox'/*.msg, read and act on each message in numeric order, then acknowledge each handled message by moving it: `mv '/var/folders/4m/dpx5d4mx2c3701rzh7sw3vtr0000gn/T/tmp.GKMQNyf4Nc/state/demo-ship-descope.inbox'/NNN.msg '/var/folders/4m/dpx5d4mx2c3701rzh7sw3vtr0000gn/T/tmp.GKMQNyf4Nc/state/demo-ship-descope.inbox'/handled/`.
The move IS the acknowledgement: without it firstmate rings again and eventually treats you as stuck. An empty or absent inbox needs no action.

# Project memory
If `AGENTS.md` or `CLAUDE.md` already exists, or if this task produced durable project-intrinsic knowledge, run `/Users/javiermellado/.no-mistakes/worktrees/a3e9874797a4/01M0RB1VCT9WZJDY0DPRBCRESJ/bin/fm-ensure-agents-md.sh .` in the worktree.
Record only project knowledge useful to almost every future session.
For anything the codebase already shows, prefer a pointer to the authoritative file, command, or doc over copying the detail.
If you touch a project `AGENTS.md` that lacks `## Maintaining this file`, add that short self-governance section from `/Users/javiermellado/.no-mistakes/worktrees/a3e9874797a4/01M0RB1VCT9WZJDY0DPRBCRESJ/bin/fm-ensure-agents-md.sh` in the same pass.
Keep it proportionate: skip `AGENTS.md` edits for trivial tasks that produced no durable project knowledge.

# Definition of done
Delivery contract: mode=no-mistakes
The task is complete only when committed on your branch.
When you believe it is complete, append `done: {summary}` to the status file and stop.
Firstmate will then instruct you to run /no-mistakes to validate and ship a PR.

You drive no-mistakes by responding to its gates, not by implementing fixes.
Follow the guidance no-mistakes itself provides for the mechanics: it loads when you invoke /no-mistakes, and `no-mistakes axi run --help` plus the `help` lines in each `axi` response are authoritative and version-matched to the installed binary.
When starting no-mistakes, make `--intent` preserve all relevant content from this brief's `# Task` section plus every later accepted Firstmate requirement, clarification, constraint, exclusion, and supersession, carrying only each requirement's current accepted form; retain direct requirements instead of substituting a diff summary, and exclude generic operational, status, delivery, and other scaffold boilerplate unless it is task-specific.
Do not hand-edit, commit, or fix findings yourself while a run is active - the pipeline applies every fix.

Two firstmate-specific rules layer on top of that guidance:
- ask-user findings are never yours to answer: escalate to firstmate (rule 6) and stop.
  Firstmate applies `ask-user-authority` and obtains any required captain decision.
  When the decision comes back, feed it to the gate with `no-mistakes axi respond` and let the pipeline apply it - do not route the question to "the user" or implement the fix yourself.
- Avoid `--yes`: it would silently bypass firstmate's authority check and any required captain escalation.

After /no-mistakes reports CI green (the CI-ready return point - do not wait for it to keep monitoring in the background until merge), RE-READ the PR title and body as published on GitHub: the pipeline can inject local evidence paths into the body, and no machine path, home directory, username, or other local-environment detail may remain public; scrub any with `gh pr edit` before reporting.
Remove machine paths, home directories, usernames, and local-environment details ONLY; never remove or rewrite whole sections (Intent, What Changed, Testing) while scrubbing: redact within lines, keep the document structure.
Then append `done: PR {url} checks green` and stop. You are finished.
Evidence: Drain end-to-end: descoped decision surfaces, survives restart, and closes on resolved

Source: Drain end-to-end: descoped decision surfaces, survives restart, and closes on resolved

descoped [key=descope-x]: dropped the follow-up because it was out of scope done: shipped the remaining half OPEN DECISIONS (still open, folded from the durable status logs - not just the latest line): task-descope [key=descope-x] descoped: dropped the follow-up because it was out of scope OPEN DECISIONS: close one by answering it: bin/fm-send.sh <task> --resolve-key <key> '<answer>' (same OPEN DECISIONS line re-presented on the simulated-restart drain) (after 'resolved [key=descope-x]: routed to a follow-up task' -> no OPEN DECISIONS line printed)

\### STEP 1 — worker appends keyed descoped, then done: (the measured incident shape)
--- status log ---
descoped [key=descope-x]: dropped the follow-up because it was out of scope
done: shipped the remaining half

\### STEP 2 — first drain surfaces the open descoped decision
OPEN DECISIONS (still open, folded from the durable status logs - not just the latest line):
task-descope [key=descope-x] descoped: dropped the follow-up because it was out of scope
OPEN DECISIONS: close one by answering it: bin/fm-send.sh <task> --resolve-key <key> '<answer>'

\### STEP 3 — simulated restart (second drain) still re-presents it
OPEN DECISIONS (still open, folded from the durable status logs - not just the latest line):
task-descope [key=descope-x] descoped: dropped the follow-up because it was out of scope
OPEN DECISIONS: close one by answering it: bin/fm-send.sh <task> --resolve-key <key> '<answer>'

\### STEP 4 — captain resolves the key; third drain no longer prints it open
=== (no OPEN DECISIONS above = resolved) ===

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 3 issues found → auto-fixed ✅
  • ⚠️ bin/fm-captain-hold.sh:296 - origin_open_decisions() returns empty whenever a ship worker's last status line is done: or failed: (case 'done|failed) return 0' at line 296), on the assumption that finishing the run supersedes any still-open decision. The new descoped invariant is precisely that done: does NOT close a descoped decision (bin/fm-classify-lib.sh:349 keeps it open across done:, and the drain test asserts it survives a done: line). So a worker that appends 'descoped [key=descope-x]: ...' then 'done: ...' leaves the descoped decision open in status_open_decisions but invisible to fm-captain-hold.sh: command_complete's --none attestation (line 809-811 uses the suppressed open) succeeds with no warning, and command_verify (line 860) sees nothing untransferred, so the descope cannot be routed into the captain-held inventory through this path (only closed via fm-send --resolve-key). The transfer loop itself uses the unsuppressed raw_open (line 808/826), so routing WITH keys still works; the concrete gap is the --none attestation and verify treating a done worker's open descope as already-superseded while the drain still surfaces it as open. Recommended fix at the shared boundary: in origin_open_decisions, do not suppress decisions whose opening verb is descoped when the last line is done/failed (i.e. stop re-deriving 'done supersedes all' here and honor the fold's verb-specific semantics).
  • ℹ️ bin/fm-fleet-snapshot.sh:504 - The fleet snapshot's captain-decision derivation does not recognize the new descoped verb: hints.pending_decision (line 504) tests only .verb == 'needs-decision', hints.blocked_event (line 505) only 'blocked', the secondmate home-summary state (line 764) classifies 'captain_decision' only for 'needs-decision'/'captain-hold', and the secondmate decision matching (line ~1112) yields 'inconclusive' for any other verb. The full open set (hints.open_decisions / decisions_open, derived from status_open_decisions) DOES include descoped, so the raw data is present; but the derived booleans, the state label, fm-crew-state.sh map_log_state (descoped -> 'unknown'), and fm_voice_records.py STATE_VERBS (descoped not allowed, reported as 'note') do not treat descoped as captain-actionable. Consequence: on surfaces other than the drain (bearings board, secondmate summaries, voice), a descoped decision may be labeled no_active_work/unknown/note instead of a pending captain decision. Informational: the drain is the authoritative re-presentation surface the intent names, and it is correct and tested; these are adjacent-surface completeness gaps, not a correctness failure of the change's own scope.
  • ℹ️ bin/fm-brief.sh:463 - The generated ship brief's canonical 'States:' enumeration (line 463) still lists 'working, needs-decision, blocked, paused, done, failed' without descoped, while the very next line (466) added descoped to the 'would act on' list and rule 4 (line 474) mandates the descoped event. Minor inconsistency in the generated contract wording: a worker reading the enumeration literally might not realize descoped is a valid status verb even though rule 4 explicitly instructs it. Add descoped to the States: list for consistency with the adjacent 'would act on' list.

🔧 Fix: Honor descoped decisions through done and ship briefs
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-classify-decision-key.test.sh — descoped [key=X] opens like blocked, stays open across working:/done:, closes on matching resolved (both key positions)
  • bash tests/fm-wake-drain-open-decisions.test.sh — keyed descoped surfaces in the OPEN DECISIONS fold, survives a simulated restart, closes on resolved
  • bash tests/fm-watch-triage.test.sh — descoped is captain-relevant but non-terminal (not a terminal wait verb)
  • bash tests/fm-brief.test.sh — ship States list includes descoped, keyed descoped + PR-scrub contract render; scout/secondmate and non-no-mistakes modes excluded
  • bash tests/fm-captain-hold-lifecycle.test.sh — a descoped decision survives done: and routes into the captain-held inventory via complete/hold/verify
  • Manual scaffold: FM_HOME=&lt;tmp&gt; bash bin/fm-brief.sh demo-ship-descope sample-repo --mode no-mistakes, then inspected the generated brief.md (States list, descoped contract, keep-sections scrub)
  • Manual drain demo: drove bin/fm-wake-drain.sh over descoped [key=descope-x] + done: (surface), re-ran for restart (re-present), then resolved [key=descope-x] (no longer open)
  • git diff base..target | grep -E &#39;/Users/|/home/&#39; confirmed no local machine paths introduced; commit messages are product language
✅ **Document** - passed

✅ No issues found.

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

✅ No issues found.

teseo added 3 commits August 23, 2026 23:01
…bing

A worker may drop brief scope, but the drop must be a keyed descoped:
status event that stays open until resolved. The no-mistakes PR privacy
scrub now redacts local details in place and must not delete sections.
@greptile-apps

greptile-apps Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5

The PR should not merge until terminal fleet snapshots preserve unresolved descoped decisions.

The shared fold now makes descopes durable across completion, but a reachable captain-facing snapshot path still erases them solely because the worker is terminal.

Files Needing Attention: bin/fm-classify-lib.sh, bin/fm-fleet-snapshot.sh

Comments Outside Diff (1)

  1. bin/fm-classify-lib.sh, line 349-353 (link)

    P1 Terminal snapshots erase descopes

    When a ship or scout appends a keyed descoped event and then reaches done or failed, this fold keeps the decision open but fm-fleet-snapshot.sh clears the entire folded set. Fleet and Bearings snapshots therefore omit the unresolved dropped requirement even though the drain continues to surface it.

Reviews (1): Last reviewed commit: "no-mistakes(document): Document descoped..." | Re-trigger Greptile

@teseo teseo closed this by deleting the head repository Sep 15, 2026
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