agent harness: sim shellHook fix, sim-probe/flag-where/arm-history, AGENT-ONBOARDING #204

Merged
tenstorrent merged 4 commits from agent-harness into master 2026-10-09 11:00:33 +02:00
Owner

New agents (Muse via opencode, and our own subagents) lost turns on sim-env noise and silent slot waits. verify-3 also counted 12 WRONG review findings. Most missed a guard, reset, record or deliberate arm deletion that existed elsewhere. The rest held draft-depth levers to the per-step bar and the accept guard. This PR is docs and tooling only: no arm, patch or kernel changes, so it does not trigger the cards job.

Root cause fixed (nix/sim/flake.nix shellHook). The hook ran python3 while a desktop LD_LIBRARY_PATH leaked expat 2.7.1. That printed the pyexpat ImportError, left TT_METAL_HOME empty and printed "ttnn: NOT importable", although the env was fine. scripts/sim-run.sh:45 only unsets the variable later. The hook now unsets it first. The OK line now comes from the hook's own discovery, because a second import in the hook fails on EROFS (tracy mkdir), which sim-run.sh's overlay already handles. Verified with nix develop ./nix/sim#runtime --command bash -c 'echo $TT_METAL_HOME': the path is set and there is no ImportError.

New scripts (shellcheck clean; CI already lints scripts/*.sh):

  • scripts/sim-probe.sh <probe.py> [args] [--out X]
    • Runs ttsim-slot (or runs directly with a warning when there is none), then nix sim, then sim-run.sh.
    • Prints timestamped waiting for ttsim slot / running / done rc=N lines, plus the probe's result lines.
    • Keeps temp files and the log in $TMPDIR (when it is not under /tmp) or in the gitignored .tmp/sim-probe/.
    • An interrupt kills the whole process group.
    • Tested: sim_kv_update_fold.py --Ts 1 --Bs 1 --only edge_T1_B1 gave all_ok in 34 s. A fake busy slot printed the waiting heartbeat, and the no-wrapper fallback warned.
  • scripts/flag-where.sh [--prefix] FLAG: definitions, uses of the bound constant (that is where the guards live), arm settings, switchclass class, LEVERS lines and LEDGER lines with their entry ID. No .pyc noise.
  • scripts/arm-history.sh <fragment>: git log --all --diff-filter=ADR over the matching arms, then the bench/runs records, then PRs whose title or body mentions the fragment. It reproduces #194's odoc case: added in ea95224f, deleted in b91ba951.

docs/AGENT-ONBOARDING.md (161 lines, commands and facts):

  • where CONTROL is defined;
  • the scripts above;
  • the probe contract (template, load-bearing parts, record schema, INDEX regeneration);
  • the served-shape caps, each verified in code;
  • the 1x2 hang/corrupt prohibitions;
  • the arm lifecycle;
  • master's judging rules, with the b8k3 records re-scored by master's picker. -dx-b8k3: +2.02% per token, -2.85% per step, B8 -8.77/-8.51%, accept -5.66%. Shipped -b8k3-cph48: +2.25%, -2.92%, B8 -9.39/-8.29%, accept -5.24%. #203 is noted as open;
  • JIT triage signatures;
  • the reviewer rule set;
  • the builder rule (a signed estimate, and negative results are welcome).

AGENTS.md gains one pointer line. LEDGER.md gains a 9-line "Current state" box: CONTROL, the last 3 ships, the last 3 kills or parks, and the open PRs. It is refreshed at each ship.

Checks: nixfmt --check on the CI file set passes. shellcheck on the CI script set passes. check-cited-records.py OK. The ttx lint and dead-lever unit tests pass (ttx itself is untouched).

Follow-ups (out of scope):

  • Stable lever IDs (L-xxxx) in LEVERS.md, with lint and citation support. Row-number citations break on every edit.
  • A generated docs/FLAG-INDEX.md.
  • A shared bench/probes/sim_common.py.
  • Restructuring STATUS.md (its line 3 says "never append", but most of the file is an append-only log).

🤖 Generated with Claude Code

New agents (Muse via opencode, and our own subagents) lost turns on sim-env noise and silent slot waits. verify-3 also counted 12 WRONG review findings. Most missed a guard, reset, record or deliberate arm deletion that existed elsewhere. The rest held draft-depth levers to the per-step bar and the accept guard. This PR is docs and tooling only: no arm, patch or kernel changes, so it does not trigger the cards job. **Root cause fixed (nix/sim/flake.nix shellHook).** The hook ran python3 while a desktop `LD_LIBRARY_PATH` leaked expat 2.7.1. That printed the pyexpat ImportError, left `TT_METAL_HOME` empty and printed "ttnn: NOT importable", although the env was fine. `scripts/sim-run.sh:45` only unsets the variable later. The hook now unsets it first. The OK line now comes from the hook's own discovery, because a second import in the hook fails on EROFS (tracy mkdir), which sim-run.sh's overlay already handles. Verified with `nix develop ./nix/sim#runtime --command bash -c 'echo $TT_METAL_HOME'`: the path is set and there is no ImportError. **New scripts** (shellcheck clean; CI already lints `scripts/*.sh`): - `scripts/sim-probe.sh <probe.py> [args] [--out X]` - Runs ttsim-slot (or runs directly with a warning when there is none), then nix sim, then sim-run.sh. - Prints timestamped `waiting for ttsim slot` / `running` / `done rc=N` lines, plus the probe's result lines. - Keeps temp files and the log in `$TMPDIR` (when it is not under /tmp) or in the gitignored `.tmp/sim-probe/`. - An interrupt kills the whole process group. - Tested: `sim_kv_update_fold.py --Ts 1 --Bs 1 --only edge_T1_B1` gave all_ok in 34 s. A fake busy slot printed the waiting heartbeat, and the no-wrapper fallback warned. - `scripts/flag-where.sh [--prefix] FLAG`: definitions, uses of the bound constant (that is where the guards live), arm settings, switchclass class, LEVERS lines and LEDGER lines with their entry ID. No `.pyc` noise. - `scripts/arm-history.sh <fragment>`: `git log --all --diff-filter=ADR` over the matching arms, then the bench/runs records, then PRs whose title or body mentions the fragment. It reproduces #194's odoc case: added in ea95224f, deleted in b91ba951. **docs/AGENT-ONBOARDING.md** (161 lines, commands and facts): - where CONTROL is defined; - the scripts above; - the probe contract (template, load-bearing parts, record schema, INDEX regeneration); - the served-shape caps, each verified in code; - the 1x2 hang/corrupt prohibitions; - the arm lifecycle; - master's judging rules, with the b8k3 records re-scored by master's picker. `-dx-b8k3`: +2.02% per token, -2.85% per step, B8 -8.77/-8.51%, accept -5.66%. Shipped `-b8k3-cph48`: +2.25%, -2.92%, B8 -9.39/-8.29%, accept -5.24%. #203 is noted as open; - JIT triage signatures; - the reviewer rule set; - the builder rule (a signed estimate, and negative results are welcome). **AGENTS.md** gains one pointer line. **LEDGER.md** gains a 9-line "Current state" box: CONTROL, the last 3 ships, the last 3 kills or parks, and the open PRs. It is refreshed at each ship. **Checks:** nixfmt --check on the CI file set passes. shellcheck on the CI script set passes. `check-cited-records.py` OK. The ttx lint and dead-lever unit tests pass (ttx itself is untouched). **Follow-ups (out of scope):** - Stable lever IDs (`L-xxxx`) in LEVERS.md, with lint and citation support. Row-number citations break on every edit. - A generated `docs/FLAG-INDEX.md`. - A shared `bench/probes/sim_common.py`. - Restructuring STATUS.md (its line 3 says "never append", but most of the file is an append-only log). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
agent harness: fix the sim shellHook, add sim-probe/flag-where/arm-history, onboarding page
Some checks failed
tt-stack-ci / Build simulators and check the host module (pull_request) Successful in 2m9s
tt-stack-ci / Report upstream drift (pull_request) Successful in 47s
tt-stack-ci / Serialized card gate (pull_request) Has been cancelled
4e577b1578
Before: every `nix develop ./nix/sim#runtime` printed a pyexpat ImportError, "ttnn: NOT
importable" and an empty TT_METAL_HOME. Agents read that as a broken env and lost turns on
it. consult-1 blamed a sim-run.sh probe. The real cause is the shellHook: it runs python3
while a desktop LD_LIBRARY_PATH leaks expat 2.7.1, and sim-run.sh only unsets that later.
The hook now unsets it first, and judges importability by its own discovery: a second
import fails on EROFS, which sim-run.sh's overlay handles. Verified: TT_METAL_HOME is set
and the noise is gone.

verify-3 found 12 WRONG review findings. Most missed a guard, reset, record or deliberate
arm deletion that existed elsewhere. The rest held draft-depth levers to the per-step bar
and the accept guard. New:
- scripts/sim-probe.sh: ttsim slot + nix sim + sim-run, with timestamped heartbeat lines
  (the slot used to wait silently), temp files out of /tmp and a process-group interrupt.
  Tested on sim_kv_update_fold.py edge_T1_B1: all_ok, 34 s.
- scripts/flag-where.sh: definitions, constant uses, arms, switchclass, LEVERS and LEDGER
  for one flag, with no .pyc noise.
- scripts/arm-history.sh: arm adds/deletes on every ref, records and PRs (reproduces the
  #194 odoc case: ea95224f add, b91ba951 delete).
- docs/AGENT-ONBOARDING.md: probe contract, served-shape caps, 1x2 prohibitions, arm
  lifecycle, judging rules with the b8k3 numbers re-scored by master's picker, JIT
  triage, reviewer and builder rules.
- AGENTS.md: a single pointer line. LEDGER.md: a "Current state" box, refreshed at each ship.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner

verdict: approve
tier: T1 — host-local docs + shell scripts + one nix shellHook change; no arm, patch, kernel, or CI-gate edits. Docs/tooling only, does not trigger the cards job.

rationale: Verified black-box against the description and the diff. Diff direction is correct (merge-base = master e59447c, head = 4e577b1 on agent-harness). No secrets, no code-exec / injection / shell-interpolation patterns in any new file. The shellHook fix is correct: unset LD_LIBRARY_PATH now runs before the ttnn discovery so the pyexpat ImportError goes away, and the OK line is keyed off the discovery result rather than a second import ttnn that would fail on EROFS (handled later by sim-run.sh's overlay). Three new scripts pass bash -n. CI run #7320 is waiting on the approval gate; head is not behind master.

**verdict:** approve **tier:** T1 — host-local docs + shell scripts + one nix shellHook change; no arm, patch, kernel, or CI-gate edits. Docs/tooling only, does not trigger the cards job. **rationale:** Verified black-box against the description and the diff. Diff direction is correct (merge-base = master e59447c, head = 4e577b1 on agent-harness). No secrets, no code-exec / injection / shell-interpolation patterns in any new file. The shellHook fix is correct: `unset LD_LIBRARY_PATH` now runs before the ttnn discovery so the pyexpat ImportError goes away, and the OK line is keyed off the discovery result rather than a second `import ttnn` that would fail on EROFS (handled later by sim-run.sh's overlay). Three new scripts pass `bash -n`. CI run #7320 is waiting on the approval gate; head is not behind master.
agent harness: apply r2 validation fixes (slot wrapper path, picker on master, --out append)
Some checks failed
tt-stack-ci / Report upstream drift (pull_request) Successful in 1m18s
tt-stack-ci / Build simulators and check the host module (pull_request) Successful in 2m35s
tt-stack-ci / Serialized card gate (pull_request) Has been cancelled
d68695fbb3
The r2 validator found the onboarding assumed a /tmp slot wrapper (now a symlink to the durable
/home/orchestra/bin/ttsim-slot), claimed "slot acquired" on hosts with no wrapper, quoted a 34 s
smoke that is ~3 min cold, called #203 open after it merged, and left arm-history's records
search blind to deleted arms' records on other refs.

- sim-probe.sh: wrapper lookup $TTSIM_SLOT -> /home/orchestra/bin -> /tmp symlink; no wrapper
  prints "running (no slot wrapper; unthrottled)".
- arm-history.sh: records added on any ref (git log --all --diff-filter=A -- bench/runs/).
- onboarding: smoke timing, master picker classes (735f4dc8), --out appends, w2 is never an MMRS
  site, build flock, merge-base check against origin/master.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Merge branch 'master' into agent-harness
All checks were successful
tt-stack-ci / Build simulators and check the host module (pull_request) Successful in 3m11s
tt-stack-ci / Report upstream drift (pull_request) Successful in 54s
tt-stack-ci / Serialized card gate (pull_request) Successful in 44s
91ce5f02f4
Member

Cards skipped

PR #204 91ce5f02f4431316255d5d0b0eaf05f307cc8257 (refs/pull/204/head) does not touch card-facing paths (bench/arms/, patches/, kernel/op sources, or .forgejo/workflows/). No card boot. Build out: /nix/store/hbb3j0xxx0pqf760i3p54q54gzgmzpc9-vm-test-run-tenstorrent-serving.

## Cards skipped PR #204 `91ce5f02f4431316255d5d0b0eaf05f307cc8257` (`refs/pull/204/head`) does not touch card-facing paths (`bench/arms/`, `patches/`, kernel/op sources, or `.forgejo/workflows/`). No card boot. Build out: `/nix/store/hbb3j0xxx0pqf760i3p54q54gzgmzpc9-vm-test-run-tenstorrent-serving`.
Author
Owner

agent-gateway closeout (merged): cleared agent:* labels.
Hermes kanban card (if any) is left for Hermes to archive/complete.

agent-gateway closeout (merged): cleared `agent:*` labels. Hermes kanban card (if any) is left for Hermes to archive/complete.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitpartner/tt-stack!204
No description provided.