Skip to content

feat(artifacts): artifact-first WorkerResult lineage with hashes - #7555

Open
CR1MS0N-Operator wants to merge 2 commits into
kunchenguid:mainfrom
CR1MS0N-Operator:cr1ms0n/artifact-lineage
Open

CR1MS0N-Operator wants to merge 2 commits into
kunchenguid:mainfrom
CR1MS0N-Operator:cr1ms0n/artifact-lineage

Conversation

@CR1MS0N-Operator

@CR1MS0N-Operator CR1MS0N-Operator commented Oct 20, 2026 •

Copy link
Copy Markdown

What

Workers return a verified artifact manifest instead of prose: bin/fm-artifact-lib.sh + bin/fm-artifact-manifest.sh enforce a closed kind allowlist, refuse transcripts, keep paths inside data/<task>/ (symlink-safe), record the full sha256, and write atomically with a re-hash verification. The publisher appends artifacts=<manifest> artifacts_sha256=<digest> on the local parent channel; the scout and ship definitions of done require the manifest; docs/artifact-lineage.md and the script index are updated.

Consistency nit (fixed in ca92eaa5)

fm_artifact_kind_valid accepts manifest, and docs/artifact-lineage.md lists it, but the library header, the entry-point header, and both definitions of done listed only the other five kinds. All four now say patch, test-log, review-report, report, trace, manifest, so a worker reading the ship or scout DoD can find the kind it is allowed to name. No behaviour changed; tests/fm-artifact-manifest.test.sh passes unchanged.

How this composes with #7553 and #7389

#7553 adds ## Required artifact to the same briefs. They compose at exactly one point: that field names the manifest, and this PR is the contract behind the name. A ship or scout ## Required artifact should read something like "the verified manifest at data/<task>/artifacts.json, pinning the patch and the test log", and the DoD line owned here tells the worker how to write, verify, and reference it. Neither PR introduces a second artifact contract: the DoD/docs/artifact-lineage.md remains the single owner of the writer instruction and the kind list, and ## Required artifact only points at its output. Now that manifest is in every kind list, a brief that names "the manifest" agrees with the allowlist.

#7389 also edits worker artifact instructions. Whichever lands second should keep that single owner rather than restating kinds in the brief; this PR does not add a parallel instruction surface.

Verification

Rebase and conflicts

Rebased onto upstream main 9224c902 (2026-11-02). Two conflicts, both mechanical, both sides kept:

  • bin/fm-brief.sh — upstream added an empty-inventory attestation exception to the scout "stay inside this worktree" rule; this PR added the artifact manifest as a permitted outside-worktree write. Merged into one rule that allows the report, the artifact manifest, and the status file, with the attestation exception intact.
  • docs/secondmate-parent-channel.md — upstream added the config/ready-after-green note to the ship row; this PR added the artifact manifest to the scout row. Both kept.

Automated checks on this head

$ bash tests/fm-artifact-manifest.test.sh
ok - manifest write, verify, and ref round-trip
ok - a changed artifact fails verification and is not referenced
ok - a transcript is refused as a WorkerResult
ok - paths outside data/<task>/ or through a symlink are refused
ok - the local parent channel carries the manifest pointer and digest
ok - the remote route keeps the report pointer and omits the unfetchable manifest pair
all artifact manifest tests passed
rc=0

$ bash tests/fm-brief.test.sh    # passes
$ bash tests/fm-dod-lib.test.sh  # all fm-dod-lib tests passed
$ bash tests/fm-inactive-reconcile.test.sh  # all inactive reconciliation tests passed
$ PATH=/tmp/sc-bin:$PATH bin/fm-lint.sh
fm-lint.sh: ShellCheck 0.11.0 (pinned 0.11.0)
fm-lint-workflows.sh: actionlint 1.7.12 (pinned 1.7.12)
fm-lint-workflows.sh: 3 workflow files valid
rc=0

ShellCheck and actionlint were installed locally for this run with the repo's own pinned installers (bin/fm-install-shellcheck.sh /tmp/sc-bin, bin/fm-install-actionlint.sh /tmp/sc-bin); nothing was installed system-wide.

Live validation: the parent channel, local route and remote route

Disposable main and mate homes; a child task record whose ledger ends in a terminal done: line; the real publisher invoked as bin/fm-inactive-reconcile.sh report child on each route.

Local route — manifest written, verified, then published:

$ bin/fm-artifact-manifest.sh write --task child --artifact report=data/child/report.md --artifact patch=data/child/worker.patch
/tmp/fm-artifact-lab2/local/mate/data/child/artifacts.json

$ bin/fm-artifact-manifest.sh verify --task child
verified: data/child/artifacts.json

$ bin/fm-artifact-manifest.sh ref --task child
artifacts=data/child/artifacts.json artifacts_sha256=31c8da193524a1ba475fbb69f64ca6edba2413fd6f0955cfc8699965257b3341

$ bin/fm-inactive-reconcile.sh report child
report rc=0

$ sed -n '/child child done/p' /tmp/fm-artifact-lab2/local/main/state/mate.status
done [key=child-outcome-child-done-9ee0eadb] [at=1793653745]: child child done: report written pr=https://example.test/owner/repo/pull/1 mode=no-mistakes yolo=off report=data/child/report.md artifacts=data/child/artifacts.json artifacts_sha256=31c8da193524a1ba475fbb69f64ca6edba2413fd6f0955cfc8699965257b3341

The published pair is exactly the ref output: the parent reads the pointer and the digest, and the digest names the manifest bytes.

Remote route — same child, same writer, remote parent config:

$ bin/fm-artifact-manifest.sh write --task child --artifact report=data/child/report.md
/tmp/fm-artifact-lab2/remote/mate/data/child/artifacts.json

$ bin/fm-inactive-reconcile.sh report child
report rc=0

$ grep 'child child done' /tmp/fm-artifact-lab2/remote/mate/state/parent-replies.status
done [key=child-outcome-child-done-9ee0eadb] [at=1793653746]: child child done: report written pr=https://example.test/owner/repo/pull/1 mode=no-mistakes yolo=off report=data/child/report.md

$ grep 'child child done' /tmp/fm-artifact-lab2/remote/mate/state/parent-replies.status | grep -c 'artifacts='
0

The remote line keeps the report= pointer and omits the manifest pair it cannot fetch, as docs/artifact-lineage.md says.

Gaps I could not validate here (named, not faked)

  • A real ship or scout worker following the DoD line to write data/<id>/artifacts.json. No harness this repo's gate configuration permits is authenticated on this machine: claude -p "reply with exactly: OK" returns Not logged in · Please run /login; codex returns 401 Incorrect API key; pi reports no API key for the selected model; grok is not signed in; omp gets 401 from its local gateway. A spawn reaches the worktree and the pane and then stops at the harness's first-run screen, so I could not obtain a real worker transcript writing the manifest. The manifest writer/verifier and the publication path above are the real scripts with real output, but the worker-driven half is unproven here.
  • A live secondmate home. The channel evidence uses a disposable home laid out as a secondmate home (.fm-secondmate-home, .fm-secondmate-parent) with a terminal child ledger line and the real publisher, not a provisioned second mate with a live worker.

no-mistakes attestation

This branch was pushed through the gate on this exact head:

$ git push --force-with-lease=refs/heads/cr1ms0n/artifact-lineage:c8d3f9fc no-mistakes cr1ms0n/artifact-lineage
 + c8d3f9fc...ca92eaa5 cr1ms0n/artifact-lineage -> cr1ms0n/artifact-lineage (forced update)

$ no-mistakes axi run --intent "..."
outcome: failed
error: "step review failed: agent review: claude exited: exit status 1: API error: Not logged in · Please run /login"

So this head carries no no-mistakes attestation, and the "PR must be raised via no-mistakes" check will stay red until the run can execute an agent. That is an unauthenticated-agent limitation on this machine, not a decision to skip the gate. Before I rebased, the gate's own rebase step reported exactly the two mechanical conflicts listed above (rebase-1 bin/fm-brief.sh, rebase-2 docs/secondmate-parent-channel.md); after the rebase it completed with 0 findings and the run failed at Review on the agent login.

Contract class

New-default: every unconfigured ship and scout brief tells the worker to write and hash a manifest before done:, and the parent channel gains a field. Captain merge-or-leave decision, not an auto-merge.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-20T04:38:09.164086Z ee1812c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks, @CR1MS0N-Operator. A hash-pinned artifact manifest in place of a prose self-report fits "workers are supervised, not trusted". The path confinement and symlink refusal are careful work.

Where it stands: I read the diff of head ee1812c1. It touches no workflows or secrets, so I approved the first-time fork CI and Require no-mistakes runs. Two things are missing before this can go further, and both are on you:

  1. No no-mistakes raise. The PR body has no no-mistakes pipeline attestation, so the blocking "PR must be raised via no-mistakes" check will not pass as-is. Please re-raise through no-mistakes (git push no-mistakes) so the attestation lands on the head.
  2. No live validation yet. The evidence so far is the new unit test file. Could you drive it live and post the evidence? For example: a real ship or scout worker following the new definition-of-done line to write data/<id>/artifacts.json, and a secondmate's parent channel actually carrying the artifacts= artifacts_sha256= pair on the local route (and omitting it on the remote route). The no-mistakes live-validation step can capture this for you.

A small consistency nit while you're there: fm_artifact_kind_valid accepts manifest, and docs/artifact-lineage.md lists it, but the script headers and both definition-of-done texts list only five kinds.

Contract-class (my own read): new-default. Every unconfigured ship and scout brief now tells the worker to write and hash a manifest before done:, and the parent channel gains a new field. Even when CI and evidence are green, this is a captain merge-or-leave decision, not an auto-merge.

VISION.md per rule:

  • One captain, one interface: aligns. Outcomes become checkable without reading transcripts.
  • Authority: aligns. No new autonomy.
  • Scripts own mechanics: aligns. Hashing and verifying are scripted, while the agent only lists its artifacts.
  • Token efficiency: a small cost on every brief and every task, which is part of the captain's call.
  • Restart is a non-event: aligns. The record is durable.
  • Delegation with a spine: aligns. It is evidence-backed and no new task shape.
  • Fleet outlives any vendor: aligns. Harness-neutral.
  • Scope: aligns.

Overlap: your #7553 adds a ## Required artifact field to the same briefs, and #7389 also edits worker artifact instructions. It would help to say how the two of yours compose (for example, whether Required artifact should name the manifest), so Kun isn't choosing between two artifact contracts.

CR1MS0N-Operator and others added 2 commits November 2, 2026 14:02
…(bead 82cc)

Workers now return artifact references plus full SHA-256 hashes instead of a
conversational summary. A manifest at data/<task>/artifacts.json names each
artifact by kind and path; the parent channel carries only the manifest pointer
and its digest.

- bin/fm-artifact-lib.sh: closed kind allowlist (transcripts refused), confined
  data/<task>/ paths, full-hash hashing, atomic write, verified re-hash.
- bin/fm-artifact-manifest.sh: write/verify/ref entry point.
- bin/fm-inactive-reconcile.sh: append artifacts= and artifacts_sha256= to a
  child's local parent-channel line while the manifest verifies.
- bin/fm-brief.sh and bin/fm-dod-lib.sh: scout and ship definitions of done
  require the manifest before the done line.
- docs/artifact-lineage.md plus the parent-channel and script-index pointers.
- tests/fm-artifact-manifest.test.sh covers the round trip, tamper detection,
  transcript refusal, unsafe paths, and both channel routes.

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
`fm_artifact_kind_valid` (bin/fm-artifact-lib.sh:44) accepts `manifest`, and
docs/artifact-lineage.md lists it, but the library header, the entry-point
header, and both definition-of-done texts in bin/fm-brief.sh and
bin/fm-dod-lib.sh listed only the other five kinds. A worker reading the ship
or scout DoD could not find the sixth kind it is allowed to name.

Measured: bin/fm-artifact-manifest.test.sh passes unchanged (it asserts
behaviour, not the prose list), and `bash -n` is clean on all four scripts.
@CR1MS0N-Operator
CR1MS0N-Operator force-pushed the cr1ms0n/artifact-lineage branch from ee1812c to ca92eaa Compare November 2, 2026 21:04
@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 0/5

[Medium impact] The PR changes how scout and ship work records reach local parent channels.

Fix the skipped artifact checks, cross-task paths, and scout command before merging.

Reviews (1) · Last reviewed commit: "docs(artifacts): list the manifest kind ..." · Reviewed by Greptile

Comment thread bin/fm-artifact-lib.sh
Comment on lines +168 to +170
case "$line" in
' {'*'}') ;;
*) continue ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Most artifacts go unchecked

fm_artifact_manifest_verify skips every non-final entry written by write. The writer adds no newline after each object, so the next separator makes that line end in },. This selector accepts only lines ending in }.

With a patch and a test log, changing or deleting the patch still lets verify and ref succeed while the test log remains intact. Check every entry and add a test that changes a non-final artifact.

How this was verified: The writer produces comma-ended non-final entries, the verifier skips those lines, and the publisher accepts the resulting successful check.

Comment thread bin/fm-artifact-lib.sh
Comment on lines +84 to +88
base=$(CDPATH='' cd -- "$data" 2>/dev/null && pwd -P) || return 1
real=$(CDPATH='' cd -- "$(dirname "$path")" 2>/dev/null && pwd -P) || return 1
case "$real" in
"$base"|"$base"/*) ;;
*) return 1 ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Other tasks' files pass

fm_artifact_resolve checks the resolved directory against the whole data directory, not the task directory. It also allows intermediate directory links. A worker can create data/task/link pointing to ../other and submit data/task/link/report.md; both writing and checking accept the other task's report as its evidence.

Reject linked directory components and require the resolved file to stay under the requested task.

How this was verified: Worker-selected paths pass through the same resolver during writing and checking, and its resolved-path check accepts sibling task directories.

Comment thread bin/fm-brief.sh
Write your findings to \`$DATA/$ID/report.md\`.
The report must stand alone: what you did, what you found, the evidence (commands run, output, file:line references), and what you recommend.
Return artifacts, not a transcript: write the lineage manifest with
\`$FM_ROOT/bin/fm-artifact-manifest.sh write --task $ID --artifact report=$DATA/$ID/report.md\`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Scout command rejects report path

The generated command passes an absolute report path, but fm_artifact_rel_valid accepts only data/<task>/.... DATA is resolved to an absolute directory before this brief is written, so following the command fails with exit code 3 instead of creating the required manifest.

Render report=data/$ID/report.md and keep the chosen home/data directory separate from the artifact's relative path.

Comment thread bin/fm-dod-lib.sh
Comment on lines +707 to +712
cat <<EOF

## Artifact lineage
Return artifact references and hashes, not a conversational summary: the parent consumes your manifest, never your transcript.
Before your done line, write the lineage manifest with
\`$artifact_root/bin/fm-artifact-manifest.sh write --task $id --artifact <kind>=<path> ...\`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Manual PRs miss manifest instructions

The new shared block is never printed for no-mistakes tasks with pr=manual. That branch calls fm_dod_manual_pr_block and returns before reaching this block. The helper contains no manifest instructions, so these workers miss the new completion requirement.

Make that branch continue to the shared block too.

Comment thread bin/fm-artifact-lib.sh
Comment on lines +109 to +110
path=$(fm_artifact_resolve "$data" "$task" "$rel") || return 3
hash=$(fm_artifact_sha256 "$path") || return 4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Manifest overwrites its own evidence

write accepts an existing data/<task>/artifacts.json as a manifest artifact, hashes it, then overwrites that same file with the new manifest. Rerunning with only --artifact manifest=data/task/artifacts.json returns success but immediately fails verification because it records the old file's hash.

Reject the output path as an input before replacing any existing manifest.

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.

2 participants