Skip to content

feat(review): clause-level 061 adapter with per-clause subject profile - #292

Merged
brianluby merged 2 commits into
mainfrom
feat/f12-f13-deferred
Nov 14, 2026
Merged

brianluby merged 2 commits into
mainfrom
feat/f12-f13-deferred

Conversation

@brianluby

Copy link
Copy Markdown
Collaborator

Re-opened from #289 (auto-closed when its stacked base feat/f12-f13-m10-adapters was deleted on #288 merge). Rebased onto current main; M-10 is already merged.

Clause-level 061 adapter: each captured human clause becomes one reviewable subject bound to its exact original raw identity, borrowing from the genuine sealed CurrentAuthoringPlanClosure (hash_v3 profile8 clause_subject). Tampered-original refusal, selection-order/membership enforcement.

CodeRabbit findings remediated: O(n²)->BTreeMap key->ordinal lookup, explicit ledger digest charge, accurate BTreeMap-order comment.

Verification: 598 review tests + 4 clause tests green; full suite green; fmt/clippy clean.

Each captured human clause becomes one reviewable subject bound to its exact
original raw identity, borrowing from the genuine sealed CurrentAuthoringPlanClosure.

- hash_v3 profile8 clause_subject: domain-separated per-clause fingerprint over
  the clause key, exact original digest and extent (independent byte oracle).
- adapters::authoring_clause: prepare() re-verifies each selected clause's exact
  original against its sealed member; a tampered clause original refuses.
  bind_queue() binds every clause subject to its own sealed ordinal source pin.
- CurrentAuthoringPlanClosure::clause_members() borrows each sealed clause's
  native key and complete original digest.
- Consumed in authoring_binding::prepare (retained) and authoring_finalize
  (bind_queue), mirroring the /1 mapping/applicability adapter pattern.

The /3 whole-plan queue shape and all existing zero-edit/quorum/dissent/M-10
contracts are unchanged. 4 new clause tests; 598 review tests green.
… charge

CodeRabbit findings on PR #289 (clause-061 adapter):
- bind_queue precomputes a BTreeMap of clause key -> declaration ordinal
  once, replacing the per-fact O(n) position() scan (O(n^2) at 10k
  clauses) with O(log n) lookups; first-wins ordinal, unknown-key refusal
  and derived storage charge preserved.
- Replace the misleading chain::compare() call with an explicit
  ledger.bytes() charge of both complete digest extents (same accounting,
  no discarded lexical comparison).
- Correct clause_subjects comment: keys iterate in lexicographic BTreeMap
  key order, not native declaration order.
Copilot AI balanced review requested due to automatic review settings November 14, 2026 23:44
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: f63c7879-9b77-46e3-8cbd-489926342b7a
Commits

Reviewing files that changed from the base of the PR and between d28baf0 and beedea9.

Files selected for processing: 9

  • src/review/adapters/authoring_clause.rs
  • src/review/adapters/authoring_clause_tests.rs
  • src/review/adapters/mod.rs
  • src/review/authoring_binding.rs
  • src/review/authoring_capture.rs
  • src/review/authoring_capture_tests.rs
  • src/review/authoring_finalize.rs
  • src/review/hash_v3.rs
  • src/review/hash_v3_tests.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@brianluby
brianluby merged commit ab90138 into main Nov 14, 2026
20 of 23 checks passed
@brianluby
brianluby deleted the feat/f12-f13-deferred branch November 14, 2026 23:45

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues
What changed in this PR

Adds a clause-level (profile8) “061 adapter” so each captured human clause becomes its own reviewable subject bound to the exact sealed original identity, with ordering/membership enforcement and tamper refusal.

Changes:

  • Introduces hash_v3::clause_subject (profile8) plus an independent oracle-style unit test.
  • Adds adapters::authoring_clause to derive per-clause review facts from CurrentAuthoringPlanClosure and bind them to queue HumanClause pins.
  • Wires clause binding into authoring finalize flow and adds dedicated adapter tests.
File Description
src/​review/​hash_v3.rs Adds profile8 per-clause subject digest function.
src/​review/​hash_v3_tests.rs Adds oracle-based test coverage for clause subject hashing and validation.
src/​review/​authoring_finalize.rs Ensures clause subjects are bound to queue pins before issuance.
src/​review/​authoring_capture.rs Exposes clause member (key, raw_sha256) projection from sealed closure.
src/​review/​authoring_binding.rs Prepares/stashes per-clause review facts as part of pending binding.
src/​review/​adapters/​mod.rs Registers the new authoring_clause adapter module.
src/​review/​adapters/​authoring_clause.rs Implements per-clause re-review fact preparation and queue pin binding.
src/​review/​adapters/​authoring_clause_tests.rs Adds tests for correct binding, tamper refusal, and selection enforcement.
src/​review/​authoring_capture_tests.rs Wires the new adapter tests into the test suite.

Review effort: Lite

Comment thread src/review/hash_v3.rs
Comment on lines +846 to +858
pub(crate) fn clause_subject(
clause_key: &str,
raw_sha256: &str,
byte_length: u64,
ledger: &mut ContractLedger,
control: &mut dyn WorkControl,
) -> Result<String, ContractError> {
phase(ledger, control, |ledger, control| {
key(clause_key, ledger)?;
hash_operand(raw_sha256, ledger)?;
if byte_length == 0 || byte_length > 1_048_576 {
return Err(ContractError::Invalid);
}
let pins: Vec<_> =
queue.source_pins.iter().filter(|pin| pin.kind == SourceKindV3::HumanClause).collect();
ledger.visits(pins.len())?;
if pins.len() != self.complete_clauses() || pins.len() != self.facts().len() {
Comment on lines +108 to +116
for fact in self.facts() {
ledger.visits(1)?;
let ordinal = declared.get(fact.subject_id()).ok_or(ContractError::Binding)?;
let expected = format!("authoring:clause:{ordinal}");
ledger.derived(expected.len())?;
let pin = pins
.iter()
.find(|pin| pin.artifact_key == expected)
.ok_or(ContractError::Binding)?;
Comment thread src/review/hash_v3.rs
Comment on lines +856 to +858
if byte_length == 0 || byte_length > 1_048_576 {
return Err(ContractError::Invalid);
}
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