Skip to content

Ticket 0007b: anchor emission at the kernel witness seal point - #318

Merged
noctem-o merged 1 commit into
mainfrom
seam/0007b-anchor-emit-kernel
Jul 4, 2026
Merged

noctem-o merged 1 commit into
mainfrom
seam/0007b-anchor-emit-kernel

Conversation

@noctem-o

@noctem-o noctem-o commented Jul 4, 2026

Copy link
Copy Markdown
Owner

What

Ticket 0007b — wires cog_anchor::Anchorer into cog-cli at one seal point (the kernel witness build), proving the full emission pattern before 0008-anchor-fanout replicates it to the other four.

  • cog anchor init --anchor-key <path> --anchor-log <path> — generates the bare 64-lowercase-hex Ed25519 key via cog-anchor, opens the log (auto-genesis), prints the verifying key. Refuses an existing key (fail-closed identity).
  • Kernel witness build — when anchoring is configured: verify → anchor (reuses the real verify_kernel_witness_run; an unverified bundle is never anchored). On any anchor failure: deterministic pending-anchor.json beside the manifest + loud warning naming cog anchor init, and the seal still succeeds (fail-open emission).
  • Unconfigured builds are byte-identical to before + a stderr notice — verification does not run when there is nothing to anchor.
  • Config: minimal deadbolt-anchor.toml ([anchor] signing_key_path / log_path) in the cwd; explicit flags override. Dev-grade local custody.
  • cog-cli reaches the log only through cog-anchor; magpie-log keeps exactly one direct dependent.

Review (independently verified)

Check (reviewer runs) Result
Anchor tests (cargo test -p cog-cli anchor) ✅ 6/6
kernel_witness tests (regression) ✅ 19/19
clippy -D warnings (cog-cli) ✅ clean
magpie_log imported directly in cog-cli ✅ none — log reached only via Anchorer
cargo tree -i magpie-log ✅ cog-anchor direct; cog-cli transitive
Diff scope ✅ cog-cli/** + Cargo.lock; cog-anchor untouched

Invariants confirmed: verify-gate is fail-closed (corrupt root → no log, no marker, Err); fail-open emission / fail-closed identity per the ratified 0007b §Decision; pending-anchor-v1 marker carries exactly the five fields + error, no timestamps; canonicalization profile read from the manifest, not hardcoded.

Reviewer fix applied on the worker's diff

Codex originally ran verification unconditionally at the top of the emission path — so an unconfigured build also verified, and a verify failure would have changed the build's exit vs. pre-seam behavior. Reordered to resolve anchoring config first: unconfigured → notice + return without verifying; verify runs only when an anchor is actually pending. Restores exact "unconfigured == old behavior + notice" and drops redundant work. (All 19 kernel_witness tests still green.)

Note

Config lives at deadbolt-anchor.toml in the current working directory — dev-grade and documented in cog help text; CWD-relative is a touch fragile but adequate for this stage.

Provenance

Implemented by Codex (gpt-5.5) via the delegation wrapper; ticket authored, diff reviewed, and the verify-gating fix applied by Claude. Human is the merge authority.

🤖 Generated with Claude Code

Wire cog_anchor::Anchorer into cog-cli at one seal point (kernel witness
build), proving the full emission pattern: config, verify->anchor ordering,
pending marker, unconfigured notice; opt-in and strictly additive.

- `cog anchor init --anchor-key --anchor-log`: generates the 64-hex Ed25519
  key via cog-anchor, opens the log (auto-genesis), prints the verifying key.
  Refuses an existing key (fail-CLOSED identity).
- Kernel witness build: when anchoring is configured, verify THEN anchor
  (reuses verify_kernel_witness_run; an unverified bundle is never anchored).
  On any anchor failure, write deterministic pending-anchor.json beside the
  manifest, warn loudly (naming `cog anchor init`), and keep the seal
  successful (fail-OPEN emission). Unconfigured builds are byte-identical to
  before plus a stderr notice -- verification does not run when there is
  nothing to anchor.
- Minimal config: deadbolt-anchor.toml [anchor] signing_key_path/log_path in
  the cwd; explicit flags override. Dev-grade local custody.
- cog-cli reaches the log ONLY through cog-anchor; magpie-log keeps exactly
  one direct dependent.

Other four seal points deferred to 0008-anchor-fanout.

Implemented by Codex (gpt-5.5) via delegation; Claude-reviewed. Verify-gating
(verify only when anchoring is configured) was a reviewer fix on Codex's diff.
6 anchor + 19 kernel_witness tests green; clippy -D warnings clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@noctem-o
noctem-o merged commit e479d1a into main Jul 4, 2026
1 check passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4648dce6c9

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


// Anchoring is intended (fully or partially configured). Normative ordering:
// verify, THEN anchor — an unverified bundle is never anchored.
let verify_report = verify_kernel_witness_run(run);

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 Badge Reuse the CLI verifier preflight before anchoring

When the run's kernel_decision_report.json is a symlink/reparse point, the normal verify kernel-witness path refuses the run via preflight_kernel_witness_source_artifacts before calling verify_kernel_witness_run, but this new anchor gate calls the library verifier directly and will follow the symlink and append an anchor. That means kernel witness build --anchor-* can record a SegmentAnchored event for a run that the CLI verifier rejects, so the verify-before-anchor guarantee is weaker than the actual verifier users run.

Useful? React with 👍 / 👎.

Comment on lines +113 to +115
let config = match read_anchor_config() {
Ok(config) => config,
Err(err) => return AnchorPathResolution::Failed(err),

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 Badge Honor explicit anchor flags before parsing config

When a malformed deadbolt-anchor.toml is present in the current directory, this early config read returns Failed before checking whether both --anchor-key and --anchor-log were supplied. In that scenario cog anchor init --anchor-key ... --anchor-log ... fails, and kernel witness build --anchor-* skips otherwise usable explicit paths and emits a pending marker instead of anchoring, even though complete flag values should not need the config file.

Useful? React with 👍 / 👎.

Comment on lines +90 to +95
let verifying_key = generate_key_file(&paths.key_path).map_err(|err| match err {
AnchorError::Key(message) => format!("anchor_init_key_refused: {message}"),
other => format!("anchor_init_key_failed: {other}"),
})?;
Anchorer::open(&paths.log_path, &paths.key_path)
.map_err(|err| format!("anchor_init_log_open_failed: {err}"))?;

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 Badge Preflight the log before writing a new key

If the key path is writable but the log path cannot be opened (for example its parent directory is missing, or an existing log was created with a different key), this writes a brand-new key file and then returns anchor_init_log_open_failed. A subsequent cog anchor init after fixing the log path still refuses the existing key, leaving the init command unable to complete without manual key deletion/recreation.

Useful? React with 👍 / 👎.

noctem-o added a commit that referenced this pull request Jul 5, 2026
Ticket 0009: anchor reconcile, the first consumer of anchors (+ P2 remediation from #318/#319)
@noctem-o
noctem-o deleted the seam/0007b-anchor-emit-kernel branch July 5, 2026 10:39
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