Skip to content

Amplifier integration fixes: bundle stamping, server detach, idle-reap cap, session backfill - #600

Merged
danshapiro merged 15 commits into
mainfrom
land/amplifier-integration-fixes
Aug 3, 2026
Merged

Amplifier integration fixes: bundle stamping, server detach, idle-reap cap, session backfill#600
danshapiro merged 15 commits into
mainfrom
land/amplifier-integration-fixes

Conversation

@danshapiro

Copy link
Copy Markdown
Owner

Why

Three-round adversarially-reviewed investigation found:

What

  1. Bundle stamping: stamp the user's active bundle (merged settings resolution: global → project → local, plain-string-only, omit-on-any-surprise) into new session stubs — mirrored Rust (saphyr) + TS resolvers with contract tests.
  2. Detached server launch: setsid-detached server launch in scripts/launch-rust.sh + optional systemd user unit (launcher-level only, pid-file semantics preserved).
  3. Idle-reap hard cap: 24-hour hard cap on idle-reaping agent-mode terminals (claude/codex/amplifier/opencode/gemini/kimi).
  4. Session backfill: one-time backfill script (scripts/amplifier-backfill-bundle.ts, dry-run default, apply refuses while any amplifier process is live, byte-fidelity guard) — already executed successfully on the author's machine: 39/39 sessions healed, verified end-to-end.

Validation

Full the-usual workflow:

  • Plan review (2 rounds)
  • 18 load-bearing assumptions tested (8 falsified and designed around)
  • Execution 12/12 tasks
  • Delta review (2 rounds), final review APPROVED
  • All Rust + TS suites green
  • Detached launch live-verified

Implementation plan: docs/plans/2026-08-02-amplifier-integration-fixes.md

danshapiro and others added 15 commits August 2, 2026 23:04
…/ 8 falsified)

Validated against the installed amplifier_app_cli 0.1.1 (1873aa9), the real
~/.amplifier corpus (12,469 sessions), live sessions, pinned saphyr/yaml@2
runs, setsid/WSL experiments, and green test baselines. Plan changes:

- Item 4 safety model redesigned (ledger A15/A16): --apply refuses while any
  amplifier process is visible; pre-rename re-read-compare; byte-fidelity
  verify (skipped-unfaithful); per-session guards kept as defense in depth.
- Item 3 (ledger A14): unconditional agent idle-reap exemption replaced by a
  24h hard cap - Running is not a loss-proof live-child signal and the sweep
  is the only cleanup for wedged rows.
- Item 2 (ledger A13): setsid verified against shell-death cascades; WSL2
  VM-teardown caveat documented; systemd unit promoted to recommended.
- Item 1 (ledger A5/A6/A9/A10): bare-stamp nuance (CLI normalizes to
  bundle:<name> on first save), loud exit-1 failure for unloadable bundles,
  multi-doc = Surprise in both resolvers, uniqueKeys:false in the TS twin,
  mirrored matrices extended; CLI ground-truth bullet added (resume default
  is 'anchors'; /home/dan/code/amplifier is not the CLI source).

Full ledger: .the-usual-logs/amplifier-integration-fixes/load-bearing-ledger.md
…te, correct reaper test counts

Fresh-eyes review found two blocking defects in the plan:

1. Task 9's applyBlockedByLiveAmplifier tested /amplifier/ against the
   whole ps snapshot, which always contains the backfill script's own
   process (the filename contains 'amplifier'), so --apply could never
   run. The gate now filters out ps lines mentioning the script filename
   (amplifier-backfill-bundle, present in every node/npx/tsx wrapper's
   argv) before matching; unit test gains self-exclusion + real-process
   assertions (same test count); header comment and Item 4 summary
   updated to match.

2. Task 7's red/green gates claimed 6 existing enforce_idle_kills_*
   tests; the crate has 9 (verified via cargo test -- --list). Red gate
   now expects 12 run / 10 pass / 2 fail, green gate expects all 12.
… shell death cannot cascade-kill agent terminals
… cap

Fresh-eyes review (iteration 1) found the ITEM-3 is_agent_mode closed
list omitted the gemini and kimi agent CLI modes, both shipped under
extensions/ (category "cli", picker group "agents"). A busy-but-quiet
gemini/kimi terminal was still reaped at the configured idle threshold
(default 15 min) — the exact kill-while-busy bug the hard cap fixes —
and neither mode has resumeArgs, so a reaped session was unrecoverable.

- registry.rs: add "gemini" | "kimi" to is_agent_mode; doc comment now
  states the membership rule (mirrors shipped agent-CLI extensions)
- registry.rs tests: the spares-agent-modes test now drives all 6 modes
  and asserts inventory len 6
- plan doc: correct the Task 7 mode inventory (the false premise that
  s.mode is only shell|claude|codex|opencode|amplifier) and its two
  code blocks

Verified: cargo fmt clean, clippy -D warnings clean,
cargo test -p freshell-terminal enforce_idle_kills => 12 passed.
…undle stamping, server detach, idle-reap cap, session backfill)

Generated with Amplifier

Co-Authored-By: Amplifier <[email protected]>
@danshapiro
danshapiro merged commit 098dc47 into main Aug 3, 2026
3 checks passed
@danshapiro
danshapiro deleted the land/amplifier-integration-fixes branch August 3, 2026 16:14
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