Skip to content

Require posture on strand creation#544

Open
flyingrobots wants to merge 6 commits into
mainfrom
cycle/538-strand-creation-posture
Open

Require posture on strand creation#544
flyingrobots wants to merge 6 commits into
mainfrom
cycle/538-strand-creation-posture

Conversation

@flyingrobots

@flyingrobots flyingrobots commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Thread RetentionPosture through ForkStrandRequest, ForkStrandReceipt, and Strand so strand creation is posture-explicit.
  • Add named session/default and debugger fork constructors; debugger-created strands clamp to AuthorOnly and never silently enter Shared history.
  • Revalidate strand posture at StrandRegistry::insert and hash posture obstructions deterministically for scheduler fault evidence.
  • Update strand, neighborhood, observation, and settlement fixtures to construct explicit posture.

Refs #538.

Validation

  • cargo check -p warp-core
  • cargo test -p warp-core --lib
  • cargo test -p warp-core --test strand_contract_tests
  • cargo clippy -p warp-core --lib -- -D warnings -D missing_docs
  • cargo fmt --all -- --check
  • git diff --check
  • scripts/check-causal-posture-constructors.sh
  • scripts/ban-nondeterminism.sh
  • pnpm exec markdownlint-cli2 CHANGELOG.md
  • pre-push hook exact Rust slices passed on push

Summary by CodeRabbit

Release Notes

New Features

  • Explicit retention posture is now carried through strand fork operations and registrations.

Changed

  • Settlement planning now validates strand posture coherence and rejects non-shared strands before processing.
  • Strand posture information is preserved in settlement artifacts instead of forcing default postures.

Bug Fixes

  • Fixed non-shared strand rejection error mapping to use the stable INVALID_STRAND code.
  • Debugger-created forks no longer silently adopt unintended posture defaults.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

RetentionPosture is added as an explicit field on Strand with registry-level coherence validation producing StrandError::Posture. SessionContext gains retention_posture() and debugger_retention_posture() constructors. Settlement planning gates on Shared posture via a new SettlementError::NonSharedStrand variant, and braid-shell/plural artifact construction threads the strand's actual posture instead of hard-coding AuthorOnly. The WASM layer maps NonSharedStrand to INVALID_STRAND.

Changes

RetentionPosture enforcement across strand lifecycle

Layer / File(s) Summary
RetentionPosture/Strand contracts and validation
crates/warp-core/src/revelation.rs, crates/warp-core/src/strand.rs
RetentionPosture::validate() added; SessionContext gains retention_posture() and debugger_retention_posture(); Strand gains retention_posture field; StrandError::Posture variant added; StrandRegistry::insert validates posture on insertion.
ForkStrandRequest/Receipt posture plumbing and fault hashing
crates/warp-core/src/coordinator.rs
ForkStrandRequest and ForkStrandReceipt gain retention_posture; from_session_default and debugger_default derive it from SessionContext; hash_strand_error and new helper hashers cover StrandError::Posture and PostureObstruction variants deterministically.
Settlement planning gate and posture propagation
crates/warp-core/src/settlement.rs
SettlementError::NonSharedStrand added; plan_with_policy gates on Shared posture early; build_braid_shell and plural_draft accept and use the strand's causal posture instead of hard-coded AuthorOnly.
WASM ABI error mapping
crates/warp-wasm/src/warp_kernel.rs, crates/warp-wasm/src/lib.rs
map_settlement_error maps NonSharedStrand to INVALID_STRAND; StubKernel::settle_strand stub extended with appended_plurals and braid_shell_digest.
Coordinator fork posture tests
crates/warp-core/src/coordinator.rs
Test helpers test_session_context/test_retention_posture added; existing fork tests supply retention_posture; new tests verify session-default and debugger-default posture propagation.
Settlement posture tests
crates/warp-core/src/settlement.rs
Shared/AuthorOnly posture test helpers and setup_runtime_with_strand_posture added; new test asserts AuthorOnly strand is rejected; plural/braid-shell assertions updated to expect CausalPosture::Shared.
WASM ABI posture regression test
crates/warp-wasm/src/warp_kernel.rs
shared_retention_posture/author_only_retention_posture helpers and setup_runtime_with_strand_posture added; regression test asserts plan_settlement and settle_strand both return INVALID_STRAND for AuthorOnly strands.
Strand contract tests
crates/warp-core/tests/strand_contract_tests.rs
test_retention_posture helper added; wired into all Strand literals; new registry test asserts Shared without admission_scope yields MissingAdmissionScope.
Neighborhood/observation test fixtures
crates/warp-core/src/neighborhood.rs, crates/warp-core/src/observation.rs
test_retention_posture helpers and retention_posture field wired into Strand literals in publication and observation fixture tests.
CHANGELOG
CHANGELOG.md
Unreleased entries documenting posture enforcement on strand creation, settlement gate, artifact posture propagation, and INVALID_STRAND ABI fix.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ForkStrandRequest
  participant WorldlineRuntime
  participant StrandRegistry
  participant SettlementService

  Client->>ForkStrandRequest: from_session_default(session_ctx) / debugger_default(session_ctx)
  ForkStrandRequest->>ForkStrandRequest: derive retention_posture from SessionContext
  Client->>WorldlineRuntime: fork_strand(request)
  WorldlineRuntime->>StrandRegistry: insert(Strand { retention_posture })
  StrandRegistry->>StrandRegistry: retention_posture.validate()
  StrandRegistry-->>WorldlineRuntime: Ok / StrandError::Posture
  WorldlineRuntime-->>Client: ForkStrandReceipt { retention_posture }

  Client->>SettlementService: plan_with_policy(strand)
  SettlementService->>SettlementService: check causal_posture == Shared
  alt posture is not Shared
    SettlementService-->>Client: SettlementError::NonSharedStrand
  else posture is Shared
    SettlementService->>SettlementService: build_braid_shell(strand_posture)
    SettlementService->>SettlementService: plural_draft(strand_posture)
    SettlementService-->>Client: SettlementPlan
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • flyingrobots/echo#315: Introduced the Strand/StrandRegistry structures that this PR extends with the retention_posture field and registry-level posture validation.
  • flyingrobots/echo#542: Migrated settlement braid-shell/plural artifact posture to CausalPosture; this PR extends that work by gating planning on Shared and persisting the strand's actual posture into artifacts.

Poem

The posture must be Shared to settle down,
No AuthorOnly sneaks past the registry crown.
Each fork now carries its derivation sealed,
DebuggerDefault stays author-only, revealed.
INVALID_STRAND returns where ENGINE_ERROR would hide —
Coherence enforced, no silent posture slide. 🔒

🚥 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 directly describes the main change: explicit RetentionPosture is now required and threaded through strand creation APIs (ForkStrandRequest, ForkStrandReceipt, Strand).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cycle/538-strand-creation-posture

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 and usage tips.

@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: 1eacd3876d

ℹ️ 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/settlement.rs Outdated
Comment thread crates/warp-core/src/revelation.rs Outdated
Comment thread crates/warp-core/src/strand.rs
@flyingrobots

Copy link
Copy Markdown
Owner Author
Severity Source File Lines Issue Mitigation
P1 PR/Self crates/warp-core/src/settlement.rs 682-833 Settlement planning still imports non-Shared strand suffixes, so AuthorOnly debugger/session work can enter base shared history without admission. Add a regression proving AuthorOnly settlement is rejected; require Shared posture before planning imports; make import-settlement fixtures explicitly Shared.
P2 PR/Self crates/warp-core/src/revelation.rs 383-389 SessionContext::retention_posture accepts arbitrary PostureDerivation, allowing fresh session-created work to masquerade as debugger or legacy migration work. Remove the derivation parameter; stamp PostureDerivation::SessionDefault inside the helper; keep debugger/migration derivations in named paths only.
P2 PR/Self crates/warp-core/src/settlement.rs 927-1376 Settlement shell construction discards strand posture and hard-codes shell/member posture as AuthorOnly, corrupting retained shell posture for legitimately shared strands. Thread the settled strand posture into build_braid_shell; assert shared settlement shells record Shared.

@codex please confirm these are the complete actionable issues for this pass.

@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: 1eacd3876d

ℹ️ 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/settlement.rs Outdated
Comment thread crates/warp-core/src/revelation.rs Outdated
Comment thread crates/warp-core/src/coordinator.rs Outdated
Comment thread crates/warp-core/src/strand.rs
Comment thread crates/warp-core/src/strand.rs
@flyingrobots

Copy link
Copy Markdown
Owner Author

@codex Self-discovered issue during P1 warp-wasm RED verification.

Severity Source File Lines Issue Mitigation
P1 Self crates/warp-wasm/src/lib.rs ~1258 cargo test -p warp-wasm --features engine fails because the engine-feature test SettlementResult literal omits the now-required appended_plurals and braid_shell_digest fields. Update the test literal to include empty plural refs and no braid-shell digest, then verify cargo test -p warp-wasm --features engine.

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

  • Added the missing SettlementResult fields for the warp-wasm settlement stub: empty appended_plurals and None for braid_shell_digest. crates/warp-wasm/src/lib.rsL1258-L1268
  • Added an explicit shared retention-posture helper for warp-wasm settlement fixtures, including authority, derivation, contract, and admission scope. crates/warp-wasm/src/warp_kernel.rsL1407-L1426
  • Updated both warp-wasm engine settlement Strand literals to use the shared posture helper, keeping import-settlement fixtures lawful after the non-Shared settlement gate. crates/warp-wasm/src/warp_kernel.rsL1494-L1504 crates/warp-wasm/src/warp_kernel.rsL1556-L1566
  • Committed the changes on the current branch with commit d66918a Fix warp-wasm settlement fixtures.
  • Created a PR via the make_pr tool titled Fix warp-wasm settlement fixture posture fields.
  • Left the pre-existing uncommitted pnpm-lock.yaml change untouched.

Testing

  • cargo test -p warp-wasm --features engine
  • cargo check -p warp-wasm --features engine
  • git diff --check

View task →

@flyingrobots

Copy link
Copy Markdown
Owner Author

Activity Summary

@codex Review repair pass completed for the posture-on-strand-creation PR.

Item Severity Source Files Commit Outcome
1 P1 PR crates/warp-core/src/settlement.rs 03a8f01c Non-Shared strands are rejected before settlement planning/import; AuthorOnly regression added.
2 P2 PR crates/warp-core/src/revelation.rs, crates/warp-core/src/coordinator.rs 2164cc4c SessionContext::retention_posture() stamps PostureDerivation::SessionDefault; callers cannot select migration/debugger derivations.
3 P2 PR crates/warp-core/src/settlement.rs dea53815 Settlement plural artifacts, braid-shell members, and retained shells carry the source strand posture instead of hard-coded AuthorOnly.
4 P1 PR + Self crates/warp-wasm/src/warp_kernel.rs, crates/warp-wasm/src/lib.rs 334648cd warp-wasm --features engine test fixtures include explicit Shared strand posture and updated ABI settlement-result fields.

Resolved review threads: PRRT_kwDOQH8Wr86JWgtl, PRRT_kwDOQH8Wr86JWgtm, PRRT_kwDOQH8Wr86JWgtn, PRRT_kwDOQH8Wr86JXZaa, PRRT_kwDOQH8Wr86JXZab, PRRT_kwDOQH8Wr86JXZac, PRRT_kwDOQH8Wr86JXZad, PRRT_kwDOQH8Wr86JXZae.

Local witnesses:

  • cargo test -p warp-core --lib → 541 passed
  • cargo test -p warp-core --test strand_contract_tests → 27 passed
  • cargo test -p warp-core --lib settlement::tests → 20 passed
  • cargo test -p warp-wasm → 4 passed
  • cargo test -p warp-wasm --features engine → 54 passed
  • cargo fmt --all -- --check
  • git diff --check
  • scripts/check-causal-posture-constructors.sh
  • scripts/ban-nondeterminism.sh
  • pnpm exec markdownlint-cli2 CHANGELOG.md

Pre-push witnesses passed on final head 334648cd, including default warp-wasm and engine-feature warp_kernel::tests. Remote CI is still in progress at the time of this comment; merge gate remains locked until checks finish and the approval requirement is satisfied.

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

Testing / Checks

  • pwd && find .. -name AGENTS.md -print && git status --short && git log -n 5 --oneline
  • sed -n '1,220p' docs/BEARING.md
  • sed -n '1,220p' METHOD.md
  • ⚠️ find backlog/asap -maxdepth 2 -type f -print | sort | head -100 — warning only because backlog/asap does not exist in this checkout; METHOD.md says live backlog has moved to GitHub Issues.
  • rg -n "retention_posture|build_braid_shell|appended_plurals|braid_shell_digest|NonShared|Shared" crates/warp-core/src/settlement.rs crates/warp-core/src/revelation.rs crates/warp-core/src/coordinator.rs crates/warp-wasm/src/lib.rs crates/warp-wasm/src/warp_kernel.rs | head -120
  • nl -ba crates/warp-core/src/settlement.rs | sed -n '682,700p;965,985p'
  • nl -ba crates/warp-core/src/revelation.rs | sed -n '383,400p'
  • nl -ba crates/warp-wasm/src/warp_kernel.rs | sed -n '1214,1228p;1498,1506p;1560,1568p'
  • nl -ba crates/warp-wasm/src/lib.rs | sed -n '1260,1268p'
  • nl -ba crates/warp-core/src/settlement.rs | sed -n '930,958p;1270,1305p;1370,1385p'
  • nl -ba crates/warp-core/src/settlement.rs | sed -n '1306,1325p;1384,1398p'

View task →

@flyingrobots

Copy link
Copy Markdown
Owner Author

@codex please confirm this self-review finding.

Self-Code Review Findings

Severity File / Lines Type Issue Recommended mitigation
P2 crates/warp-core/src/settlement.rs:555, crates/warp-core/src/settlement.rs:696; crates/warp-wasm/src/warp_kernel.rs:420 Public ABI error classification The branch adds SettlementError::NonSharedStrand as a lawful posture/admission rejection for non-Shared strands, but the WASM boundary maps every settlement error except StrandNotFound to ENGINE_ERROR. KernelPort callers of plan_settlement / settle_strand would see a policy denial as an internal engine fault instead of a stable invalid/admission rejection. Add a regression test through WarpKernel::plan_settlement or settle_strand for an AuthorOnly strand and map SettlementError::NonSharedStrand to a stable non-engine ABI code, either INVALID_STRAND with a posture-specific message or a new posture/admission-specific code if the ABI is allowed to grow.

No P0/P1 findings were found in this self-review. Remote CI is green at the time of review, and the worktree was clean before fetch/review.

@flyingrobots

Copy link
Copy Markdown
Owner Author

Resolved the self-review P2 in 0c7ca74e (Fix: map non-shared settlement ABI errors).

What changed:

  • SettlementError::NonSharedStrand now maps to stable INVALID_STRAND at the WASM KernelPort boundary instead of falling through to ENGINE_ERROR.
  • Added an engine-feature regression for AuthorOnly settlement through WarpKernel::plan_settlement and settle_strand.
  • Recorded the public-boundary behavior fix in CHANGELOG.md.

Local witnesses:

  • cargo test -p warp-wasm --features engine settlement_publication_rejects_author_only_strand_as_invalid_strand
  • cargo test -p warp-wasm --features engine
  • cargo clippy -p warp-wasm --features engine -- -D warnings
  • scripts/check-causal-posture-constructors.sh
  • cargo fmt --all -- --check
  • git diff --check
  • pnpm exec markdownlint-cli2 CHANGELOG.md
  • pre-push exact slice: cargo test -p warp-wasm --features engine --lib warp_kernel::tests

@codex self-review finding is addressed; please confirm.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 0c7ca74ef2

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

@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-wasm/src/warp_kernel.rs`:
- Around line 426-431: The SettlementError::NonSharedStrand case in the
warp_kernel.rs file is incorrectly using the error_codes::INVALID_STRAND code,
which is documented as "requested strand is not registered" in the ABI contract.
However, this case represents a different error condition where the strand
exists but settlement is forbidden by its posture policy. Either create a new
dedicated error code constant for settlement-policy rejection and use it in the
NonSharedStrand match arm, or coordinate with the team to intentionally broaden
the ABI contract definition for code 14 and update all downstream callers and
documentation accordingly. Do not leave the meaning of the error code ambiguous
on the wire.
🪄 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

Run ID: 61466ee0-086f-4459-b6c1-611aa718e135

📥 Commits

Reviewing files that changed from the base of the PR and between cfccf67 and 0c7ca74.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • crates/warp-core/src/coordinator.rs
  • crates/warp-core/src/neighborhood.rs
  • crates/warp-core/src/observation.rs
  • crates/warp-core/src/revelation.rs
  • crates/warp-core/src/settlement.rs
  • crates/warp-core/src/strand.rs
  • crates/warp-core/tests/strand_contract_tests.rs
  • crates/warp-wasm/src/lib.rs
  • crates/warp-wasm/src/warp_kernel.rs

Comment on lines +426 to +431
SettlementError::NonSharedStrand { strand_id, posture } => AbiError {
code: error_codes::INVALID_STRAND,
message: format!(
"strand {strand_id:?} with posture {posture:?} is not shared-admitted for settlement"
),
},

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.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Don’t overload INVALID_STRAND for admission-policy rejection.

INVALID_STRAND is still documented as “requested strand is not registered” in the ABI contract. Reusing code 14 for NonSharedStrand changes the machine-readable meaning on the wire and makes “strand missing” indistinguishable from “strand exists but settlement is forbidden by posture policy”. Either add a dedicated ABI code for settlement-policy rejection, or update the ABI/spec contract and downstream callers in the same change if code 14 is being broadened intentionally.

🤖 Prompt for 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.

In `@crates/warp-wasm/src/warp_kernel.rs` around lines 426 - 431, The
SettlementError::NonSharedStrand case in the warp_kernel.rs file is incorrectly
using the error_codes::INVALID_STRAND code, which is documented as "requested
strand is not registered" in the ABI contract. However, this case represents a
different error condition where the strand exists but settlement is forbidden by
its posture policy. Either create a new dedicated error code constant for
settlement-policy rejection and use it in the NonSharedStrand match arm, or
coordinate with the team to intentionally broaden the ABI contract definition
for code 14 and update all downstream callers and documentation accordingly. Do
not leave the meaning of the error code ambiguous on the wire.

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