Skip to content

fix(bin): attach bounded context to actionable wakes - #2801

Open
Cl3MM wants to merge 3 commits into
kunchenguid:mainfrom
Cl3MM:fix/1692-bounded-wake-context
Open

fix(bin): attach bounded context to actionable wakes#2801
Cl3MM wants to merge 3 commits into
kunchenguid:mainfrom
Cl3MM:fix/1692-bounded-wake-context

Conversation

@Cl3MM

@Cl3MM Cl3MM commented Aug 22, 2026

Copy link
Copy Markdown

Summary

Actionable watcher wakes currently give the primary agent only a reason and an instruction to drain the queue. The agent then reconstructs task, decision, endpoint, and status state through several provider turns, each carrying the full primary context.

This PR adds a bounded fm-wake-context.v1 presentation so Claude, Codex, and Pi receive deterministic operational context with the actionable wake.

What changes

  • stage the wake presentation before advancing any status cursor
  • preserve byte-identical replay until the exact acknowledgement is handled
  • include bounded task, decision, endpoint, and recent-status projections
  • keep full reports and logs on disk instead of embedding them
  • use byte-based packet limits, including UTF-8 content
  • fall back to one canonical drain instruction when collection times out or exceeds its buffer
  • commit status cursors monotonically and handle status-file rotation
  • preserve the existing queue, session-lock, acknowledgement, and manual-drain contracts

Safety coverage

The tests cover the seven failure cases found during the first local review:

  1. bounded unread-status projection with an omitted-line count
  2. absolute task-check keys
  3. --ack-through 0 replay and commit
  4. monotonic cursor merge across status-file rotation
  5. strictly positive backend and Pi collection timeouts
  6. wake-cardinality validation against the post-presentation snapshot
  7. Pi ENOBUFS handling through the public actionable-close delivery path

Validation

  • tests/fm-wake-context.test.sh: PASS
  • ShellCheck on changed shell scripts: PASS
  • Bash syntax checks: PASS
  • git diff --check origin/main...HEAD: PASS

The Pi, Claude, and checkpoint suites that depend on tests/lib.sh could not run in the local sandbox because process-identity discovery requires unavailable sysmond access. CI remains responsible for those adapter suites.

Fixes #1692

@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown

Confidence Score: 4/5

The PR should not merge until Claude and Codex wake-context collection has an aggregate deadline that guarantees timely fallback.

Actionable wakes can currently block in synchronous, sequential context collection because local crew-state lookup is unbounded and per-task backend deadlines accumulate across the fleet.

Files Needing Attention: bin/fm-wake-context.sh, bin/fm-claude-stop-autoarm.sh, bin/fm-watch-checkpoint.sh

Reviews (1): Last reviewed commit: "test(bin): stabilize wake context safety..." | Re-trigger Greptile

Comment thread bin/fm-wake-context.sh
Comment on lines +224 to +227
write_tasks() { # <ids> <out>
local task
: > "$2"
while IFS= read -r task; do [ -z "$task" ] || write_task "$task" "$2"; done < "$1"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Wake collection lacks aggregate deadline

When a task's crew-state lookup stalls, or several task backend probes consume their individual deadlines, this serial loop keeps the synchronous Claude Stop hook and Codex checkpoint blocked instead of delivering the actionable wake and canonical fallback. Apply an overall collection deadline or equivalent bound to the complete presentation path.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

VISION: aligns. Token efficiency is first-class: actionable wakes currently spend frontier turns reconstructing crew state. Scripts own that mechanics; bin/fm-wake-context.sh attaches a bounded fm-wake-context.v1 packet (byte caps, staged presentation before cursor advance, byte-identical replay until ack, canonical drain fallback). Authority is unchanged: presentation is not a new grant. Distinct from lock-steal #2796.

Class: corrective. Fixes #1692 on the existing always-on wake path. Not a new default product behavior.

Security: none. Local fm-wake-context.sh --present only; packet/status/file bounds; 0600 cache; no network, no credentials, no workflow file. Greptile P1 (no aggregate collection deadline on Claude Stop / Codex checkpoint) is reliability, not a gate.

Overlap: bin/fm-wake-drain.sh and bin/fm-classify-lib.sh with open #2749. Does not edit bin/fm-watch.sh. #2795 and #2631 are closed. Preferred candidate if later fully green.

CI: HEAD 6e16a25ab5f2196e143346dafe3d9302fa91a5c8. mergeable MERGEABLE, mergeStateStatus UNSTABLE. ahead 3 / behind 0. Fork CI 32595118059 in_progress (approved earlier this pass, not green). Require no-mistakes / body-compliance 32595117981 FAILURE. No structured no-mistakes-pipeline-attestation:v1 whose head_sha matches THIS HEAD — no-mistakes is blocking. A git-push signature is not a substitute. Greptile FAILURE — not a gate.

Workflows approved: yes (CI 32595118059, NM 32595117981). Land-eligible: NO. Waiting on CI; even a green CI still needs a matching NM attestation from the author. Not waiting on the captain. Captain-flag NOW: no.

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.

Firstmate burns through my credits too quickly because of excessive watcher events

3 participants