Skip to content

chore: rebind/signal polish — review findings from #567/#568 - #575

Merged
danshapiro merged 14 commits into
mainfrom
chore/rebind-review-polish
Jul 29, 2026
Merged

chore: rebind/signal polish — review findings from #567/#568#575
danshapiro merged 14 commits into
mainfrom
chore/rebind-review-polish

Conversation

@danshapiro

Copy link
Copy Markdown
Owner

Polish pass on the rebind/signal work from #567/#568, closing the minor findings from both delta reviews.

Items fixed

  • Deterministic signal-file ordering — claude signal drain sorts by filename (timestamp-first nonces) for deterministic last-write-wins under multiple pending signals
  • Claude live-sidecar guard parity — claude rebind lane now checks the live freshclaude sidecar map (D7 defense-in-depth parity with the codex lane)
  • Portable nonce — claude SessionStart nonce no longer relies on GNU-only date +%s%N (was broken on macOS); timestamp-first for sortability
  • Warn-once fork-ambiguity logging — codex fork-ambiguity warn is rate-limited to once per window instead of spamming every sweep
  • Percent-encoded file:// plugin URLs — opencode plugin URL handles unusual characters in home paths; validated against live Node and Bun encoding oracles
  • Foreign-signal disposition/cleanup — signals addressed to a foreign-provider pane are explicitly warn-logged and consumed (bounded junk) instead of silently retained forever
  • Test hygienecodex_locator.rs test module split into a sibling file
  • Doc fixes — stale codex resume claims in the 2026-07-26 locator plan; stale pid-first nonce wording in the drain doc

Review status

🤖 Generated with Amplifier

danshapiro and others added 14 commits July 29, 2026 02:08
…ation

Validated the plan's 11 load-bearing assumptions (7 verified, 3
falsified, 1 deferred with in-plan contingency). Fixes for the
falsified ones:

- Task 6: encode set corrected to pathToFileURL parity, oracle-verified
  against the installed Bun 1.3.14 / Node v22.21.1 (adds [ \ ] ^ | ~;
  posix backslash percent-encoded, not rewritten; 5 new table cases).
- Tasks 1+2: ordering contract narrowed to GNU-deterministic with a
  documented, self-correcting second-granularity fallback residual
  (same-second order degrades to pid order; design unchanged).
- Task 9: new Step 0 (npm ci prerequisite) -- cargo test --workspace
  depends on node_modules via the freshagent tsx MCP resolution; also
  records the verified green baseline and one known timing flake.

Also annotates Task 7 with the verified mode/provider-permanence
premise and the global port-safety constraint with the audit result.
The goldens module is mounted as cli_argv_goldens_file inside
cli_launch.rs, so the filter 'cli_launch_goldens' matched zero tests
and the step's Expected: FAIL could never occur. Use the module-path
filter cli_argv_goldens_file and note why.
…module (fresheyes review 2)

The plan told the implementer to add unit tests to cli_launch.rs's
'existing #[cfg(test)] mod tests', but that file has no in-file test
module (only the cli_launch_goldens.rs mount). Step 1 now explicitly
creates the module after the goldens mount and confirms the resulting
cli_launch::tests::... paths match Step 2's --lib cli_launch filter.
…nonce

date +%s%N is GNU-only; BSD/macOS degraded the nonce to a literal N and
made the timestamp useless for ordering. POSIX fallback keeps 19-digit
width-stable digits-only nonces, timestamp-first so the consumer's
filename sort (next commit) is emission order on GNU date (on the
second-granularity fallback, same-second order degrades to pid order --
documented residual, self-correcting). Uniqueness is preserved:
GNU keeps ns precision; elsewhere (second, pid) -- same as before.
…te-wins

Bare read_dir order made rapid A->B->A switches within one sweep window
land nondeterministically. Filename sort over the timestamp-first nonces
(previous commit) makes drain order emission order on GNU date (the
second-granularity fallback degrades same-second order to pid order --
documented residual), matching the opencode lane's already-shipped
contract.
…map (D7 parity)

The codex lane probes fresh_codex.has_live_session before honoring a
claim; the claude lane only had the durable fresh-agent ledger-row twin,
leaving a window where a sidecar with an unlanded row was invisible.
Adds the in-memory probe in the same guard position codex uses.
Pure code-move to the repo's #[path]-included child-module convention
(pane_ledger_tests.rs et al.); both files now respect the <=1K-line
limit and the tests keep private-item access. 34 tests before and after.
…per window

The n>=2 refusal arm re-warned on every sweep tick for the whole fork
window. Adds a log-only latch on ForkWatch, re-armed by a new Enter
(note_fork_submit); refusal semantics and the deliberate no-merge of
ambiguous hits are unchanged.
A home dir containing '#', '?', or '%'+hex produced a URL Bun resolves
to the wrong path (silent pane-lifetime import failure); space/non-ASCII
broke opencode's dedup-by-file-URL contract. Encode the path to the
canonical WHATWG form (pathToFileURL parity) via percent-encoding.
…l files

Foreign-provider signals were silently retained and re-rejected every
sweep for 10 minutes -- the exact silently-never-firing shape the module
header warns against. They are permanently unactionable (pane mode and
identity provider never change), so: warn once, consume the file
(SignalDisposition::Discard). Also reaps orphaned .tmp staging files on
the existing TTL. Pane identity is never touched; all legitimate
retention (no-pane-yet, not-live-yet) is unchanged.
…tor plan

In-TUI /resume may fork into a new rollout file (openai/codex#34972);
the flat 'no new file' claim predated the fork lane. Also annotates the
pinned interface block as pre-fork-lane. Historical doc, correction
markers included.
The drain doc still described the old pid-first <pid>-<ns> nonce shape; the producer now emits <timestamp>-<pid> (branch's own Task 1 change). Also wraps the adjacent long sort-rationale doc line. Doc-comment only.
…ex-lane-self-healing) into rebind-review-polish

Semantic merge of the opencode signal lane, preserving both sides:

- main's OpencodeDrainOutcome split (rebinds + hellos), plugin-alive hello
  delete-on-read, HelloTracker with once-per-pane grace-window warning
- branch's SignalDisposition ladder (Acted/Retain/Discard) with explicit
  foreign-provider signal discard, stale .tmp staging reap, and all other
  polish items (deterministic claude drain ordering, portable
  timestamp-first nonce, sidecar guard parity, warn-once fork-ambiguity,
  percent-encoded plugin URL, codex_locator test split)

Conflicts (crates/freshell-ws/src/opencode_signal.rs):
- drain() doc + signature: kept OpencodeDrainOutcome return with combined
  doc covering hellos AND stale-.tmp reaping
- drain_and_rebind_opencode(): kept main's hello-tracker pass, folded the
  rebind loop onto the branch's SignalDisposition match
- adapted branch test drain_reaps_stale_tmp_staging_files_but_keeps_fresh_ones
  to the OpencodeDrainOutcome shape

Hello files are discriminated at parse time (before the rebind ladder), so
the foreign-signal Discard path can never consume a hello as "foreign".

Verified: cargo fmt --check, clippy -D warnings, cargo test --workspace
(2198 passed / 0 failed), contract freeze (test:port + regen idempotency +
freshell-protocol --locked), coordinated npm run check.

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <[email protected]>
@danshapiro
danshapiro merged commit 90c027a into main Jul 29, 2026
3 checks passed
@danshapiro
danshapiro deleted the chore/rebind-review-polish branch July 29, 2026 16:17
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