Skip to content

Validate strict weslaw bindings#534

Merged
flyingrobots merged 9 commits into
mainfrom
weslaw-strict-binding
May 26, 2026
Merged

Validate strict weslaw bindings#534
flyingrobots merged 9 commits into
mainfrom
weslaw-strict-binding

Conversation

@flyingrobots
Copy link
Copy Markdown
Owner

@flyingrobots flyingrobots commented May 25, 2026

Summary

  • add strict schema-hash and subject binding for active weslaw/v1 Law IR
  • validate variant, footprint, channel, invariant, and footprint-resource references against Shape IR, operations, and law registries
  • expose wesley law validate, lint, diff, explain, rebind, capabilities, and coverage
  • close the WLAW v1 runway at 75 / 75 slices, including Rust law-backed validators, report-only capability summaries, coverage reports, and v1 closeout docs

Validation

  • cargo test -p wesley-core --test law_ir
  • cargo test -p wesley-cli --test cli
  • BATS_LIB_PATH=test/bats-plugins bats -t test/weslaw-fixtures.bats
  • pnpm run legacy-preflight
  • pnpm run preflight
  • git diff --check
  • pre-push Rust product preflight and Bats smoke suite

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

📝 Walkthrough

Walkthrough

Adds strict weslaw binding and semantic canonical hashing, contract-bundle manifest and law-diff artifacts, CLI init-law/law subcommands and --law emit integration, Rust validator emission, expanded tests/fixtures, JSON Schemas, and documentation updates.

Changes

Law binding, hashing, and contract bundle manifest

Layer / File(s) Summary
CLI surface, option parsing, and law commands
crates/wesley-cli/src/main.rs
New init-law and law subcommands (validate, lint, diff, explain, rebind, capabilities, coverage), --law option parsing restricted to supported commands, CLI JSON/text report structs, CliError::Law(WeslawError) and From<WeslawError> for CliError, help text and output format handling.
Wesley core: binding, canonicalization, and hashing
crates/wesley-core/src/domain/law.rs
Adds strict binding validation (validate_law_ir_v1_bindings and BindingContext), lowering bridge for @wes_channel, semantic-canonical Law IR JSON (to_semantic_law_ir_json), law/document hash computation (compute_law_hash_v1, compute_law_hash_set_v1), and contract-bundle manifest builder (build_contract_bundle_manifest_v1) with new diagnostic codes and exported report/diff types.
Semantic diff, diff schema, and canonical helpers
crates/wesley-core/src/domain/law.rs, schemas/wesley-law-diff-v1.schema.json
Implements semantic diff_law_ir_v1, law-diff event/report types, Markdown/JSON renderers, deterministic ordering and canonicalization helpers used by hashing and diffs, and publishes wesley.law-diff/v1 JSON Schema.
Emit integration and Rust validator emission
crates/wesley-cli/src/main.rs, crates/wesley-emit-rust/src/lib.rs
Emit commands accept optional --law; CLI loads law, builds contract-bundle manifest, and passes manifest into metadata writer. Rust emitter gained emit_rust_with_operations_and_hashes/emit_rust_with_operations_and_law, emits WESLEY_SCHEMA_HASH/WESLAW_HASH constants and generated validate_* helper functions derived from law IR.
Tests, fixtures, and CLI test coverage
crates/wesley-core/tests/law_ir.rs, crates/wesley-cli/tests/cli.rs, test/fixtures/weslaw/*
Expanded tests for semantic hashing (excludes rationale, default materialization, message-order sensitivity), manifest building and schema validation, many law-diff scenarios and binding-error cases, CLI law command integration tests, emit tests asserting embedded hash constants and generated validators, and new/updated fixture artifacts and CI diff fixtures.
Documentation, schemas, and project docs
CHANGELOG.md, README.md, docs/*, schemas/wesley-contract-bundle-manifest-v1.schema.json, schemas/wesley-law-diff-v1.schema.json, test/weslaw-fixtures.bats
Adds wesley.contract-bundle-manifest/v1 JSON Schema, documents strict binding, contract-bundle manifest/hash fields (schemaHashQualified, schemaHash, lawHash, lawDocumentHash, profileHash, bundleHash), updates CLI docs and end-to-end flows, updates BEARING/fixture README, and adds canonical-schema checks to fixtures tests.

Sequence Diagrams

sequenceDiagram
  participant CLI as Wesley CLI
  participant Core as wesley-core
  participant Emitter as wesley-emit-rust
  participant FS as Filesystem

  CLI->>Core: load schema + law, lower to IR, validate bindings, build contract-bundle manifest
  Core-->>CLI: manifest + hashes (schema/law/document/profile/bundle)
  CLI->>Emitter: emit request with manifest and IR
  Emitter->>FS: write generated Rust with WESLEY_SCHEMA_HASH / WESLAW_HASH and validators
  CLI->>FS: write metadata sidecar with manifest and law_ir_codec
Loading

Estimated code review effort:
🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested labels:
feature, enhancement

🐰 A law binds swift and strong,
With hashes woven all along,
Schema, semantics, truth combined,
In contracts manifested, refined.
Wesley's laws now codified!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 39.36% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Validate strict weslaw bindings' clearly and concisely summarizes the main objective of the changeset: adding strict schema-hash and subject binding validation for weslaw/v1 Law IR.
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.
Description check ✅ Passed PR description clearly states objectives, validation steps, and includes comprehensive self-review with resolutions addressing schema binding, subject validation, CLI exposure, and v1 closeout.

✏️ 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 weslaw-strict-binding

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 25, 2026

🔍 The Case of Pull Request #534

Plain-English Readout

  • Holmes (evidence investigation): Holmes says this change looks ready to ship.
  • Watson (independent verification): Watson found verification concerns. Most important concern: No evidence citations were available for trust analysis.
  • Moriarty (trend forecast): Moriarty does not have enough historical data yet to forecast readiness.

Suggested next actions

  1. Resolve Watson’s verification concerns before trusting the Holmes verdict as final.
📚 Glossary (what the Holmes terms mean)
  • HOLMES: Wesley’s main evidence investigation. It decides whether the cited proof is strong enough to justify shipping this commit.
  • WATSON: An independent verification pass. It checks Holmes’s citations and score math instead of trusting them blindly.
  • MORIARTY: A readiness forecast over time. It is advisory trend analysis, not the release gate itself.
  • Schema coverage score (SCS): How much of the schema has direct supporting evidence across generated artifacts and cited proof.
  • Test confidence index (TCI): How much test evidence exists for constraints, policies, relationships, and operations.
  • Migration risk index (MRI): How risky the schema change is to roll out. Lower is better.
  • Evidence trust: Whether the report is backed by exact citations, whole-file citations, or coarse references. Weak trust means the claim may be directionally right but not specific enough to trust blindly.
  • Citation quality: A count of exact line-span citations versus whole-file or coarse references.
  • ELEMENTARY: Ready to ship based on the current evidence.
  • REQUIRES INVESTIGATION: More work or review is needed before shipping.
  • YOU SHALL NOT PASS: Do not ship this change in its current state.

🕵️ SHA-lock HOLMES full report (click to expand)

🕵️ SHA-lock HOLMES Investigation

  • Generated: 2026-01-01T00:00:00.000Z
  • Commit SHA: e35ed41
  • Bundle Version: 2.0.0

⚠️ Evidence valid only for commit e35ed41

🔍 Executive Deduction

"Watson, after careful examination of the evidence, I deduce..."

Weighted Completion: ██████████ 95.0%
Scores: SCS 95.0% · TCI 90.0% · MRI 10.0%
Verification Status: 2 claims verified
Citation Quality: 2 exact · 0 whole-file · 0 coarse
Evidence Trust: strong
Ship Verdict: ELEMENTARY

🧩 SCS Breakdown

Component Score Coverage
Sql 100.0% 1.00/1.00
Types 100.0% 1.00/1.00
Validation 100.0% 1.00/1.00
Tests 100.0% 1.00/1.00

🧪 TCI Breakdown

Component Score Coverage Note
Unit Constraints 100.0% 1/1 N/A
Unit Rls 100.0% 1/1 N/A
Integration Relations 100.0% 1/1 N/A
E2e Ops 90.0% 9/10 fixture

⚠️ MRI Breakdown

Component Risk Share Points Count
Drops 0.0% 0 0
Renames Without Uid 0.0% 0 0
Add Not Null Without Default 100.0% 1 1
Non Concurrent Indexes 0.0% 0 0

📊 The Weight of Evidence

"Observe, Watson, how not all features carry equal importance..."

Element Weight Status Evidence Strength Deduction
schema 5 ✅ Exact SQL & tests test/fixtures/examples/.wesley-cache/shipme-fixture/tests.sql:1-1@e35ed41 exact Elementary!

🚪 Security & Performance Gates

"Elementary security measures, Watson..."

Gate Status Evidence Holmes's Ruling
Migration Risk MRI: 10.0% "Trivial risk"
Test Coverage TCI: 90.0% "Excellent coverage"
Sensitive Fields 0 fields "All secured"
Evidence Quality 2 exact · 0 whole-file · 0 coarse "All 2 citations resolve to exact line spans."

📋 The Verdict

ELEMENTARY - Ship immediately!
"The evidence is conclusive. No mysteries remain."

Signed and sealed,

  • S. Holmes, Consulting Detective

[END OF INVESTIGATION FOR COMMIT e35ed41]

🧵 Command Run

  • Run ID: run-fe7184b1-e909-4a09-a3e9-20dfbd9302dd
  • Transmutation: holmes-investigate
  • Command: investigate
  • Status: completed
  • Ledger: /home/runner/work/wesley/wesley/test/fixtures/examples/.wesley-cache/ledger

🩺 Dr. WATSON full report (click to expand)

🩺 Dr. Watson's Independent Verification Report

Medical Examination of Evidence

  • Examination Date: 2026-05-26T02:44:26.061Z
  • Patient SHA: e35ed41

🔬 Citation Verification

"Let me examine each piece of evidence independently..."

  • Citations Examined: 2
  • Verified: 0 ✅
  • Failed: 0 ❌
  • Unable to Verify: 2
  • Exact Subrange Citations: 0
  • Whole-file Citations: 0
  • Coarse Citations: 0
  • Evidence Trust: missing
  • Trust Note: No evidence citations were available for trust analysis.

Verification Rate: 0.0%

📊 Mathematical Verification

"I shall recalculate Holmes's arithmetic..."

Holmes claimed SCS: 95.0%
Watson calculates: 100.0%
Difference: ⚠️ Significant

🔍 Consistency Analysis

"Checking for contradictions in Holmes's deductions..."

✅ No logical inconsistencies detected

🩺 Dr. Watson's Medical Opinion

VERIFICATION: CONCERNS NOTED ⚠️

"While Holmes's methods are generally sound, I have noted some"
"discrepancies that warrant further investigation. No evidence citations were available for trust analysis."

Respectfully submitted,

  • Dr. J. Watson, M.D.
    Medical Examiner & Verification Specialist

🧵 Command Run

  • Run ID: run-d6e0c8f4-d2ca-4386-a193-fc37928ec4d9
  • Transmutation: watson-verify
  • Command: verify
  • Status: completed
  • Ledger: /home/runner/work/wesley/wesley/test/fixtures/examples/.wesley-cache/ledger

🔮 Professor MORIARTY full report (click to expand)

🧠 Professor Moriarty's Temporal Predictions

The Mathematics of Inevitability

  • Analysis Date: 2026-05-26T02:45:08.194Z

INSUFFICIENT DATA

"I require at least two data points to predict the future."
"Run Wesley generate multiple times to build history."

🧵 Command Run

  • Run ID: run-943af335-7b38-4834-9e06-a9194b42fda8
  • Transmutation: moriarty-predict
  • Command: predict
  • Status: completed
  • Ledger: /home/runner/work/wesley/wesley/test/fixtures/examples/.wesley-cache/ledger

Machine-readable reports: holmes-report.json · watson-report.json · moriarty-report.json (see workflow artifacts).


Filed at 221B Repository Street

Copy link
Copy Markdown

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

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: ef6ae4faf2

ℹ️ 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/wesley-core/src/domain/law.rs Outdated
Comment thread crates/wesley-core/src/domain/law.rs
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
crates/wesley-emit-rust/src/lib.rs (1)

33-47: ⚡ Quick win

Add a direct unit test for hash-constant emission.

The new public API and print path are critical output contracts; a small crate-local test that asserts both constants are emitted (and parse) would harden against regressions.

Also applies to: 296-306

🤖 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/wesley-emit-rust/src/lib.rs` around lines 33 - 47, Add a crate-local
unit test that calls emit_rust_with_operations_and_hashes with a minimal
WesleyIR and empty operations plus sample schema_hash and law_hash strings, then
assert the returned String contains the emitted constants (look for the constant
identifiers or the exact hash values) and verify the output is valid Rust by
parsing it (e.g., with syn::parse_file or another Rust parser). Put the test in
the same crate (e.g., a #[cfg(test)] mod tests with #[test] fn
emit_hash_constants_present()), reference the public function
emit_rust_with_operations_and_hashes and the RustProvenanceConstants identifiers
to locate code, and fail the test if the constants are missing or the parse
fails.
crates/wesley-cli/tests/cli.rs (1)

773-776: ⚡ Quick win

Assert WESLEY_SCHEMA_HASH matches metadata too.

This test only enforces equality for lawHash; schemaHash is currently checked for presence/prefix only, so a wrong emitted schema constant could slip through.

Suggested test hardening
     assert!(generated.contains("pub const WESLEY_SCHEMA_HASH: &'static str = \"sha256:"));
     assert!(generated.contains("pub const WESLAW_HASH: &'static str = \"sha256:"));
+    assert_eq!(
+        metadata_json["schemaHash"],
+        generated_hash_literal(&generated, "WESLEY_SCHEMA_HASH")
+    );
     assert_eq!(
         metadata_json["lawHash"],
         generated_hash_literal(&generated, "WESLAW_HASH")
     );
🤖 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/wesley-cli/tests/cli.rs` around lines 773 - 776, The test currently
asserts metadata_json["lawHash"] equals generated_hash_literal(&generated,
"WESLAW_HASH") but does not assert the schema hash; update the test to also
assert metadata_json["schemaHash"] equals generated_hash_literal(&generated,
"WESLEY_SCHEMA_HASH") so the emitted schema constant is validated. Locate the
assertion using metadata_json and generated_hash_literal in the test (around the
existing assert_eq for lawHash) and add a symmetric assert_eq comparing
metadata_json["schemaHash"] to generated_hash_literal(&generated,
"WESLEY_SCHEMA_HASH").
🤖 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 `@CHANGELOG.md`:
- Around line 24-40: The changelog claims the CLI exposes the "wesley law"
command (e.g., "wesley law validate", and related emitted constants like
WESLEY_SCHEMA_HASH / WESLAW_HASH) but the current CLI preflight shows no "wesley
law" surface; update CHANGELOG.md to match shipped behavior by either removing
or qualifying those lines about "wesley law" and its emitted artifacts, or
explicitly note they are forthcoming (e.g., "planned / not yet shipped") until
the command and embedded constants are actually added; ensure references to
"wesley law validate", "WESLEY_SCHEMA_HASH", "WESLAW_HASH", and bundle/profile
emit behavior are consistent with current PRs before merging.

In `@crates/wesley-cli/src/main.rs`:
- Around line 749-755: The metadata builder currently always sets
EmitMetadata.schema_hash from compute_registry_hash(ir) which diverges from the
emit-with-law path that uses manifest.schema_hash; update the EmitMetadata
construction (where schema_hash is set) to use manifest.schema_hash when
manifest.is_some() (i.e., prefer manifest.map(|m| m.schema_hash.clone()) or
otherwise fallback to compute_registry_hash(ir)?), so the schema_hash in
EmitMetadata matches the manifest-derived schema hash used by emit-with-law;
locate EmitMetadata initialization in main.rs and adjust the schema_hash
assignment accordingly.

In `@docs/BEARING.md`:
- Around line 341-355: The PR description text is inconsistent with the updated
checklist in the BEARING.md diff; update the PR description to state "45 / 75"
slices closed (matching the updated status line that lists WLAW-001 through
WLAW-045) instead of the incorrect "35 / 75"; ensure any mention of the slice
total and the numeric progression referencing WLAW-021–045 reflects 45 / 75 so
the PR description and the docs/BEARING.md status line are consistent.

---

Nitpick comments:
In `@crates/wesley-cli/tests/cli.rs`:
- Around line 773-776: The test currently asserts metadata_json["lawHash"]
equals generated_hash_literal(&generated, "WESLAW_HASH") but does not assert the
schema hash; update the test to also assert metadata_json["schemaHash"] equals
generated_hash_literal(&generated, "WESLEY_SCHEMA_HASH") so the emitted schema
constant is validated. Locate the assertion using metadata_json and
generated_hash_literal in the test (around the existing assert_eq for lawHash)
and add a symmetric assert_eq comparing metadata_json["schemaHash"] to
generated_hash_literal(&generated, "WESLEY_SCHEMA_HASH").

In `@crates/wesley-emit-rust/src/lib.rs`:
- Around line 33-47: Add a crate-local unit test that calls
emit_rust_with_operations_and_hashes with a minimal WesleyIR and empty
operations plus sample schema_hash and law_hash strings, then assert the
returned String contains the emitted constants (look for the constant
identifiers or the exact hash values) and verify the output is valid Rust by
parsing it (e.g., with syn::parse_file or another Rust parser). Put the test in
the same crate (e.g., a #[cfg(test)] mod tests with #[test] fn
emit_hash_constants_present()), reference the public function
emit_rust_with_operations_and_hashes and the RustProvenanceConstants identifiers
to locate code, and fail the test if the constants are missing or the parse
fails.
🪄 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: CHILL

Plan: Pro

Run ID: 54c6f088-2625-422f-b14a-744a26a69ce7

📥 Commits

Reviewing files that changed from the base of the PR and between 28273e3 and 9212fde.

📒 Files selected for processing (18)
  • CHANGELOG.md
  • README.md
  • crates/wesley-cli/src/main.rs
  • crates/wesley-cli/tests/cli.rs
  • crates/wesley-core/src/domain/law.rs
  • crates/wesley-core/tests/law_ir.rs
  • crates/wesley-emit-rust/src/lib.rs
  • docs/BEARING.md
  • docs/END_TO_END.md
  • docs/ENTRYPOINTS.md
  • docs/GUIDE.md
  • docs/design/0019-weslaw-semantic-law-ir/CANONICALIZATION_AND_DIAGNOSTICS.md
  • docs/design/0019-weslaw-semantic-law-ir/LAW_IR_V1.md
  • docs/design/0019-weslaw-semantic-law-ir/weslaw-semantic-law-ir.md
  • schemas/README.md
  • schemas/wesley-contract-bundle-manifest-v1.schema.json
  • test/fixtures/weslaw/README.md
  • test/weslaw-fixtures.bats

Comment thread CHANGELOG.md
Comment thread crates/wesley-cli/src/main.rs
Comment thread docs/BEARING.md Outdated
@flyingrobots
Copy link
Copy Markdown
Owner Author

@codex Self-review findings for this branch. Please confirm these before merge.

Severity File:line Infraction Evidence Recommended mitigation prompt
P1 Major crates/wesley-core/src/domain/law.rs:952 Existing channel/invariant law modifications are reported as LAW_ADDED instead of a modification. diff_law_entry_bodies only handles scalar, variant, and footprint bodies. The fallback at lines 966-969 returns LawDiffEventKindV1::LawAdded for any other body pair, so a same-id/same-subject ChannelLaw or InvariantLaw body change is falsely classified as a newly added law. Add regression tests for same-id channel and invariant modifications. Implement explicit channel/invariant diff events now, or add a neutral LAW_CHANGED/UNCLASSIFIED_LAW_CHANGED event instead of emitting LAW_ADDED for existing entries.
P1 Major crates/wesley-core/src/domain/law.rs:804 oldLawHash != newLawHash can produce an empty changes array. lawHash includes registries at lines 1292-1297 and tags at lines 1363-1369, but diff_law_ir_v1 only emits lifecycle/body events. A registry-only or tag-only change changes lawHash; then diff_law_entry_bodies can return None, leaving no machine-readable reason for the hash delta. Add a regression asserting that a changed lawHash always yields at least one event. Then either exclude non-semantic tags/provenance from lawHash, or emit explicit REGISTRY_CHANGED / LAW_TAGS_CHANGED / generic changed events.
P2 Medium crates/wesley-core/src/domain/law.rs:741 Public semantic hash path does not enforce active-only semantics. The docs for diff_law_ir_v1 state draft entries do not affect lawHash at lines 801-803, but to_semantic_law_ir_json calls semantic_law_ir_value, which maps every value.entries item at lines 1285-1290. Loader-normalized YAML avoids this today, but programmatic/deserialized LawIrV1 can still include LawStatusV1::Draft and perturb lawHash. Add a regression constructing a LawIrV1 with a draft entry and prove compute_law_hash_v1 ignores it. Filter entry.status == Active inside semantic_law_ir_value or remove Draft from normalized public Law IR.
P3 Minor crates/wesley-cli/src/main.rs:749 Emit metadata mixes bare and qualified SHA-256 formats. schemaHash is still written as a bare 64-char digest at line 750 while law/profile/bundle hashes are sha256:<hex> strings from the manifest at lines 751-755. Consumers comparing metadata with manifest/generated Rust constants must special-case schemaHash. Decide and document one wire format. Prefer adding a schemaHashQualified field or changing metadata schemaHash to match manifest schemaHash, with backward-compatibility handled explicitly.

Summary: 4 findings total: P1=2, P2=1, P3=1. No whitespace or Markdown-style violations found by git diff --check; the repo preflight had already passed before this review.

Copy link
Copy Markdown

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

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: 9f2f021396

ℹ️ 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/wesley-core/src/domain/law.rs Outdated
Comment thread crates/wesley-core/src/domain/law.rs Outdated
Comment thread crates/wesley-core/src/domain/law.rs
@flyingrobots
Copy link
Copy Markdown
Owner Author

Self-review resolution summary

Resolved the strict self-review findings in commit d3fc5395.

Severity Area Finding Resolution Commit
P1 crates/wesley-core/src/domain/law.rs Existing channel and invariant law body changes could be reported as LAW_ADDED. Added explicit channel/invariant modification event classes, including CHANNEL_VERSION_CHANGED, CHANNEL_LAW_CHANGED, and PREDICATE_CHANGED, with regression coverage. d3fc5395
P1 crates/wesley-core/src/domain/law.rs Law-hash changes from registry/tag/bundle fields could produce an empty semantic diff. Added bundle-level diff events for registry changes, schema-hash rebound, tag changes, and a final hash-mismatch fallback. d3fc5395
P2 crates/wesley-core/src/domain/law.rs Programmatic draft law entries could affect semantic law hashing. Filtered semantic hash input to active law entries and added a regression test for draft pollution. d3fc5395
P3 crates/wesley-cli/src/main.rs Emit metadata mixed bare schema hashes with qualified sha256: hashes. Added schemaHashQualified while preserving legacy bare schemaHash; updated CLI tests and docs. d3fc5395

Validation run before and during push:

  • cargo fmt
  • cargo test -p wesley-core --test law_ir
  • cargo test -p wesley-cli --test cli
  • BATS_LIB_PATH=test/bats-plugins bats -t test/weslaw-fixtures.bats
  • pnpm run preflight
  • pre-push Rust product preflight

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/wesley-core/src/domain/law.rs (1)

1081-1083: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

validate_law_ir_v1_bindings should ignore draft entries.

The function contract says active entries, but it validates/counts all entries. That can incorrectly fail bindings and inflate manifest lawEntryCount when drafts are present.

Suggested fix
-    for (index, entry) in law_ir.entries.iter().enumerate() {
+    let active_entries = law_ir
+        .entries
+        .iter()
+        .enumerate()
+        .filter(|(_, entry)| entry.status == LawStatusV1::Active);
+
+    let mut bound_entry_count = 0usize;
+    for (index, entry) in active_entries {
         let law_path = format!("$.laws[{index}]");
@@
         context.bind_entry(entry, coordinate, &law_path)?;
+        bound_entry_count += 1;
     }
@@
     Ok(LawBindingReportV1 {
         schema_hash: active_schema_hash.to_string(),
-        bound_entry_count: law_ir.entries.len(),
+        bound_entry_count,
     })
 }

Also applies to: 1100-1103

🤖 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/wesley-core/src/domain/law.rs` around lines 1081 - 1083,
validate_law_ir_v1_bindings is iterating and counting all law_ir.entries but
must only consider active (non-draft) entries; update the loops and any counts
to filter entries by their status (e.g., skip entries where entry.status
indicates Draft) before constructing law_path/subject_path and validating
bindings so drafts are ignored when computing law entry counts and performing
validations (apply same change to the other loop referenced around the later
lines).
🤖 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/wesley-cli/src/main.rs`:
- Around line 338-339: The code silently accepts unknown options.profile values
by defaulting to "release", allowing typos to bypass coverage gates; update the
handling around options.profile (where profile is set and passed to
law_coverage_report) to validate that the provided string is one of the allowed
values ("release" or "ci-release") and reject/exit with an error if it isn't;
apply the same validation pattern to the other similar profile-handling site
that passes a profile to law_coverage_report to ensure unknown profiles are
refused rather than treated as "release".
- Around line 1798-1806: The current logic counts raw occurrences of
old_schema_hash in source and does a global replace (using source.replace),
which is brittle; instead locate and replace only the schema.hash anchor line.
Change the code that uses source.matches(old_schema_hash).count() and
source.replace(old_schema_hash, new_schema_hash) to: search for a single line
that assigns schema.hash (e.g., pattern matching "schema.hash" followed by ":"
or "=" and the quoted hash), assert exactly one match, and replace only the hash
portion on that line with new_schema_hash (use the existing variables
old_schema_hash, new_schema_hash, source, and path to report errors if the
specific schema.hash line is missing or duplicated).

In `@docs/GUIDE.md`:
- Around line 48-54: The documented "wesley law" command entries (the lines
listing "Law lint", "Law", "Law Diff", "Law Explain", "Law Rebind", "Law
Capabilities", "Law Coverage" and the similar entries at 67-69) are inaccurate
because the native CLI does not expose a "wesley law" namespace; update
docs/GUIDE.md to either: (A) replace those command examples with the actual
native CLI command names and flags that are exposed by the codebase (so the
fast-path commands in GUIDE.md match the real CLI), or (B) remove the bogus
"wesley law ..." block and add a correct description pointing to the real CLI
entrypoints; ensure you update all occurrences noted (the block at the shown
diff and the entries at 67-69) and keep examples using the exact flag syntax the
native CLI exposes.

---

Outside diff comments:
In `@crates/wesley-core/src/domain/law.rs`:
- Around line 1081-1083: validate_law_ir_v1_bindings is iterating and counting
all law_ir.entries but must only consider active (non-draft) entries; update the
loops and any counts to filter entries by their status (e.g., skip entries where
entry.status indicates Draft) before constructing law_path/subject_path and
validating bindings so drafts are ignored when computing law entry counts and
performing validations (apply same change to the other loop referenced around
the later lines).
🪄 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: CHILL

Plan: Pro

Run ID: 1e07b6aa-7b79-4e7e-bca0-ca1e407b7671

📥 Commits

Reviewing files that changed from the base of the PR and between 9212fde and 47c6c86.

📒 Files selected for processing (24)
  • CHANGELOG.md
  • crates/wesley-cli/src/main.rs
  • crates/wesley-cli/tests/cli.rs
  • crates/wesley-core/src/domain/law.rs
  • crates/wesley-core/tests/law_ir.rs
  • crates/wesley-emit-rust/src/lib.rs
  • docs/BEARING.md
  • docs/END_TO_END.md
  • docs/GUIDE.md
  • docs/design/0019-weslaw-semantic-law-ir/COORDINATES_AND_REGISTRIES.md
  • docs/design/0019-weslaw-semantic-law-ir/LAW_IR_V1.md
  • docs/design/0019-weslaw-semantic-law-ir/weslaw-semantic-law-ir.md
  • schemas/README.md
  • schemas/wesley-law-diff-v1.schema.json
  • test/fixtures/weslaw/README.md
  • test/fixtures/weslaw/accepted/channel-ttd-protocol-from-directive.weslaw.yaml
  • test/fixtures/weslaw/accepted/rust-validator-payoff.weslaw.yaml
  • test/fixtures/weslaw/diff/binding-broken.weslaw.yaml
  • test/fixtures/weslaw/diff/ci-semantic-diff.json
  • test/fixtures/weslaw/diff/ci-semantic-diff.md
  • test/fixtures/weslaw/diff/holmes-blade-binding-broken.json
  • test/fixtures/weslaw/diff/new.weslaw.yaml
  • test/fixtures/weslaw/diff/old.weslaw.yaml
  • test/weslaw-fixtures.bats
✅ Files skipped from review due to trivial changes (8)
  • test/fixtures/weslaw/diff/ci-semantic-diff.md
  • test/fixtures/weslaw/diff/binding-broken.weslaw.yaml
  • docs/design/0019-weslaw-semantic-law-ir/LAW_IR_V1.md
  • docs/design/0019-weslaw-semantic-law-ir/COORDINATES_AND_REGISTRIES.md
  • docs/BEARING.md
  • test/fixtures/weslaw/README.md
  • docs/END_TO_END.md
  • schemas/README.md

Comment thread crates/wesley-cli/src/main.rs Outdated
Comment thread crates/wesley-cli/src/main.rs Outdated
Comment thread docs/GUIDE.md
@flyingrobots
Copy link
Copy Markdown
Owner Author

Resolved review-thread follow-ups:

Thread Outcome Evidence
Reject non-object schema types as footprint resources Fixed 725473c2 gates schema-backed footprint resources to GraphQL object types unless an explicit registry resource exists, with regression coverage in law_ir_v1_binding_rejects_non_object_schema_footprint_resources.
Report binding paths using authored law order Fixed 725473c2 retains authored laws[n] indices through normalization for diagnostics, covered by law_ir_v1_binding_reports_authored_law_indices_after_normalization.
PR description slice count mismatch Fixed PR body now says WLAW is closed at 75 / 75 and lists the current command surface.
Classify channel/invariant body edits as modifications Fixed Prior diff review commit added channel/invariant modification events and coverage via law_diff_v1_reports_channel_and_invariant_changes_as_modifications.
Emit a diff event whenever semantic law hash changes Fixed Prior diff review commit added registry/tag/schema-hash events, covered by law_diff_v1_reports_registry_and_tag_hash_deltas.
Exclude draft entries from semantic law hash input Fixed Prior hash review commit filters active entries for semantic hash input, covered by semantic_law_hash_ignores_programmatic_draft_entries.
Fix documented wesley law command surface Fixed abb36b39 made the docs CLI checker understand nested native commands; 725473c2 keeps law coverage profile help explicit.

Validation after the fixes: cargo test -p wesley-core --test law_ir, cargo test -p wesley-cli --test cli, pnpm run legacy-preflight, pnpm run preflight, git diff --check, and pre-push Rust product preflight all passed.

@flyingrobots flyingrobots merged commit 22ef594 into main May 26, 2026
20 checks passed
@flyingrobots flyingrobots deleted the weslaw-strict-binding branch May 26, 2026 08:07
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