Skip to content

test(secondmate): trim redundant spawn ordering assertions - #56

Merged
kunchenguid merged 1 commit into
mainfrom
fm/sm-testtrim-t7
Jun 23, 2026
Merged

kunchenguid merged 1 commit into
mainfrom
fm/sm-testtrim-t7

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

Trim tests/fm-secondmate.test.sh to remove over-defensive/redundant test cases without losing any distinct behavior coverage. The suite grew during a defensive review-hardening pass. After a thorough audit (including the production code structure and two independent reviews), I found the suite is overwhelmingly load-bearing: the three scripts fm-home-seed.sh, fm-spawn.sh, fm-teardown.sh each INDEPENDENTLY re-implement their own home path-escape/symlink/nested-home validation (no shared library), so testing the same scenario through seed AND spawn AND teardown is legitimate separate coverage, not redundancy. I deliberately kept ALL security guards intact (symlink-escape, path-escape, nested/overlapping-home rejection, and the --force teardown safety tests). The ONLY genuine over-defensive redundancy I removed is in test_secondmate_spawn_requires_seeded_matching_home: it re-proved 'no tmux window was created before validation' for all 10 rejection reasons, but all spawn validation runs inside validate_firstmate_home_for_spawn which returns before the caller reaches 'tmux new-window' (verified at fm-spawn.sh line 292 vs 321), so a per-reason ordering regression is structurally impossible. I consolidated those 9 repeats to one canonical ordering proof (kept on the first sub-case, with an explanatory comment so the repeats are not re-added) plus removed 9 now-dead ': > $log' resets, while keeping every per-reason rejection-message assertion. I intentionally did NOT trim the one-per-function ordering checks in the teardown tests because those are self-contained per-scenario coverage, not intra-function repetition, and they sit in the protected categories. Net change is 4 insertions, 19 deletions in one file; no production scripts changed; all 54 test cases still pass. This is a test-suite-only cleanup.

What Changed

  • Removed repeated new-window ordering assertions from secondmate spawn rejection sub-cases, captain, keeping one canonical pre-validation side-effect check.
  • Added a short comment explaining why the remaining rejection cases assert only their specific refusal messages.
  • Left the per-reason rejection-message coverage intact in tests/fm-secondmate.test.sh.

Risk Assessment

✅ Low: Captain, risk is low because this is a narrow test-only cleanup that preserves the per-reason rejection assertions plus one fresh-log ordering check before launch.

Testing

Exercised the changed secondmate shell behavior suite and a focused end-to-end spawn-validation CLI transcript; no baseline run was provided, no UI surface was involved, and all verification completed without findings.

Evidence: fm-secondmate behavior test transcript
ok - FM_HOME parameterizes data and state paths
ok - fm-lock status is scoped per home
ok - secondmates registry records scopes and allows overlapping project clone lists
ok - home seeding records routing scope from filled charter briefs
ok - home seed validation rejects duplicate home routes
ok - home seed validation rejects duplicate id routes
ok - home seed validation rejects nested home routes
leased worktree for dash
ok - home seeding durably leases treehouse-acquired dash homes under the secondmate id
ok - home seeding returns rejected acquired homes through treehouse
ok - home seed rollback warns when treehouse-acquired return fails
ok - home seeding leaves unsafe acquired active homes untouched
ok - home seeding rolls back failed clone attempts without residue
ok - home seeding refuses direct seed without filled charter text
ok - home seeding refuses unfilled placeholder charters
ok - home seeding refuses empty normalized charter fields
ok - home seeding refuses local-only projects
ok - home seeding refuses registry delimiter home paths
ok - home seeding refuses active home and repo root
ok - home seeding refuses homes marked for another id
ok - home seeding refuses homes registered to another id
ok - home seeding refuses same-id reassignment to a different home
ok - home seeding refuses registered home overlaps
ok - remote-backed subhome seeding requires a source origin
ok - remote-backed subhome seeding validates existing destination origins
ok - home seeding resolves relative source origins against the source project
ok - home seeding skips initialized existing no-mistakes clones
ok - home seeding refuses uninitialized existing no-mistakes clones
ok - home seeding refuses project destinations outside the subhome
ok - home seeding refuses operational directories outside the subhome
ok - home seeding refuses symlinked leaf files
ok - kind=secondmate spawn launches in the home and records routing meta
ok - secondmate spawn validates homes before launch
ok - secondmate spawn refuses operational directories outside the subhome
ok - fm-send resolves bare firstmate windows through this home
ok - restart recovery can respawn a secondmate from durable registry and charter
ok - secondmate teardown retires empty homes and releases routing
ok - secondmate teardown refuses to hide failed leased-home return
ok - secondmate teardown raw-removes plain-clone homes
ok - secondmate force teardown discards child work
ok - force teardown allows operational directory symlinks inside the subhome
ok - force teardown refuses operational directory symlinks outside the subhome
ok - secondmate teardown requires seeded home marker
ok - secondmate teardown refuses homes containing registered nested homes
ok - secondmate teardown refuses nested homes from the child registry
ok - force teardown validates subhome before child cleanup
ok - force teardown refuses child worktrees inside the active home
ok - force teardown refuses child worktrees inside the firstmate repo
ok - force teardown refuses unregistered child worktree paths
ok - secondmate teardown refuses ancestor homes
ok - secondmate teardown refuses descendant homes
ok - idle kind=secondmate pane is healthy and not stale
ok - secondmate charter brief is idle by default and does not self-initiate work
ok - fm-backlog-handoff moves in-scope items, is idempotent, and aborts safely
ok - fm-backlog-handoff creates absent sections and refuses unsafe homes
Evidence: spawn validation CLI transcript

Focused CLI transcript covers 10 spawn rejection cases and ends with tmux new-window observed: no.

case: unseeded home
exit: 1
stderr: error: firstmate home /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T//fm-spawn-validation.Cqb1SO/unseeded-subhome is not a seeded secondmate home

case: marker belongs to another secondmate
exit: 1
stderr: error: firstmate home /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T//fm-spawn-validation.Cqb1SO/wrong-marker-home is marked for secondmate other, expected domain

case: missing AGENTS.md
exit: 1
stderr: error: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T//fm-spawn-validation.Cqb1SO/marker-only-home is not a firstmate home (missing AGENTS.md)

case: missing bin directory
exit: 1
stderr: error: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T//fm-spawn-validation.Cqb1SO/marker-only-home is not a firstmate home (missing bin/)

case: active home rejected
exit: 1
stderr: error: secondmate home cannot be the active firstmate home: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T//fm-spawn-validation.Cqb1SO/active-home

case: repo root rejected
exit: 1
stderr: error: secondmate home cannot be the firstmate repo: /Users/kunchen/.no-mistakes/worktrees/016d88035d58/01KVV2KCZHCT72JPJ4MDBS6M9X

case: inside active home rejected
exit: 1
stderr: error: secondmate home cannot be inside the active firstmate home: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T//fm-spawn-validation.Cqb1SO/active-home/data/spawn-descendant-home

case: ancestor of active home rejected
exit: 1
stderr: error: secondmate home cannot be an ancestor of the active firstmate home: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T//fm-spawn-validation.Cqb1SO/spawn-active-ancestor

case: inside firstmate repo rejected
exit: 1
stderr: error: secondmate home cannot be inside the firstmate repo: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T//fm-spawn-validation.Cqb1SO/spawn-validate-root/tmp/spawn-descendant-home

case: ancestor of firstmate repo rejected
exit: 1
stderr: error: secondmate home cannot be an ancestor of the firstmate repo: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T//fm-spawn-validation.Cqb1SO/spawn-root-ancestor

tmux new-window observed: no

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.

  • Inspected the target diff with git diff --find-renames 7651a3c08341e065d582881b2360d44f7f3abd41..1ea4359963876316e98fca0039e274803caedf97 -- tests/fm-secondmate.test.sh.
  • Verified the production ordering path with rg -n "validate_firstmate_home_for_spawn|new-window|secondmate home" bin/fm-spawn.sh and sed -n '250,340p' bin/fm-spawn.sh.
  • Ran tests/fm-secondmate.test.sh > /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KVV2KCZHCT72JPJ4MDBS6M9X/fm-secondmate-test-output.txt 2>&1.
  • Ran a focused inline bash CLI scenario that invoked bin/fm-spawn.sh domain <home> codex --secondmate against the seeded-home rejection cases and wrote /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KVV2KCZHCT72JPJ4MDBS6M9X/spawn-validation-cli-transcript.txt.
  • Checked cleanup with git status --short; the working tree remained clean.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

The spawn home-validation test re-proved "no tmux window created before
validation" for all 10 rejection reasons. All spawn validation runs inside
validate_firstmate_home_for_spawn, which returns before the caller reaches
tmux new-window, so a per-reason ordering regression cannot occur. The
repeats tested a structurally impossible condition.

Keep one canonical ordering proof (with a comment so the repeats are not
re-added) and let each rejection assert only its own refusal message. Every
distinct rejection guard, and every security guard (symlink, path-escape,
nested/overlapping home, force-teardown safety), is unchanged. All 54 cases
still pass.
@kunchenguid
kunchenguid merged commit a082fca into main Jun 23, 2026
4 checks passed
@kunchenguid
kunchenguid deleted the fm/sm-testtrim-t7 branch June 23, 2026 20:43
pranaypratyush pushed a commit to pranaypratyush/firstmate that referenced this pull request Aug 25, 2026
…enguid#56)

* fix(hermes): reap persistent TUI process tree

Bind each Firstmate Hermes launch to its lifecycle token and require the matching metadata, state, and registry proof before teardown signals the marked roots and descendants.

Harden live E2E cleanup and record tmux and isolated Herdr verification that task-owned processes are removed without touching personal Hermes sessions.

* no-mistakes(review): fix(hermes): track reap set across KILL and allow legacy teardown

* no-mistakes(review): fix(hermes): legacy fallback, defunct survivors, lsof-absent group reap

* no-mistakes(review): fix(hermes): jq-optional ownership proof, forkless marker scan, live active teardown

* no-mistakes(review): perf(hermes): bounded ps marker scan, token-root closure scope

* no-mistakes(review): fix(hermes): portable process-environment ownership scan

* no-mistakes(review): fix(hermes): try every environment ps form, propagate scan failures

* no-mistakes(review): fix(hermes): drop defunct pids, pane-seeded live capture

* no-mistakes(review): fix(hermes): refuse unprovable identities, drop live settle retry

* no-mistakes(review): docs(hermes): record final-head live teardown verification

* no-mistakes(review): fix(hermes): fail closed on unreadable procfs, document refusal recovery

* no-mistakes(review): fix(hermes): live marker scan falls through unreadable procfs

* no-mistakes(review): docs(hermes): final-head evidence, clarify missing-vs-inconsistent proof

* no-mistakes(document): docs(hermes): correct post-probe commit scope in verification record

* no-mistakes: apply CI fixes
NewAiCoder added a commit to NewAiCoder/firstmate that referenced this pull request Sep 26, 2026
… kills it silently (kunchenguid#56)

* fix(bin): close the Claude Stop auto-arm park before the hook timeout

Claude registers the Stop auto-arm with "timeout": 28800 and TERMs the whole
hook process tree at that timeout without delivering any rewake. On a quiet
fleet every no-change heartbeat is absorbed, so one watcher park can outlive
the timeout; the watcher then dies with the hook, the claim stays frozen at
arming, and nothing re-arms until someone types into the session.

- The hook runs the arm as a tracked child and starts a park-boundary timer
  (a relative sleep, immune to wall-clock steps). At fm_claude_park_seconds
  (default 27000, always below 28800) it TERMs the arm, stops this home's
  watcher through the new fm-watch-arm.sh --stop, and closes the park as an
  ordinary exit-2 rewake, so the handling turn's Stop starts a fresh park.
- An arming claim older than the park boundary is no longer open, so a Stop
  that lands just before an old park is killed supersedes it instead of
  deferring to it.
- fm-watch-arm.sh --restart and --stop share one home-scoped stop.
- Tests: a quiet park closes at the boundary with one rewake, an expired
  claim is superseded, the boundary stays below the hook timeout, and --stop
  ends a real watcher with downtime published and no re-arm.

* no-mistakes(document): docs: describe the Claude Stop park boundary, drop stale foreground/claim-open prose

---------

Co-authored-by: NewAiCoder <claude@theinbtw.com>
@apipoj

apipoj commented Oct 15, 2026

Copy link
Copy Markdown

Measured on CI (final — 3 runs on this PR)

run job wall billed emulator phase notes
baseline 38653252101 (sequential, main era) 21 m 05 s ~22 min 1378.9 s same-era run 38654885766 was cancelled at the 30-min limit
#1 4 workers, cold cache 24 m 30 s 25 886.7 s 8 m 21 s = one-time image build; GHA cache saved
#2 GOMAXPROCS=1 probe, warm 18 m 09 s 19 990.3 s probe reverted (within run-to-run noise, slightly worse)
#3 ship config (2c95602), warm 18 m 33 s 19 1017.3 s code byte-identical to #1 — the 886.7↔1017.3 spread (~15%) is runner noise

Steady state: ~19 billed minutes vs ~22 baseline, image build 8 m 21 s → 19–22 s on every future PR, and 11+ minutes of margin under the 30-minute timeout (the old gate was cancelled at the cliff).

Why not 4–6 minutes: shared 4-vCPU runner; per-case latency roughly triples at 4-way concurrency (5.3 s → ~14 s), capping throughput gains at ~1.5–1.8×, with the heavy oracle tail degrading further. Breaking that cap means reusing pytest processes/containers — exactly what the per-case isolation guarantee (#49) forbids. Run-to-run noise (±15%) also puts finer tuning (3 vs 4 workers, GOMAXPROCS pins) below the measurement floor; probing costs ~19 billed minutes per data point.

Everything else in the description stands: isolation unchanged (fresh container + dataset per case), same pass/fail semantics, worker sizing 4 × ~2.3 GB ≈ 11 GB inside 16 GB, timeout-minutes untouched.

Frontend-only skip evidence: the pull_request: branches: [main] trigger means the evidence run needs a frontend-only PR against main on the merged ci.yml. PR 57 (README-only) is prepared for that: retarget it to main at merge time and its run will show the gate job green in under a minute with setup/build/test skipped. Skip/run logic verified locally for all cases (frontend-only → skip; backend/scripts/tests/deploy/requirements/workflows → run; empty or failed file list → run/fail-open).

@dhulsmaninfodatek

Copy link
Copy Markdown

Pushmeldingen op Android werken op staging.

Met de APK met Firebase op een emulator, ingelogd als testaccount: na de eerste vraag vraagt de app om toestemming, en met de app op de achtergrond komt binnen een halve minuut "Managed Cowork / Your answer is ready". Tikken opent de chat met het antwoord.

Productie heeft de sleutel ook al. Daar gaat het aan met de uitrol van https://github.com/RentMagic/infodatek.managed-cowork/pull/765, die de mount meebrengt. iPhone wacht nog op de APNs-sleutel.

fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 2, 2026
…unchenguid#56)

* fix(continuity): allow fm-session-start.sh in the watcher-continuity gate

fm-session-start.sh acquires the home lock first and drains the wake
queue itself, making it a recovery command, but the continuity gate's
recovery set omitted it, so every fresh session hit a deny on the exact
command AGENTS.md mandates be run first.

* no-mistakes(review): clarify continuity deny guidance and bootstrap allow boundary

* no-mistakes(review): use verifiable session-start precondition in continuity deny guidance

* no-mistakes(review): document session-start allowance limitation and fix guidance drift

* no-mistakes(review): describe visible-status projection as a write, not a read

* no-mistakes(document): add session-start allowance to stale continuity-gate doc copies

* docs(continuity): correct known-limitation feasibility claim

The gate does not currently distinguish a fresh pre-lock session from
a mid-session re-run, but that is a scope deferral, not an inherent
limitation: fm-sessionstart-nudge.sh's lock_is_in_ancestry() already
does the equivalent same-process distinction, so point at it as the
feasible reference for follow-up work instead of overclaiming the
gate cannot do this.

* no-mistakes(document): fix over-broad model_live claim in continuity known limitation

* no-mistakes(review): scope continuity deny guidance by shared session-lock ancestry
@drkarl drkarl mentioned this pull request Nov 2, 2026
fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 18, 2026
…chenguid#56)

* feat(bin): tell a Mothership room card how the work taken on for it goes

A backlog task filed for a room request the owner took on carries a
`mothership: <room>/<card>` ref in its body, which the accepted line now
names. Its card then hears one short line at each lifecycle step: progress
when the work is dispatched, progress with the PR address when its PR is
recorded, a problem for each new blocker in its status log, and a result
when it lands, which settles the ship's part of the card. Each line runs
through the room's allow-list under the task's project and through the
link's private word check, with a client id fixed per task and event. A
send the link refuses or cannot make wakes the first mate and never holds
up the step that asked for it; a task with no ref sends nothing.

* no-mistakes(review): Read quoted card refs; blocked-scan never waits on task locks

* no-mistakes(test): Wait for task lock before blocked-scan cleanup check

* no-mistakes(document): Name the card ref in tap-desk accepted-work filing

* fix(fork-surface): claim the room-card report suite under mothership-monitor
fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 18, 2026
Brings in the Mothership room-card reports (kunchenguid#56) and the one-at-a-time
Factory pane rebuild (kunchenguid#57), so the fresh pipeline run starts on top of
current main and keeps the upstream merge commit.
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.

3 participants