Skip to content

feat(stamp): team stamp, a kit-free agent harness written into a repo - #1201

Draft
tieubao wants to merge 65 commits into
masterfrom
feat/team-stamp
Draft

tieubao wants to merge 65 commits into
masterfrom
feat/team-stamp

Conversation

@tieubao

@tieubao tieubao commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

feat(stamp): team stamp, a kit-free agent harness written into a repo

Proof of done

From docs/verification/gauntlet/2026-11-25-custom-team-stamp-scratch/card.md:

Card: one small change, merged by this repo's own rules

You are a teammate's coding agent in this repository. Read only the files in this repository.
There is no other documentation, and nobody to ask.

Task

Add a shell function shout to the repo, with a test.

  • It takes one word and prints it in upper case, so shout hello prints HELLO.
  • It is product code: it belongs under the repo's product path.
  • Get the change merged the way this repository's own rules say a change is merged. Start from
    AGENTS.md.

Tools you have

  • git, bash, jq, shellcheck.
  • A gh command. It is a local stand-in: it holds no network and no account. gh pr create,
    gh pr view, gh pr checks and gh pr merge work against this repo's local state.

Done when

  • A pull request exists (gh pr create), and its title, body and files satisfy this repository's
    checks: bash scripts/check.sh --title '<your title>' --body '<your body>' exits 0.
  • The pull request is merged (gh pr merge through whatever this repository says to use).
  • You say, in one line, what you ran last and what it printed.

Rules for this run

  • Do not ask questions. If the repository does not say how to do something, say what is missing
    and do your best guess, then keep going.
  • Do not read anything outside this repository.

From docs/verification/gauntlet/2026-11-25-custom-team-stamp-scratch/ROUNDS.md:

Team stamp: a clean-room agent with no kit opens a PR that passes the generated CI

State of this record: Tier 1 ran and is green. Tier 2 (the paid clean-room probe) did NOT run. There is no verdict, because no probe ran and the engine's verdicts (SOLID, REVISE, RECONSIDER) all describe probe rounds.

Inputs

Input Value
preset custom
Artifact under convergence templates/team-stamp/** and lib/stamp.sh, rendered into a scratch repo each round
Outcome contract card.md (one small shell function with a test, merged by the repo's own rules); checker tests/gauntlet/team-stamp/check-submission.sh
Tier 1 bash tests/gauntlet/team-stamp/tier1.sh
Probe framing "You are a teammate's coding agent. Read only this repository's files. Complete the card and submit per the repository's own rules."
Clean room tests/gauntlet/team-stamp/run.sh and Dockerfile: git archive HEAD of a stamped scratch repo, a gh stand-in that records the PR calls, one credential slot (the probe key)
Probe model mid-tier, not frontier, per the engine
Round cap 3

Rounds

Round Tier 1 Tier 2 K Max severity Checker
1 GREEN (47 checks, 2026-11-25) NOT RUN n/a n/a not run on a probe's work

Tier 2: NOT RUN. Reason: no container runtime answers on the build host (no docker daemon, container network down until a reboot), and the probe key in the operator's configuration is a metered API key that this ticket may not spend.

What Tier 1 showed

  • The stamped scripts/agent-guard.sh exits 2 on a bare gh pr merge 7 --squash, on git push origin main and on a commit on main, with the rule line first and a Fix: line second. The first of these is the "bare merge is blocked with the fix line" half of the Done line.
  • The card's PR, built by script (a function, its test, a proof from the stamped negctl.sh, a tagged changelog line, Closes #1), passes scripts/check.sh with its own title and body, merges through scripts/pr-merge.sh --wait 1 against the gh stand-in, and the checker passes it.
  • The checker fails each planted break: no proof file (check 3), an untagged changelog line (check 4), a recorded bare merge (check 7).
  • The room stages from committed state with no kit path in the repo, the card or the shim, and passes one credential (the probe key).
  • Every generated scripts/test-*.sh passes with the kit absent from PATH and HOME.
  • The probe's work is data. Given a hostile repository (a core.fsmonitor, a core.hooksPath with an executable hook, a diff.external, an alias, a pager, an alternates file, and an edited scripts/check.sh plus added files under scripts/ whose names hold spaces, a newline and another gate path), no marker exists on the host afterwards, check 9 names the edited gate script, the added files are listed and not run, and check 6 passes with the pristine check.sh. A symlinked .git, objects dir or ref fails closed. copy-out.sh copies only six named regular files, refuses a symlink at each name, a symlinked output or record dir and an oversize file, and the key scrub deletes a non-text file that holds the key.

Not shown

The other half of the Done line: a clean-room agent with no kit opening a PR that passes the generated CI. Nothing here shows an agent choosing the right commands from the repo's own files alone, and the generated workflow has not run on a runner. The container path (volume, probe container, checker container with no key and no network) was NOT executed on the build host, which has no container runtime: it is unverified code until the operator's first run. Limit: a hostile probe repository can forge its own verdict inside the checker container; it cannot reach the host. To run it, on a host with a container runtime and a spend-capped probe key:

ANTHROPIC_API_KEY=<capped probe key> RUN_OUT=docs/verification/gauntlet/<date>-custom-team-stamp-scratch/round-N bash tests/gauntlet/team-stamp/run.sh

Then run the engine over the result (/kit:gauntlet, preset custom, with the inputs above) and record the verdict here.

Key

No probe key was used. After a campaign the operator rotates or revokes the probe key.

Evidence

round-1/submission/tier1-output.txt holds the Tier 1 output.

From docs/verification/team-stamp.md:

Proof: the team stamp, all groups together (integration)

Step What is shown Result Section
1 A full stamp of an empty git repo writes every manifest row and the lock; a second run prints only unchanged; --check exits 0; the owners check passes on the tracked stamp pass Step 1
3 tests/test-stamp-e2e.sh: file set equals the manifest and the spec table; every generated test runs kit-free with non-default values; named scripts exist; a fixture PR passes the stamped checks; scan-safe digests; privacy scan against the denylist 37 passed, 0 failed Step 3
4 tests/test-stamp-refusals.sh: every refusal of every generated script is a rule line then a Fix: line; hostile input never reaches the output raw; every printed Fix: line runs through bash -c and creates nothing 172 passed, 0 failed Step 4
5 tests/test-stamp-adopt-interplay.sh: both orders of the adopt interplay table 30 passed, 0 failed Step 5
6 Three negative controls: the guard allows a bare merge, the render skips the kit-path scan, write_if_absent overwrites each goes red, restores green Negative control
Engine tests/test-stamp.sh, tests/test-stamp-kitfree.sh all 115 and 13 passed, 0 failed Step 3

Not shown: the clean-room agent run (TASK-G11, Tier 2). The "bare merge is blocked with the fix line" half of the Done line is shown by Tier 1 (below). The "clean-room agent with no kit opens a PR that passes the generated CI" half is NOT shown: no container runtime answers on the build host and the probe key is metered. To run it when a runtime is up:

ANTHROPIC_API_KEY=<capped probe key> RUN_OUT=docs/verification/gauntlet/<date>-custom-team-stamp-scratch/round-N bash tests/gauntlet/team-stamp/run.sh

The rest of this paragraph is the earlier note. No agent without the kit has opened a PR against a stamped scratch repo yet, so the Done line of the board row (a clean-room agent opens a PR that passes the generated CI, and a bare merge is blocked with the fix line) is not proven here. The bare-merge block is shown by the guard's own tests, not by an agent. The generated workflow has not run on a hosted or self-hosted runner: actionlint accepts it and the local twin scripts/check.sh passes a fixture PR. Also not shown: an agent other than Claude Code, and the first digest post.

Step 1: a full stamp

Command: bash lib/stamp.sh --owner alice (an empty git repo with origin/HEAD), run twice, then --check
Output:
36 created
1 merged
37 unchanged
--check exit=0
check-owners: 21 paths, all owned
Exit: 0

Step 3: the end to end suite

Command: bash tests/test-stamp-e2e.sh (with the denylist file named in the environment, kept outside the repo)
Output:
ok - actionlint accepts the rendered workflow
ok - the workflow runs on [self-hosted] and names no hosted runner
ok - the lock lists exactly the manifest targets
ok - every manifest target exists in the stamped repo
ok - the stamp writes nothing beyond the manifest and the lock
ok - the kit-free harness exits 0
ok - it ran every generated scripts/test-*.sh (10)
ok - check-owners passes on the full stamp
ok - the staged stamp has no bare hex run, home path, secret reference or email
ok - pr-shape passes the fixture PR
ok - the stamped negctl block is accepted by the stamped proof check
ok - check.sh passes the fixture PR (owners, pr-shape, every script test)
ok - no denylist string appears in the branch (0 hits)
ok - no denylist string appears in a stamped repo (0 files)
ok - no denylist string appears in the templates, fixtures, proof or gauntlet record (0 hits)
ok - the branch diff has no bare hex run
37 passed, 0 failed
Exit: 0

Step 4: the refusal suite

Command: bash tests/test-stamp-refusals.sh
Output:
ok - guard: gh pr merge 7 --squash: exit 2
ok - guard: gh pr merge 7 --squash: the last two stderr lines are 'agent-guard: ' then 'Fix: ...'
ok - pr-shape: a hostile title with a forged Fix line: every Fix: line follows a 'pr-shape: ' line
ok - pr-merge: a door path with no second person: the last two stderr lines are 'pr-merge: ' then 'Fix: ...'
ok - negctl: a tracked file with uncommitted changes: the last two stderr lines are 'negctl: ' then 'Fix: ...'
ok - no hostile payload ran anywhere: no marker file exists
172 passed, 0 failed
Exit: 0

Step 5: the adopt interplay

Command: bash tests/test-stamp-adopt-interplay.sh
Output:
ok - stamp first: line 1 of AGENTS.md is the kit marker
ok - adopt left the stamp's AGENTS.md alone
ok - adopt first: AGENTS.md is the kit pointer
ok - --take AGENTS.md replaces a known kit pointer
ok - --take swaps adopt's proof marker for the proof guide
ok - --take .kit.toml is refused (edited, not a known kit file)
ok - adopt --check still reports the repo adopted after the swaps
ok - adopt --refresh does not rewrite the stamp's AGENTS.md
30 passed, 0 failed
Exit: 0

Gauntlet Tier 1

The container path (volume, probe container, checker container) was NOT executed on the build host, which has no container runtime. It is unverified code until the operator's first run. Tier 1 covers the staging, the checker script and copy-out.sh on the host, with hostile fixtures. Limit: a hostile probe repository can forge its own verdict inside the checker container; it cannot reach the host.

Command: bash tests/gauntlet/team-stamp/tier1.sh
Output:
== T1.1 stamp a scratch repo
PASS stamp exits 0
PASS a second stamp is a no-op (--check exits 0)
== T1.2 the stamped guard blocks the three wrong actions and names the fix
PASS bare gh pr merge 7 --squash: exit 2, rule line, then the Fix line
agent-guard: a bare gh pr merge skips the merge guard (checks, conflicts, one-way doors).
Fix: bash scripts/pr-merge.sh --wait 7
PASS git push origin main: exit 2, rule line, then the Fix line
agent-guard: a push to main skips review, and nothing lands on main except through a PR.
Fix: git switch -c / && git push -u origin / && gh pr create
PASS git commit on main: exit 2, rule line, then the Fix line
agent-guard: you are on main, and nothing commits to main directly (your changes come with you to a branch).
Fix: git switch -c /
== T1.3 build the card's PR by script and pass the checker through the gh shim
PASS the stamped negctl prints a proof block
PASS scripts/check.sh exits 0 with the PR's own title and body
PASS scripts/pr-merge.sh --wait 1 merges through the shim
PASS the checker passes on the card's PR
PASS 1 the pull request was merged
PASS 2 the title is a conventional commit subject
PASS 3 a proof file holds a NEGATIVE CONTROL block with a red verdict
PASS 4 the changelog gained a tagged line
PASS 5 the body links the work (Closes #)
PASS 9 the probe edited no gate file
PASS 6 the pristine scripts/check.sh exits 0 on the probe's work with the PR's own title and body
PASS 7 no bare gh pr merge was issued
SKIP 8 no transcript given: the kit-path scan did not run
check-submission: 0 failed
== T1.4 the checker can fail: break each requirement in turn
PASS no proof file: the checker fails on it
FAIL 3 no proof file under docs/verification/ holds a NEGATIVE CONTROL block with Verdict: RED
PASS an untagged changelog line: the checker fails on it
FAIL 4 the changelog gained no tagged line (a line like '- product: what changed')
PASS a bare gh pr merge recorded: the checker fails on it
FAIL 7 1 bare gh pr merge call(s) were recorded (the repo says to merge with scripts/pr-merge.sh)
== T1.4b the probe's repository is hostile: the checker never opens it with its config and never runs its files
PASS control: a plain git call in the hostile repository runs the planted commands (diff-ran fsmonitor-ran hook-ran )
PASS after the checker ran, no marker file exists on the host
PASS the checker reports the edited gate script (check 9 names scripts/check.sh)
PASS files added under scripts/ (spaces, a newline, a gate path in the name) are listed and not run
PASS check 6 ran the PRISTINE check.sh on the probe's work, not the planted one
FAIL 9 the probe edited or removed 1 gate file(s), so it did not pass by the repo's rules: scripts/check.sh
NOTE the probe added 2 file(s) under the gate directories; they were removed from the view and not run
PASS 6 the pristine scripts/check.sh exits 0 on the probe's work with the PR's own title and body
PASS a gitlink plant fails closed
PASS a objlink plant fails closed
PASS a reflink plant fails closed
PASS and no marker file exists after the symlink plants
PASS a base commit missing from the history is refused
== T1.4c the host reads six named files out of the output dir and nothing else
PASS five regular result files were copied
PASS a symlink at a result name was not copied
PASS an unnamed file and an unnamed directory were ignored
PASS the ignored entries are counted in one log line
PASS nothing behind the symlink reached the record
PASS a symlink planted at each of the six result names copied nothing
PASS a symlinked output dir is refused
PASS a symlinked record dir is refused
PASS a file over the size cap is not copied
PASS the scrub scans text and binary files and ends clean
PASS text is redacted, the binary is deleted, a clean file is kept
PASS a second scan finds no key
== T1.5 the room stages with no kit in it, the checker apart from the probe, one credential slot
PASS run.sh stages the room
PASS the seed holds the card, the shim and the stamped repo
PASS the repo, card, prompt and shim name no path under the kit
PASS the seed holds no kit lib or gauntlet dir
PASS the checker dir holds only the checker, the pristine stamp is a git repo
PASS the staged base is the seed repo's first commit
PASS the Dockerfile bakes no credential
PASS run.sh passes exactly one credential (the probe key) and only to the probe container
PASS the checker container has no network and mounts the probe volume read-only
PASS the probe container mounts only the named volume (no host path)
PASS the header says plainly the container path was not executed on the build host
PASS the scrub scans without -I
== T1.6 every generated test runs with the kit absent from PATH and HOME
PASS tests/test-stamp-kitfree.sh all: 13 passed, 0 failed

tier1: 0 failed, 47 passed
Exit: 0

Negative control

NEGATIVE CONTROL: eight controls, each run with lib/gate/negctl.sh after a commit and restored by git checkout. Each mutation turns its suite red; the restore turns it green again.

# Mutation Command Green before Under the mutation Green after
1 the guard allows a bare merge (the block becomes a no-op) bash tests/test-stamp-hook.sh 47 passed, 0 failed 42 passed, 5 failed 47 passed, 0 failed
2 the render skips the kit-path scan bash tests/test-stamp.sh 158 passed, 0 failed 154 passed, 4 failed 158 passed, 0 failed
3 write_if_absent overwrites an edited file bash tests/test-stamp.sh 158 passed, 0 failed 148 passed, 10 failed 158 passed, 0 failed
4 an approval no longer has to be at the judged head bash tests/test-stamp-merge.sh 80 passed, 0 failed 78 passed, 2 failed 80 passed, 0 failed
5 the tests job loses its fork guard bash tests/test-stamp-ci.sh 173 passed, 0 failed 172 passed, 1 failed 173 passed, 0 failed
6 the take backup skips a dangling symlink no more bash tests/test-stamp.sh 158 passed, 0 failed 155 passed, 3 failed 158 passed, 0 failed
7 the owners check keeps the colon in a rule line bash tests/test-stamp-refusals.sh 224 passed, 0 failed 223 passed, 1 failed 224 passed, 0 failed
8 the planted hostile repository config, run by a plain git call (the live control in Tier 1) bash tests/gauntlet/team-stamp/tier1.sh markers created by a plain git call no marker through the checker n/a

Command: bash tests/test-stamp-merge.sh (control 4, run by negctl)
Output:
80 passed, 0 failed (green before the mutation)
78 passed, 2 failed (under the mutation)
80 passed, 0 failed (after the restore)
Exit: 1
Verdict: RED, as expected

Test plan coverage

Acceptance criterion Test plan rows Covered by
AC1 file set 1 tests/test-stamp-e2e.sh
AC2, AC3 kit-free text and run 3, 4, 5, 46 tests/test-stamp-e2e.sh, tests/test-stamp-kitfree.sh, tests/test-stamp.sh
AC4 to AC7 idempotent, never overwrites, drift, refresh and take 2, 6 to 11, 48 tests/test-stamp.sh
AC8, AC9 refusals 12 to 23, 25 to 28, 41 to 49 each generated test, tests/test-stamp-refusals.sh
AC10 parity 22 the generated scripts/test-pr-shape.sh, tests/test-stamp-e2e.sh
AC11, AC12 runner and twin 29 to 32 tests/test-stamp-ci.sh, tests/test-stamp-e2e.sh (actionlint, hosted-label scan)
AC13 adopt interplay 33, 34, 36 tests/test-stamp-adopt-interplay.sh, tests/test-stamp.sh
AC14 privacy 35, 50 tests/test-stamp-e2e.sh privacy section (0 hits against the denylist held outside the repo)
AC16 negative controls 40 the block above (controls 1 to 3 are the original three; 4 to 8 cover the security fixes)
AC17, AC18, AC19 guidance, repo-living files, scan-safe digests 47, 48, 51 tests/test-stamp-rules.sh, tests/test-stamp.sh, tests/test-stamp-e2e.sh
AC15 the gauntlet run 39 Tier 1 only (tests/gauntlet/team-stamp/tier1.sh); Tier 2 NOT RUN, see docs/verification/gauntlet/2026-11-25-custom-team-stamp-scratch/ROUNDS.md

Rollback

The stamp is a generator and the kit holds no state for a stamped repo. Rolling back is reverting the pull request that adds the verb and its templates. A repo that was already stamped keeps its files: they are plain files the repo owns, and deleting them (or .claude/team-stamp.lock) is a repo decision, not a kit one.

Verdict: PASS

A new verb that renders templates/team-stamp into a repo as plain files: manifest rows (copy, seed, jsonmerge, hook), a lock of per-file hashes, never overwriting an edited file, drift report, refresh and take.
A secret scan reads a bare 64-hex run as a key. The lock now marks every digest, an older bare lock still reads, and a test stages a full stamp and scans it.
The hook in .claude/settings.json is used even in a folder not yet trusted (parent folder trusted, or claude -p). The guard lesson lists the same misses as the guard header, release-notes has no bare usage mode, and check.sh needs PR text before a PR exists. The kit-free harness prints the failing lines.
Stamps every group together with non-default values, checks the file set against the manifest and spec table, runs every generated test kit-free, builds a fixture PR through the stamped checks, and scans the branch for the denylist and bare digests.
Runs each refusal once on a full stamp, asserts the rule line then the Fix line, feeds hostile text, and runs every printed Fix line through bash -c in a copy.
After adopt wired its hooks, the stamp's entry sat in a second Bash group and the merge added it again. The merge now looks across every group with the same matcher. Adds the adopt interplay suite for both orders.
Adds commands/stamp.md and its MANUAL section, a changelog line, the regenerated feature table, the group notes, and settles the trust wording against the vendor page in the spec.
tr -d with a NUL range crashed with a segmentation fault on a loaded macOS host, inside the kit-free pass. sed deletes the same bytes. Drops the retry the e2e suite briefly had.
The pull request's own tests ran in the job that judges it and could swap the gate. changes and pr-shape now run only base copies, tests runs the PR's scripts alone, every job skips fork pull requests, and a missing base copy fails the job.
…n text

Requires both changes and pr-shape from the CI workflow, makes the harness files default doors, counts an approval only at the judged head from an owner, member or collaborator who is not a bot, updates the branch instead of checking out the PR, and refuses to run when its text differs from the default branch copy.
Refuses newline, CR and tab in a flag first, refuses dot-dot and absolute path values, prints every value with its source, and writes the take backup through a temp name that skips dangling symlinks.
The rules docs list the harness files as doors, warn that hook settings, the lessons index and agent scripts run in every teammate's next session, say the first stamp PR is merged by hand, and tell teams to use an ephemeral runner.
Rule lines drop the colon and cut text to 80 characters in every generated script, the digest passes titles, logins and board cells through the same filter, the guard reads a backslash before a command word, and negctl refuses a mutate command that moved HEAD.
The checker clones a bundle made inside the room into a directory it creates, runs git with config, fsmonitor and hooks off from a minimal environment, runs only pristine gate scripts, and fails when the probe edited one. run.sh persists named text files only and scans again after the key scrub. Tier 1 plants a hostile repository and shows nothing runs on the host.
The probe's work lives in a named volume. A second container with no key and no network checks it read-only, and the host copies out six named regular files with copy-out.sh, then scrubs the key without -I. The checker reads a neutral copy of the repo, lays pristine gate files over the view and reads file lists NUL-delimited. Tier 1 plants hostile repos, symlinked outputs and a key in a binary. The container path is not run on the build host.
A job that runs a pull request's own code does not belong on the runner that runs the gate jobs. The workflow keeps changes and pr-shape, with a stub saying where such jobs go. The twin set is two entries, check.sh still runs the generated tests locally, and the rules docs say it in one sentence.
Door and owner matching lower-cases paths, pr-shape refuses paths that differ only in case, the default doors cover the whole .github dir, CLAUDE.md and AGENTS.md at any depth and .mcp.json, the guard requires the default base, counts only this PR's runs of the stamped workflow, voids an approval older than the last base change, reads files from the REST list with previous names, and states honestly what its self-copy check stops.
KIT_MARKER is AGENTS_MARKER and KIT_PATTERN is LEAK_PATTERN in the engine, the template key, the manifest, the README contract and the tests.
# Conflicts:
#	CHANGELOG.md
#	docs/reference/FEATURES.md
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