Skip to content

feat(warp-core): add anchored-node create-if-absent program#686

Open
flyingrobots wants to merge 12 commits into
mainfrom
feat/anchored-node-creation-from-absence
Open

feat(warp-core): add anchored-node create-if-absent program#686
flyingrobots wants to merge 12 commits into
mainfrom
feat/anchored-node-creation-from-absence

Conversation

@flyingrobots

@flyingrobots flyingrobots commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Keeps EchoOperationProgramV1::AnchoredNodeAttachmentCompareAndSet update-only and preserves its canonical program bytes, invocation bytes, result identity calculation, schemas, footprint contract, and target profile.
  • Adds EchoOperationProgramV1::AnchoredNodeAttachmentCreateIfAbsent as a distinct executable program with its own program kind, footprint contract, invocation/input/result/application-basis schemas, target profile, result identity domain, and canonical two-operation recovery shape.
  • Defines creation as a strong total-absence precondition over two independently observed locations: the anchored node and its alpha attachment. Any occupied state refuses with PreconditionMismatch, regardless of the occupant's type.
  • Charges creation for the node type, attachment type, and payload (64 + payload length), while update retains its existing 32 + payload length write charge. The step counter measures semantic evaluator stages, not emitted WarpOp count.
  • Makes WAL recovery select and validate the exact patch shape from the receipt-bound installed target profile. Creation accepts only the ordered UpsertNode + SetAttachment patch with node + attachment outputs; update accepts only SetAttachment with the attachment output.

This closes the single anchored-node-plus-alpha-attachment creation gap in the executable-operation corridor. It does not establish a real Edict compiler crossing, a structurally separate application verifier, or atomic execution of Graft's recordGitWarpImportBatch, whose declared footprint creates both GitWarpImportBatch and StructuralBasis.

See docs/adr/0024-anchored-node-creation-from-absence.md for the complete compatibility, identity, budget, recovery, and scope decision.

Closes #685

Test plan

  • Legacy compare-and-set canonical program and invocation bytes remain fixed; update result identity retains the original calculation.
  • Creation succeeds only from node-absent + attachment-absent.
  • Creation refuses node-only, attachment-only, node + attachment, and wrong-typed occupied-node states as PreconditionMismatch.
  • Creation succeeds at the exact 64 + payload length write boundary and refuses one byte below it; update retains its separate 32 + payload length boundary.
  • A filesystem-WAL creation commit survives a fresh-host restart and recovers the installation, node, attachment, result identity, and typed receipt.
  • Recovery accepts the exact creation patch for descendant node coordinates and rejects reversed, incomplete, cross-node, wrong-output, and wrong-profile shapes.
  • All 24 executable-operation pipeline tests pass.
  • Full warp-core suite passes with native_rule_bootstrap,trusted_runtime,host_test: 689 library tests, all integration test binaries, and 33 doctests.
  • cargo fmt --all --check, Markdown lint/Prettier, git diff --check, and tests/docs/test_adr_namespace.sh pass.
  • Strict all-target Clippy reproduces the branch's 57 pre-existing test-target violations; the normal warp-core --lib Clippy pre-commit gate passes.

Summary by CodeRabbit

  • New Features
    • Added “create-if-absent” anchored-node creation that atomically creates the node plus its alpha attachment only when both are missing.
    • Added distinct program/invocation/identity handling for create vs existing compare-and-set update behavior.
  • Bug Fixes / Improvements
    • Tightened executable-operation WAL validation and patch-scope recognition to prevent mismatched or malformed installed outcomes.
  • Documentation
    • Added and indexed ADR 0024; updated architecture and topic docs, plus README wording.
  • Tests
    • Expanded pipeline and WAL recovery coverage for success, conflicts, refusal paths, and metering/TOCTOU cases.

Widen EchoOperationProgramV1::AnchoredNodeAttachmentCompareAndSet's
per-invocation precondition from a required digest to Option<Hash>.
Some(digest) is exactly today's update semantics, unchanged; None
asserts the node and its typed alpha attachment are both entirely
absent, and Echo creates both atomically in one patch using the
package-declared node type, or refuses with PreconditionMismatch.

The corridor's only program kind previously required the node and
attachment to already exist at both the coarse admission-time
application-basis check and the fine-grained evaluation-time check.
That was invisible to ReplaceRange (#684) because Jedit's buffer
nodes are created through CreateBufferWorldline, outside this
corridor. Any caller whose writes are new facts rather than edits to
a node created elsewhere hits this gap immediately.

current_application_basis widens symmetrically through a new,
domain-separated absent proposition so a stale or dishonest absence
claim is caught at admission, not only at evaluation.
anchored_node_footprint declares node-write iff creation was
claimed, keeping the declared/actual footprint equality check exact
in both branches. WarpOp::UpsertNode already existed and is reused;
no new program kind, WarpOp kind, or application-specific intrinsic
is introduced.

All 13 pre-existing tests in executable_operation_pipeline_tests.rs
pass with unmodified behavior. Three new tests exercise the full
TrustedRuntimeHost pipeline for create-from-absence, create-refuses-
when-exists, and update-refuses-when-absent. Full warp-core suite
(81 binaries, 686 library tests, doctests) passes; clippy reports
the identical pre-existing error set before and after.

See ADR 0024 for the full decision record.

Closes #685
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@flyingrobots, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4661a2d6-bd80-47ba-bd39-6559904656e9

📥 Commits

Reviewing files that changed from the base of the PR and between ebee7cf and 3f684e5.

📒 Files selected for processing (1)
  • docs/topics/GeneratedRules.md
📝 Walkthrough

Walkthrough

The executable-operation corridor adds a distinct create-if-absent program. It separately defines creation schemas, identities, absence admission, atomic node-and-attachment evaluation, program-bound WAL validation, and tests while preserving compare-and-set update semantics.

Changes

Anchored-node creation corridor

Layer / File(s) Summary
Creation contract and absence admission
crates/warp-core/src/echo_operation.rs, crates/warp-core/src/lib.rs, docs/adr/*, tests/docs/*
Creation has distinct program, invocation, footprint, application-basis, result, and target-profile identities; admission corroborates independent node and attachment absence and rejects profile mismatches.
Atomic creation and update evaluation
crates/warp-core/src/echo_operation.rs
Private evaluation emits ordered UpsertNode and SetAttachment operations only when both locations are absent, while compare-and-set remains update-only with its legacy result identity and footprint behavior.
Program-bound WAL validation
crates/warp-core/src/trusted_runtime_host.rs
WAL recording and recovery validate the installed program and exact canonical patch shape, including operation order, slots, types, payload bounds, and scope.
End-to-end validation
crates/warp-core/tests/executable_operation_pipeline_tests.rs, CHANGELOG.md
Fixtures and tests cover successful creation, occupancy and orphan refusals, TOCTOU protection, WAL recovery, budget charging, and update compatibility.
Corridor documentation
README.md, docs/architecture/*, docs/topics/*, docs/adr/*
Documentation records the two bounded profiles, recovery behavior, current exclusions, and ADR 0024 decision.

Estimated code review effort: 5 (Critical) | ~100 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant TrustedRuntimeHost
  participant EchoOperation
  participant StateStore
  participant WAL
  Caller->>TrustedRuntimeHost: submit create-if-absent invocation
  TrustedRuntimeHost->>EchoOperation: admit and prepare against installed program
  EchoOperation->>StateStore: verify node and attachment absence
  EchoOperation-->>TrustedRuntimeHost: emit atomic UpsertNode plus SetAttachment patch
  TrustedRuntimeHost->>StateStore: commit patch
  TrustedRuntimeHost->>WAL: record program-bound executable-operation tick
  WAL-->>TrustedRuntimeHost: validate canonical recovery shape
  TrustedRuntimeHost-->>Caller: return committed operation result
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a separate anchored-node create-if-absent program.
Linked Issues check ✅ Passed The changes align with #685: separate create-if-absent semantics, preserved update-only compare-and-set, exact recovery validation, and test coverage.
Out of Scope Changes check ✅ Passed The documentation and test updates stay within the stated ADR 0024 and executable-operation corridor scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/anchored-node-creation-from-absence

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/warp-core/src/echo_operation.rs`:
- Around line 2391-2423: In the `store.node(&node.local_id)` `None` branch,
check `store.node_attachment(&node.local_id)` before constructing the create
operations. If an attachment already exists, return
`obstruction(EchoOperationObstructionKindV1::PreconditionMismatch)`; otherwise
preserve the existing budget charging, footprint updates, and atomic
`UpsertNode`/`SetAttachment` flow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fb8afe6e-f111-48ae-91d7-3415051c05f9

📥 Commits

Reviewing files that changed from the base of the PR and between 67d64ab and 3b61778.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • crates/warp-core/src/echo_operation.rs
  • crates/warp-core/src/lib.rs
  • crates/warp-core/tests/executable_operation_pipeline_tests.rs
  • docs/adr/0024-anchored-node-creation-from-absence.md
  • docs/adr/README.md
  • tests/docs/test_adr_namespace.sh

Comment thread crates/warp-core/src/echo_operation.rs Outdated

@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: 3b61778cd7

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

Comment thread crates/warp-core/src/echo_operation.rs Outdated
Comment thread crates/warp-core/src/echo_operation.rs Outdated
Comment thread crates/warp-core/src/echo_operation.rs Outdated
Comment thread crates/warp-core/src/echo_operation.rs Outdated
Comment thread crates/warp-core/src/echo_operation.rs Outdated
@flyingrobots

Copy link
Copy Markdown
Owner Author

Code Lawyer self-review (CodeRabbit-style pass)

Reviewed git diff origin/main...HEAD in full (7 files, 662+/71-). Pre-review checklist passed: worktree clean, fetched origin/main first. Verified pass/fail claims independently against a clean origin/main worktree (not stash) rather than trusting text alone.

Summary table

# File Line(s) Severity Type Issue
1 crates/warp-core/src/echo_operation.rs operation_result_id, L3777-3792 High Correctness of claim (Evidence Law) hash_optional_id adds a 1-byte discriminant tag for both Some and None, not just None. This changes operation_result_id's hash input — and therefore EchoOperationResultIdV1 and everything chained from it (preparation_id, receipt identities) — for the pre-existing update path too, not only the new create path. This contradicts ADR 0024's own claims at L164-165 ("wire encoding... byte-for-byte unchanged") and L223 ("unchanged bit-for-bit"). EchoOperationInvocationV1's canonical bytes genuinely are unchanged for Some(...) — but operation_result_id's internal encoding is a different function and it did change, for both branches.
2a crates/warp-core/src/echo_operation.rs L2425 (if record.ty != required_node_type) Medium Test coverage No test exercises create-from-absence (None) against a node that exists with the wrong NodeRecord.ty. Falls into NodeTypeMismatch before creation-specific logic runs at all — plausible-looking by inspection, unverified by a test.
2b crates/warp-core/src/echo_operation.rs L2431-2436 (if expects_creation { PreconditionMismatch } else { AttachmentMissing }) Medium Test coverage No test exercises create-from-absence against a node that exists with the correct type but has no alpha attachment set. The expects_creation=true arm of this ternary is never hit by the test suite.
3 crates/warp-core/src/echo_operation.rs L2046 (if invocation.delegated_budget.read_bytes < 64) Medium Test coverage New admission-time budget precheck for absence corroboration has no dedicated test, unlike its present-value analog (covered by package_admission_rejects_malformed_unsupported_mismatched_and_over_budget_bytes).
4 crates/warp-core/src/echo_operation.rs prepare_operation_v1 create branch Low (optional) Test coverage No test confirms the existing basis-changed TOCTOU protection (a_prepared_operation_cannot_commit_after_its_parent_basis_changes's pattern) also covers a prepared create-from-absence patch. The mechanism is generic and already proven for update; a dedicated create-path test would close the loop rather than leaving it as an inference.

Verified clean (no finding)

  • cargo clippy --all-targets: independently re-verified against a clean origin/main worktree (not stash) using file:line locations, not just message text. The only diff between before/after is one pre-existing lint (field_reassign_with_default at the unrelated factor_mask = 1 line in mod tests) shifted by the same +110 line offset my insertions produce elsewhere in the file — same lint, same code, zero new locations.
  • No other Rust file in the repo references anchored_node_attachment_compare_and_set or expected_value_digest outside the two files this PR already updates — confirmed via full-repo grep, no missed call sites.
  • No stale doc/example elsewhere references the old required-Hash signature.
  • WarpOp::UpsertNode ordering (create node, then set its attachment) is empirically verified by the passing create_from_absence_commits_one_new_node_and_attachment_patch test's post-commit store readback, not just asserted by inspection.

Recommended mitigation prompts

#1 (High): In crates/warp-core/src/echo_operation.rs, operation_result_id's previous_value_digest now goes through hash_optional_id for both Some and None, adding a discriminant byte that wasn't present before for Some. This changes EchoOperationResultIdV1 for the existing update path. Either (a) correct ADR 0024 (docs/adr/0024-anchored-node-creation-from-absence.md ~L164, ~L223) to precisely scope the "unchanged" claim to EchoOperationInvocationV1's canonical bytes only, and state explicitly that operation_result_id's internal hash layout changed for both branches — noting this is judged acceptable because no real committed result/receipt identities exist yet per CHANGELOG.md; or (b) restructure operation_result_id so the Some case's hash input is byte-identical to before (only None gets distinct treatment). Prefer (a) unless byte-identical result IDs are required for a reason not yet stated.

#2a/#2b (Medium): Add two tests to crates/warp-core/tests/executable_operation_pipeline_tests.rs: (1) create-from-absence against a node that exists with a different NodeRecord.ty than the installed package's required_node_type, asserting NodeTypeMismatch; (2) create-from-absence against a node that exists with the correct type but no alpha attachment (GraphStore::insert_node without set_node_attachment), asserting PreconditionMismatch. Mirror create_from_absence_refuses_when_the_node_already_exists's basis-construction pattern.

#3 (Medium): Add a test constructing a create-from-absence invocation with delegated_budget.read_bytes < 64 against a genuinely absent node, asserting admit_echo_operation_invocation_v1 returns EchoOperationInvocationAdmissionErrorKindV1::BudgetExceeded.

#4 (Low, optional): Add a create-from-absence variant of a_prepared_operation_cannot_commit_after_its_parent_basis_changes if closing this inference gap is worth the test-suite size.


@codex — requesting confirmation on finding #1 in particular (the result-identity claim in ADR 0024). Does the "no real committed data yet" framing in CHANGELOG.md fully cover this, or does the ADR need a precision edit before merge?

Self-code-review (CodeRabbit-style pass, posted to PR #686) surfaced
one high-severity and three medium-severity findings against
3b61778. All addressed:

- operation_result_id's previous_value_digest now goes through
  hash_optional_id for both Some and None, which adds a discriminant
  tag byte the pre-existing Some path never had. This changes
  EchoOperationResultIdV1 (and everything chained from it) for the
  update path too, not only the new create path -- contradicting
  ADR 0024's "byte-for-byte unchanged" / "unchanged bit-for-bit"
  claims as originally written. Corrected the ADR's Verification
  Evidence Grade and Consequences sections to precisely scope what's
  actually unchanged (EchoOperationInvocationV1's canonical bytes and
  observable behavior) versus what changed but is judged acceptable
  (this one internal digest, for both branches, given no real
  committed result/receipt identity exists yet).

- The new admission-time budget precheck in current_application_basis
  ("read_bytes < 64") turned out to be unreachable dead code on
  closer inspection while writing its test: admit_invocation_v1's
  existing minimum-budget gate already requires
  invocation.delegated_budget.read_bytes >= 64 before
  current_application_basis is ever called. Removed the dead guard
  rather than writing an untestable test for it, with a comment
  explaining why no local guard is needed.

- Added three tests closing real coverage gaps: create-from-absence
  against a node that exists with the wrong NodeRecord.ty
  (NodeTypeMismatch, not a generic precondition failure); against a
  node that exists with the correct type but no attachment
  (PreconditionMismatch -- creation is atomic over both slots or it
  refuses); and a basis-changed TOCTOU race for a prepared
  create-from-absence patch, proving the existing exact-basis commit
  protection is generic and not update-specific. New
  fixture_host_with_bare_node helper backs the first two.

19 tests now pass in executable_operation_pipeline_tests.rs (was 16).
Full warp-core suite (81 binaries, 686 library tests, doctests) still
green; clippy identical pre-existing error set, independently
verified against a clean origin/main worktree by exact file:line
location.
@flyingrobots

Copy link
Copy Markdown
Owner Author

Findings resolved (53fed09)

# Severity Resolution
1 High Corrected ADR 0024's Verification Evidence Grade and Consequences sections. The claim was imprecise: operation_result_id routes previous_value_digest through hash_optional_id, which adds a discriminant tag for both Some and None, so EchoOperationResultIdV1 (and everything chained from it) changed for the update path too. EchoOperationInvocationV1's canonical bytes and observable behavior genuinely are unchanged for Some(...) -- the ADR now says precisely that, and states plainly that this one internal digest changed for both branches, judged acceptable since no real committed result/receipt identity exists yet.
2a/2b Medium Added two tests (create_from_absence_refuses_when_the_node_exists_with_the_wrong_type, create_from_absence_refuses_when_the_node_exists_without_its_attachment) via a new fixture_host_with_bare_node helper. Both pass, confirming the two previously-uninspected branches behave as the code implies.
3 Medium → upgraded finding On closer inspection while writing the test, this wasn't just untested -- it was unreachable dead code. admit_invocation_v1's existing minimum-budget gate already requires read_bytes >= 64 before current_application_basis is ever called, so the local < 64 guard could never fire. Removed it rather than writing an untestable test, with a comment explaining why no local guard is needed.
4 Low Added create_from_absence_cannot_commit_after_its_parent_basis_changes, mirroring the existing update-path TOCTOU test, confirming the generic exact-basis commit protection covers creation too.

19 tests now pass in executable_operation_pipeline_tests.rs (was 16, now +3 net beyond the original PR's +3). Full warp-core suite (81 binaries, 686 library tests, doctests) still green; clippy identical pre-existing error set, re-verified against a clean origin/main worktree by exact file:line location.

@codex — the dead-code removal (finding #3) is the one I'd most like a second pair of eyes on: confirming current_application_basis has exactly one call site (admit_invocation_v1 L1986) and that the budget-fits check at L~1940ish genuinely precedes it unconditionally for both Some and None invocations.

@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: 53fed09957

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

Comment thread crates/warp-core/src/echo_operation.rs Outdated
Comment thread docs/adr/0024-anchored-node-creation-from-absence.md Outdated
Comment thread crates/warp-core/src/echo_operation.rs Outdated
Comment thread docs/adr/0024-anchored-node-creation-from-absence.md Outdated
Comment thread crates/warp-core/src/echo_operation.rs Outdated
…very

operation_patch_scope_v1 only recognized the single-SetAttachment-op
update shape. A create-from-absence patch (WarpOp::UpsertNode then
WarpOp::SetAttachment, two-element out_slots) never matched, so
validate_operation_receipt_state_delta rejected every durable
create-from-absence commit with EchoOperationExecutionMismatch --
not only on recovery by a fresh host, but synchronously at the
original commit whenever the runtime WAL is enabled.

Found by Codex's automated review on PR #686. Extended the function
to recognize both canonical patch shapes explicitly, rather than
adding a second unrelated function, since both are the same
program's only two possible outputs.

RED: filesystem_wal_recovers_a_create_from_absence_commit failed at
commit_prepared_echo_operation_v1 with exactly this error before the
fix. GREEN: same test now passes; full pipeline suite (20 tests) and
existing update-path WAL recovery test both remain green.
…ment

Two review findings, same root cause: GraphStore::set_node_attachment
never requires the owning node to exist, so an attachment present
with no NodeRecord (an orphan) is a real reachable state, not
hypothetical. Neither admission nor evaluation independently checked
for it when the node itself was absent.

- current_application_basis (Codex, P2): derived "absent" from node
  presence, so it never inspected the attachment when the node was
  missing. A create-from-absence invocation dishonestly claiming
  absence against a real orphan was admitted. Fixed by deriving
  absence from the attachment slot alone -- the only thing this
  primitive actually mutates -- so an orphan corroborates as present,
  using its real value, exactly like the ordinary case.

- prepare_operation_v1's create branch (CodeRabbit, Major): built the
  atomic create ops without checking whether the attachment slot was
  already occupied, since node absence doesn't imply attachment
  absence. A caller with a basis honestly reflecting an orphan's real
  present value (passing the now-fixed admission check) could still
  reach evaluation and silently overwrite it. Fixed by checking
  store.node_attachment(&node.local_id).is_some() before proceeding,
  refusing with PreconditionMismatch -- creation is atomic over both
  slots or it refuses, per ADR 0024.

New fixture_host_with_orphan_attachment helper backs two tests, one
per layer: admission refuses a dishonest absence claim with
BasisMismatch; evaluation refuses (and leaves the orphan untouched)
when the claimed basis honestly reflects the orphan's real value,
isolating the evaluation-time check specifically. The two fixes had
to land in that order -- before the admission fix, the evaluation
test's premise (an honest "present" basis matching what admission
computes) wasn't reachable, since old admission unconditionally
computed "absent" whenever the node was missing.

22 tests pass (was 20); full pipeline suite green.
The create-from-absence write charge counted only 32 (attachment
type id) + replacement_len, but the same patch also writes
WarpOp::UpsertNode's 32-byte NodeRecord.ty. An invocation delegated
only enough write budget for the attachment could commit 32 more
bytes than declared, and the receipt's consumed_budget underreported
actual resource consumption.

Found by Codex's automated review on PR #686. Changed the charge to
64 (node type + attachment type) + replacement_len; the update path's
32 + replacement_len is untouched, since that branch never writes a
node record.

RED: create_from_absence_charges_the_node_record_against_the_write_budget
delegated a write budget between the old (39) and correct (71)
requirement for a 7-byte replacement and expected BudgetExceeded;
the buggy charge let it commit instead. GREEN: same test passes;
updated create_from_absence_commits_one_new_node_and_attachment_patch's
consumed-budget assertion (39 -> 71) to match the corrected charge.
23 tests pass (was 22); full pipeline suite green.
…Mismatch

record.ty was checked before expects_creation in the Some(record) arm,
so create-from-absence against an existing node with the wrong type
returned NodeTypeMismatch instead of PreconditionMismatch --
contradicting ADR 0024's own stated contract that every occupied
create target refuses uniformly as a precondition failure, regardless
of what specifically differs.

Found by Codex's automated review on PR #686. Moved the
expects_creation check to the top of the Some(record) arm, before the
type/attachment checks that exist to serve the update path. This also
simplified the code: the now-unreachable expects_creation branches
inside the attachment-lookup ternary and the redundant standalone
check after it are gone.

Updated create_from_absence_refuses_when_the_node_exists_with_the_wrong_type
to expect PreconditionMismatch. This left NodeTypeMismatch completely
untested, so added
update_precondition_refuses_when_the_node_has_the_wrong_type proving
it's still correctly reachable on the update path, where a caller who
correctly expected the node to exist named the wrong type.

24 tests pass (was 23); full pipeline suite green.
operation_result_id routed previous_value_digest through
hash_optional_id, which prepends a discriminant tag for both Some
and None. This silently changed EchoOperationResultIdV1 (and
everything chained from it -- preparation_id, receipt identities)
for the update path too, not only the new create path, contradicting
this branch's own "byte-for-byte unchanged" claims. A prior commit
corrected the ADR's wording to document this honestly rather than
overclaim; this commit fixes it for real instead, per Codex's
automated review on PR #686 and my own self-review's finding #1.

Some(digest) now hashes exactly digest -- the same raw 32 bytes the
pre-ADR-0024 code always wrote, no tag -- so the update path's
result identity is truly unchanged, not merely behaviorally
equivalent. None uses a new domain-separated marker
(RESULT_ID_ABSENT_PREVIOUS_VALUE_DOMAIN) whose byte length differs
from every possible 32-byte digest, so it cannot collide with
Some(digest) for any digest value -- unlike
current_application_basis's Option<Hash> field (which needed
hash_optional_id's shared tag scheme because that field's encoding
is otherwise fixed-width), this field's own two encodings already
differ in length, so no tag is needed here.

RED: operation_result_id_preserves_the_legacy_hash_for_updates (new
unit test in echo_operation.rs's own mod tests) asserted Some(...)
matches a hand-reconstructed reference hash and failed against the
tagged encoding. GREEN: same test passes after the fix. Updated ADR
0024's Verification Evidence Grade and Consequences sections to state
the digests are unchanged, not merely judged acceptable to differ.
Full warp-core suite (81 binaries, 687 library tests, doctests)
green; clippy identical pre-existing error set.
@flyingrobots

Copy link
Copy Markdown
Owner Author

Code Lawyer: Activity Summary

All 5 review-thread findings addressed, RED->GREEN->COMMIT per issue, one commit each.

# Severity Source File Commit Outcome
1 P0 Codex trusted_runtime_host.rs (operation_patch_scope_v1) eadf13b48 Fixed -- WAL recovery now recognizes the two-op create-from-absence patch shape
2 P0 CodeRabbit + Codex echo_operation.rs (current_application_basis + prepare_operation_v1) 361dae121 Fixed -- both admission and evaluation now independently refuse against an orphaned attachment
3 P2 Codex echo_operation.rs (create write-budget charge) 658daecb6 Fixed -- node record's 32 bytes now counted
4 P2 Codex echo_operation.rs (Some(record) arm ordering) c2e438b61 Fixed -- every occupied create target now reports PreconditionMismatch uniformly
5 P2 Codex + self-review echo_operation.rs (operation_result_id) 387b7bffd Fixed for real (not just documented) -- update path's result identity is byte-identical to pre-PR code

What each fix actually proved wrong, briefly

  • feat/rmg core bootstrap #1 was the sharpest: my own test suite never caught it because none of my tests exercised the WAL-enabled commit path for create-from-absence specifically. Once added, the bug reproduced at the original commit, not just later recovery -- worse than the initial report suggested.
  • feat/rewrite executor spike #2 required two sequential fixes, not one: fixing admission alone made the evaluation-layer test's premise (an "honest" basis reaching evaluation) newly reachable, which is exactly why they had to land in that order and why one test's RED depended on the other's GREEN already existing.
  • core: split math module into focused submodules #5 started as a documentation-only fix in my self-review pass, then got upgraded to a real code fix once Codex's independent finding converged on the same root cause and pushed for it.

Net test delta

16 -> 24 tests in executable_operation_pipeline_tests.rs, +1 unit test in echo_operation.rs's own mod tests. Full warp-core suite (81 binaries, 687 library tests, doctests) green throughout; clippy identical pre-existing error set at every commit, independently verified against a clean origin/main worktree by exact file:line location.

All 6 review threads resolved. @codex, @coderabbitai -- re-review requested.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@flyingrobots Re-review requested. I’ll validate the corrected execution paths, deterministic error behavior, budget accounting, WAL recovery shape, and update-path result-identity compatibility.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 387b7bffd7

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

Comment thread CHANGELOG.md Outdated
Comment thread docs/adr/0024-anchored-node-creation-from-absence.md Outdated
Comment thread crates/warp-core/src/echo_operation.rs Outdated
Comment thread crates/warp-core/src/trusted_runtime_host.rs Outdated
@flyingrobots flyingrobots changed the title feat(warp-core): admit anchored-node creation from absence feat(warp-core): add anchored-node create-if-absent program Jul 24, 2026
@flyingrobots

Copy link
Copy Markdown
Owner Author

Code Lawyer self-audit findings

The current head fixes the previously reported compatibility, occupancy, budget, obstruction, identity, and restart-recovery defects. A fresh origin/main...HEAD audit found two additional issues:

ID Severity File Finding Required disposition
S1 P1 crates/warp-core/src/trusted_runtime_host.rs operation_patch_scope_v1 selects the recovered operation count/slots by target profile, but accepts arbitrary NodeRecord.ty, arbitrary attachment value/type, and payloads beyond the installed program bound. A self-consistent WAL consequence can therefore replay a different program than the installed create/update meaning. RED with program-semantic mutation vectors; validate the recovered consequence against the exact installed program.
S2 P4 docs/adr/README.md The ADR index still describes ADR 0024 as “compare-and-set from absence,” contradicting the ADR decision that creation is a separate executable program. Correct the index vocabulary and run the documentation gates.

I will repair these one at a time with separate RED → GREEN → VERIFY → commit cycles, then resolve only the older threads whose claims are demonstrably satisfied by the current head.

@codex second opinion requested on S1 in particular: recovery must bind more than the two-operation silhouette.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

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

@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: cbab1b74f0

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

Comment thread crates/warp-core/src/trusted_runtime_host.rs Outdated
Comment thread docs/adr/README.md Outdated
@flyingrobots

Copy link
Copy Markdown
Owner Author

Code Lawyer Activity Summary

Audited origin/main...ebee7cf5c under a clean-worktree RED → GREEN → VERIFY discipline. Every inherited review thread and both self-discovered defects were verified against the current code before resolution.

# Source Severity Surface Issue Repair / evidence Outcome
1 PR P2 echo_operation.rs Create and update step budgets were conflated 44bd6e915 keeps create at 3 semantic steps and update at 4; boundary tests pass Resolved
2 PR P4 ADR 0024 Evidence/test counts were stale cbab1b74f narrows and refreshes the accepted evidence Resolved
3 PR P1 Program/profile identity /v1 compare-and-set semantics were widened by optional absence 44bd6e915 restores update-only bytes and adds a distinct create-if-absent program/profile Resolved
4 PR P1 Create obstruction Occupied targets could report type/attachment errors c2e438b61 classifies every occupied create target as PreconditionMismatch Resolved
5 PR P1 Write budget Creation omitted the node-type charge 658daecb6 charges exactly 64 + payload_len; exact and one-byte-short tests pass Resolved
6 PR P1 Admission/evaluation Orphan attachments were treated as total absence 361dae121 reads node and attachment independently and refuses every partial/occupied state Resolved
7 PR P3 ADR 0024 Obstruction prose disagreed with runtime semantics cbab1b74f records the closed occupancy rule Resolved
8 PR P2 Legacy update path Missing update state had to remain rejected 44bd6e915 preserves the update-only profile and missing-state refusal Resolved
9 PR P0 Filesystem WAL recovery Creation’s two-operation consequence was not recoverable eadf13b48 recognizes the exact create shape; restart and mutated-WAL tests pass Resolved
10 Self / Codex P1 trusted_runtime_host.rs Recovery checked only target-profile silhouette, not installed-program semantics 26f330eb4 validates exact node/atom types, atom algebra, payload bound, operation order, and slots against the recovered installation Resolved
11 Self / Codex P4 docs/adr/README.md ADR index called the separate creation program “compare-and-set from absence” ebee7cf5c names the accepted separate-program boundary accurately Resolved

Validation

  • cargo test -p warp-core --features native_rule_bootstrap,trusted_runtime,host_test: 689 library tests passed, all integration targets passed, 27 doctests passed / 6 ignored.
  • cargo test -p warp-core --features native_rule_bootstrap,trusted_runtime,host_test --test executable_operation_pipeline_tests: 24/24 passed.
  • cargo clippy -p warp-core --features native_rule_bootstrap,trusted_runtime,host_test --lib -- -D warnings: passed.
  • cargo fmt --all -- --check: passed.
  • tests/docs/test_adr_namespace.sh: passed.
  • git diff --check: passed.
  • Pre-push hook suite: passed.
  • Review threads: 17/17 resolved; 0 unresolved.

Scope judgment

This PR now establishes an exact, durable single anchored node plus alpha attachment creation primitive. It does not claim real Edict compiler emission, scheduler/Action batch integration, atomic multi-record Graft creation, or completion of the Graft migration corridor.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/architecture/application-contract-hosting.md`:
- Around line 151-156: Narrow the recovery-validation claim in the architecture
documentation to match the checks currently enforced, removing assertions that
WAL recovery validates exact node/attachment types or payload-size limits.
Retain only the documented guarantees that are actually implemented until the S1
recovery validation gap is fixed.

In `@docs/topics/GeneratedRules.md`:
- Around line 183-187: Update the wording in the documented self-validation
scope to exclude Graft-style or general multi-record mutation and scheduler
batching, while acknowledging that the create-if-absent program intentionally
writes one node and one alpha attachment. Preserve the surrounding claims about
deterministic validation and avoid excluding multi-record creation itself.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 444d1027-09e1-4f1b-8c8d-903d7ca8d44f

📥 Commits

Reviewing files that changed from the base of the PR and between 3b61778 and ebee7cf.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • README.md
  • crates/warp-core/src/echo_operation.rs
  • crates/warp-core/src/lib.rs
  • crates/warp-core/src/trusted_runtime_host.rs
  • crates/warp-core/tests/executable_operation_pipeline_tests.rs
  • docs/adr/0024-anchored-node-creation-from-absence.md
  • docs/adr/README.md
  • docs/architecture/application-contract-hosting.md
  • docs/topics/GeneratedRules.md

Comment thread docs/architecture/application-contract-hosting.md
Comment thread docs/topics/GeneratedRules.md Outdated
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.

Executable-operation corridor: anchored-node creation from absence

1 participant