Skip to content

plan+feat(cognition+transaction): normalized-entity-holy-grail-v1 Stage 1 (D-NEH-1a..g)#431

Merged
AdaWorldAPI merged 8 commits into
mainfrom
claude/normalized-entity-holy-grail-v1
May 29, 2026
Merged

plan+feat(cognition+transaction): normalized-entity-holy-grail-v1 Stage 1 (D-NEH-1a..g)#431
AdaWorldAPI merged 8 commits into
mainfrom
claude/normalized-entity-holy-grail-v1

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

Ships Stage 1 of normalized-entity-holy-grail-v1 (the canonical trunk plan that unifies the workspace's OGIT/OWL/DOLCE/Odoo inheritance + cognitive shader + JIT + MailboxSoA into ONE typed consumer pipeline grammar). Plan + 8 anchoring epiphanies + INTEGRATION_PLANS entry + the contract surface scaffold (~1750 LOC of typed signatures + compile-fail tests + crate-level example).

3 commits:

  • 1695a9a — plan file + 8 prepended epiphanies + INTEGRATION_PLANS entry
  • b96baf3 — Sonnet agent's contract surface scaffold (D-NEH-1a..g)
  • 8b3efca — main-thread /// work// TODO(Stage 2): strip pass (45 markers reviewed + converted; nothing dropped)

The shape

  • Carrier NormalizedEntity<S> — single struct, 4-way inheritance slots (Odoo → OGIT → OWL → DOLCE → FIBU/FIBO, last optional), typed lens into a MailboxSoA row, phantom-typed Stage forbids out-of-order traversal at compile time
  • Algebra 5 verbs (resolve_ogit / hydrate_owl / classify_dolce / align_fibu / op|chk_data|review|abduct|report|output) — 4 + 1; the chain methods together ARE the think verb
  • Op trait with three call sites: apply (cold, ships in Stage 1), apply_stream (warm, Stage 2 with futures-rs), apply_soa (hot, Stage 2 with cognitive-shader-driver dep) — one trait, three speeds, shared const data
  • Three transaction contexts (Interactive / Bulk / Periodisch) own commit + Baton epoch + Lance version policy + cascade traversal mode — consumer's typed enclosure picks the regime, NOT the shader
  • Cascade as one typed graph on EdgeColumn with 8 CascadeKind discriminants (collapses Odoo's 6 overlapping mechanisms into one typed surface)

Anchoring epiphanies (8 prepended to EPIPHANIES.md)

  1. E-NORMALIZED-ENTITY-1 — single typed carrier holds the 4-way inheritance
  2. E-OP-FIVE-VERBS-1 — only 5 universal verbs (4 + 1)
  3. E-OP-THREE-CALLSITES-1 — same Op trait, three speeds, shared const data
  4. E-TRANSACTION-CONTEXT-1 — typed contexts own commit + epoch + version
  5. E-CASCADE-AS-EDGECOLUMN-1 — 6 Odoo cascade mechanisms collapse into 1 typed graph
  6. E-ODOO-AS-PRIOR-ART-1 — Odoo solved the 3 regimes 15 years ago; we re-encode as compile-time typestate instead of stringly-typed env.context
  7. E-CONSUMER-CANNOT-INTERPRET-1 (iron-rule candidate) — business heuristics MUST be SIMD-amenable const data; regex / hand-rolled if x.starts_with("84") becomes a MISSING FUNCTION, not a code-review concern
  8. E-NO-AUTOMATIC-REGIME-PICK-1 — shader does NOT autonomously pick hot/warm/cold; the consumer's typed context does (correction of an earlier framing)

What's IN this Stage 1

  • 13 files / 1751 LOC of typed Rust signatures (zero-dep; contract crate stays zero-dep)
  • 472 tests baseline + 9 new typestate tests (4 compile_fail doctests + 7 positive #[test] functions)
  • Full no_run example chain (woa-rs invoice flow) renderable via cargo doc
  • 43 // TODO(Stage 2): source comments flagging the wiring deferred to Stage 2 (OGIT codebook dispatch, OWL hydrator, DOLCE classifier, FIBU overlay, MailboxSoA column writes, async Stream backend choice, EdgeColumn impl, JIT chain handle)
  • docs/COGNITION_HOLY_GRAIL.md pointer to the plan
  • Board hygiene: AGENT_LOG entry + STATUS_BOARD row (per CCA2A mandatory rule)

What's OUT (Stage 2..7, sketched in the plan)

  • Stage 2 — kernel bodies for ~50 typed Ops; JIT-compile hot path
  • Stage 3 — consumer DSL macros (woa_think! / medcare_think! / smb_think!) — pipe-style ergonomics on top of the typestate chain
  • Stage 4 — Stream + ractor-supervised actor wiring (Elixir-OTP analogue)
  • Stage 5 — Jahresabrechnung JIT kernel (target ≥100× throughput vs Odoo's account.fiscal.year.close wizard)
  • Stage 6 — palantir-foundry parity audit
  • Stage 7 — elixir-OTP parity audit
  • When v6 + v7 audits show ≥80% parity, the workspace has earned the "better palantir foundry / better elixir" framing the plan was named for

Test plan

  • cargo check -p lance-graph-contract — clean
  • cargo test -p lance-graph-contract --lib — 472 lib tests green (zero regression from baseline)
  • cargo test -p lance-graph-contract --test cognition_typestate — new typestate test crate green
  • All 43 deferred-wiring TODOs preserved as // TODO(Stage 2): source comments (visible to future agents; invisible in cargo doc output)

Note for reviewers

This is a scaffold + plan PR. Most of cognition/advance.rs, transaction/{interactive,bulk,periodisch}.rs, and op.rs's apply_stream / apply_soa paths are todo!() bodies behind typed signatures; bodies land in Stage 2 once the cognitive-shader-driver + futures dependencies are wired. The typestate gate, the trait shape, the cascade discriminants, and the docs are real and meant to stabilise here.

https://claude.ai/code/session_017gZ6sPRXYPj5n7uJ7NBtRv


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Introduced a typed, staged entity-normalization pipeline with public stage markers, stage-advancement methods, an Op contract, cascade traversal types, widened row index handle, and three transaction contexts (interactive/bulk/periodic) — many execution paths scaffolded for later stages.
  • Documentation

    • Added a full proposal, integration plan, status board entries, architectural epiphanies, and a consumer example describing the pipeline and roadmap.
  • Tests

    • Added compile-fail doctests for typestate proofs and runtime integration tests covering basic behaviors.
  • Chores

    • CI extended to run integration tests and doctests.

Review Change Stack

claude added 4 commits May 28, 2026 12:38
…EXT-1..6 + jit + MailboxSoA

Adds `.claude/plans/normalized-entity-holy-grail-v1.md` — the canonical
trunk plan that ties every prior architectural deliverable into ONE
typed consumer pipeline grammar:

- Carrier: `NormalizedEntity<Stage>` — single struct, 4-way inheritance
  slots (Odoo → OGIT → OWL → DOLCE → FIBU/FIBO), typed lens into a
  `MailboxSoA` row, phantom-typed Stage enforces traversal order at
  compile time
- Algebra: five universal verbs (`resolve` / `hydrate` / `classify` /
  `align` / `think`) — closure analogue of the Vsa16k algebra
- Execution: `Op<I,O>` trait with three call sites
  (`apply` cold / `apply_stream` warm / `apply_soa` hot, JIT-compiled),
  shared const data, shader-dispatched
- Contexts: typed `Interactive` / `Bulk` / `Periodisch` transaction
  enclosures own commit semantics + Baton epoch + Lance version policy
  + cascade traversal mode (sync DFS / async batched / JIT fixed-point)
- Cascade: Odoo's 6 overlapping mechanisms collapse into ONE typed
  graph on `EdgeColumn`

Re-encodes Odoo's 15-year-old three-regime decomposition as
compile-time typed boundaries instead of stringly-typed `env.context`
flags + lock-date wizards. The decomposition is borrowed; the failure
timing (compile-time vs runtime) is the improvement.

PREPENDS 8 driver epiphanies to EPIPHANIES.md in the same commit:
E-NORMALIZED-ENTITY-1, E-OP-FIVE-VERBS-1, E-OP-THREE-CALLSITES-1,
E-TRANSACTION-CONTEXT-1, E-CASCADE-AS-EDGECOLUMN-1,
E-ODOO-AS-PRIOR-ART-1, E-CONSUMER-CANNOT-INTERPRET-1 (iron-rule
candidate — regex/hand-rolled if-chains structurally banned via
missing-function), E-NO-AUTOMATIC-REGIME-PICK-1 (mid-session
correction).

PREPENDS plan entry to INTEGRATION_PLANS.md per CCA2A mandatory
board-hygiene rule.

Stage-1 deliverables D-NEH-1a..g (~2 500 LOC, typed signatures +
compile-fail tests + doc-level example) follow in a subsequent commit
on this branch. Subsequent stages (v2..v7) sketched in the plan:
kernel bodies, consumer DSL macros, stream+ractor wiring,
Jahresabrechnung JIT kernel, palantir-foundry parity audit, elixir-OTP
parity audit. When v6+v7 audits show ≥80% parity, the workspace has
earned the "better palantir foundry / better elixir" framing.

https://claude.ai/code/session_017gZ6sPRXYPj5n7uJ7NBtRv
…il-v1 Stage 1 contract surface scaffold

Adds the typed consumer pipeline grammar per
`.claude/plans/normalized-entity-holy-grail-v1.md` — the trunk that
unifies BP-1 + EXT-1..6 + jit + MailboxSoA into one surface.

Modules:
- `cognition::{stages, entity, op, advance, cascade}` — phantom-typed
  Stage markers (sealed trait; 9 canonical stages), `NormalizedEntity<S>`
  carrier (Copy, zero-dep placeholder handles for Odoo/OGIT/OWL/FIBU
  refs; Stage 2 replaces with real types), `Op<I,O>` trait with 3 call
  sites (Stage 1 ships `apply`; `apply_stream` + `apply_soa` deferred
  to Stage 2 per zero-dep constraint), 5-verb advancement methods
  (`resolve_ogit` fully wired for the ctx dispatch; verbs 2-4 are
  `todo!()` pending Stage 2 ontology dep), cascade traversal trait
  (`CascadeKind` 8 discriminants, `TraversalMode` 3 modes,
  `CascadeWalker` trait for EdgeColumn impl in Stage 2)
- `transaction::{interactive, bulk, periodisch, ctx}` — 3 typed context
  shapes + 4 per-stage `*Ctx` traits (sealed Context base); all three
  contexts implement all 4 traits with `todo!()` bodies; Interactive
  + Bulk + Periodisch have `new()` + `Default` impls

Compile-fail tests (`tests/cognition_typestate.rs`): 4 `compile_fail`
doctests document what the type system forbids; 7 positive `#[test]`
functions confirm permitted forms compile + run.

Crate doc: `cognition/mod.rs` has a full invoice-flow example chain
as a `no_run` doctest. `docs/COGNITION_HOLY_GRAIL.md` pointer doc.

Stage-1 `/// work` markers (count: ~35): flag OGIT codebook lookup,
OWL hydrator dispatch, DOLCE classifier wiring, MailboxSoA column
write-back, `apply_stream` async backend choice, `apply_soa` SoA dep,
EdgeColumn impl, Output shape, DolceCategory sub-enum expansion, and
frozen Lance version API. Main thread reviews + strips markers before PR.

Board hygiene: AGENT_LOG entry prepended + STATUS_BOARD D-NEH-1a..g
rows (status: In PR).

Tests: `cargo check -p lance-graph-contract` clean (0 errors);
`cargo test -p lance-graph-contract --lib` green (472 tests, was 472
baseline — no regressions); `cargo test -p lance-graph-contract --test
cognition_typestate` green (7 new tests).

Plan: `.claude/plans/normalized-entity-holy-grail-v1.md`.

https://claude.ai/code/session_017gZ6sPRXYPj5n7uJ7NBtRv
…2) (main-thread review pass)

Per the new agent workflow (plan → Sonnet → /// work markers → main-thread
review → strip → PR → bot review → fix): main thread reviewed the 45
`/// work` doc-comment markers the Sonnet agent left across the cognition
+ transaction modules and converted them to plain `// TODO(Stage 2):`
line comments.

Rationale:
- `///` doc-comments would render the deferred-work notes into cargo doc
  output as part of the public surface — wrong audience
- `// TODO(Stage 2):` keeps the context visible in source (so a future
  agent picks them up) without polluting the rendered documentation
- All 45 markers carried meaningful Stage-2-wiring notes (OGIT codebook
  dispatch, OWL hydrator, DOLCE classifier, FIBU overlay, MailboxSoA
  column writes, async Stream backend choice, EdgeColumn impl, etc.) —
  none were stripped wholesale; all preserved as TODOs

Build: cargo check -p lance-graph-contract clean.
Tests: 472 lib tests still green (zero regression from the agent's commit).

https://claude.ai/code/session_017gZ6sPRXYPj5n7uJ7NBtRv
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR ships a Stage‑1 contract surface for a typed normalized‑entity consumer pipeline: a phantom‑typed NormalizedEntity carrier with sealed stages, a step‑based Op trait, partial five‑verb advancement APIs (resolve implemented; others todo), cascade walker contract, sealed transaction contexts (Interactive/Bulk/Periodisch) as placeholders, typestate tests, and planning/board docs.

Changes

Typed Normalized Entity Consumer Pipeline

Layer / File(s) Summary
Typed Entity Carrier & Stage System
crates/lance-graph-contract/src/cognition/entity.rs, crates/lance-graph-contract/src/cognition/stages.rs, crates/lance-graph-contract/src/cognition/mod.rs
Introduces NormalizedEntity<S> as a copyable phantom‑typed carrier with stage‑dependent optional fields and a MailboxRow lens; widens MailboxRow::row_idx to u32; provides NormalizedEntity<Raw>::raw(...) constructor and pub(crate) advance_stage_internal<T: Stage>; adds nine sealed stage marker types and the sealed Stage trait; adds doctests encoding compile‑fail typestate proofs.
Operation Contract & Results
crates/lance-graph-contract/src/cognition/op.rs
Defines OpKind and Output; exposes fn kind(&self) -> OpKind and a default step(&self, entity: &NormalizedEntity<I>) -> Result<(), OpError> hook (default no‑op); adds OpError. Warm/hot execution call sites are deferred to later stages.
Stage Advancement Verbs & Chaining
crates/lance-graph-contract/src/cognition/advance.rs
Adds five‑verb method surface: resolve_ogit (implemented) and hydrate_owl, classify_dolce, align_fibu (currently todo!()), plus chaining methods (op, chk_data, review, abduct, report) that call Op::step and advance phantom stages; output() on Reported returns placeholder Output { success: true }.
Cascade Graph Abstractions
crates/lance-graph-contract/src/cognition/cascade.rs
Adds CascadeKind enum mapping Odoo cascade sources, TraversalMode enum (Sync/Batched/JitFixedPoint), and CascadeWalker trait with walk_dependents(..., on_dependent: &mut dyn FnMut(MailboxRow)) contract (Stage‑2 wiring deferred).
Transaction Context Trait Hierarchy
crates/lance-graph-contract/src/transaction/ctx.rs, crates/lance-graph-contract/src/transaction/mod.rs
Introduces sealed Context and four stage‑specific traits (OgitCtx, OwlCtx, DolceCtx, FibuCtx) exposing single‑verb lookup methods used by advancement APIs; re‑exports context traits/types.
Transaction Context Implementations
crates/lance-graph-contract/src/transaction/{interactive,bulk,periodisch}.rs
Adds concrete context types Interactive, Bulk, Periodisch with constructors/defaults; each implements Context and the domain traits but currently todo!() their resolver methods as Stage‑2 placeholders.
Module Architecture & Public Surface
crates/lance-graph-contract/src/lib.rs, crates/lance-graph-contract/src/{cognition,transaction}/mod.rs
Exports cognition and transaction modules and re‑exports core types (NormalizedEntity, Op, OpError, OpKind, Output, stage markers, CascadeKind, CascadeWalker, TraversalMode, contexts) to form the contract API surface.
Typestate Testing & Consumer Documentation
crates/lance-graph-contract/tests/cognition_typestate.rs, docs/COGNITION_HOLY_GRAIL.md
Adds runtime positive tests for typestate helpers and Op sentinel behavior, minimal external Op implementations for transitions, and consumer docs plus a Rust example demonstrating intended typestate chaining; compile‑fail proofs are in cognition module doctests.
Architectural Planning & Board Updates
.claude/plans/normalized-entity-holy-grail-v1.md, .claude/board/{EPIPHANIES,INTEGRATION_PLANS,STATUS_BOARD,AGENT_LOG}.md
Prepends the Stage‑1 proposal, epiphanies, status board rows, and AGENT_LOG entries documenting the scaffold, Stage‑2 todos, and test/build outcomes.
CI / Workflow
.github/workflows/rust-test.yml
Runs contract integration tests and doctests for crates/lance-graph-contract in CI in addition to prior unit tests.

🎯 4 (Complex) | ⏱️ ~60 minutes

A rabbit hops through the schema dense,
Five stages typed with pure immense,
Interactive, Bulk, Periodisch vie,
While phantom states help errors die,
The holy grail at last draws nigh! 🐰✨

🚥 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 and specifically describes the main change: a Stage 1 implementation of the normalized-entity-holy-grail-v1 plan delivering key contract scaffolding (D-NEH-1a..g). It is concise, clear, and uses conventional structured prefixes.
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 claude/normalized-entity-holy-grail-v1

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: 8b3efca03f

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

/// Not callable on the advancement verbs themselves (those use it
/// internally); exposed `pub` so external Op implementors can
/// construct stage-transitioned entities in their `apply` bodies.
pub fn advance_stage<T: Stage>(self) -> NormalizedEntity<T> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Hide raw stage casting behind the checked verbs

Because advance_stage is public, any downstream crate can skip the required pipeline by calling, for example, raw.advance_stage::<Reported>().output() without resolving OGIT/OWL/DOLCE/FIBU or running chk_data/review/abduct. That bypasses the typestate guarantees this API is documenting and allows invalid entities with empty normalization slots to be treated as completed, so the cast needs to be restricted to trusted verb/Op plumbing rather than exposed as a general public method.

Useful? React with 👍 / 👎.

/// Wide enough for PR #427's witness_table widening.
pub mailbox_ref: u32,
/// Row inside the per-mailbox SoA (64 K–256 K envelope).
pub row_idx: u16,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use a row index wide enough for 256K mailboxes

For mailboxes in the documented 64K–256K envelope, rows above 65,535 cannot be represented by this u16 field. Any cascade or Op dispatch that needs to address those upper rows would be unable to construct a valid MailboxRow (or would have to truncate elsewhere), so this should be widened to match the advertised per-mailbox capacity before consumers start depending on the handle layout.

Useful? React with 👍 / 👎.

claude added 2 commits May 28, 2026 13:09
…ation

Clippy 1.95 reads a leading `+` at the start of a doc-comment line as a
markdown list-bullet starter, then complains the next line doesn't have
indented continuation. The text was prose, not a list — reworded
`+ lock-date` → `plus lock-date` so the lint goes quiet.

Build: cargo clippy -p lance-graph-contract --lib --tests -- -D warnings
clean.

https://claude.ai/code/session_017gZ6sPRXYPj5n7uJ7NBtRv
…ke Ops

Clippy `-D warnings` rejects 5 unused-struct errors on the fake Op types
(`NoopOp`, `FakeChkData`, `FakeReview`, `FakeAbduct`, `FakeReport`) that
are referenced only by `compile_fail` doctests above. Regular `cargo test`
builds the crate without those doctest snippets, leaving the structs
unused.

`#[allow(dead_code)]` with a brief explanatory comment per struct is the
clean way to silence the lint without sacrificing the doctests'
documentary value.

https://claude.ai/code/session_017gZ6sPRXYPj5n7uJ7NBtRv

@coderabbitai coderabbitai 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.

Actionable comments posted: 9

🧹 Nitpick comments (1)
crates/lance-graph-contract/src/cognition/cascade.rs (1)

1-187: ⚡ Quick win

Add focused unit tests in this module.

This new contract file has no local #[cfg(test)] coverage. Please add focused unit tests (e.g., enum equality/hash behavior and basic trait-shape compile checks) alongside the implementation.

As per coding guidelines, “crates/**/*.rs: Add Rust unit tests alongside implementations via #[cfg(test)] modules; prefer focused scenarios over broad integration tests”.

🤖 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/lance-graph-contract/src/cognition/cascade.rs` around lines 1 - 187,
Add a #[cfg(test)] mod tests in this file with focused unit tests: 1) test
equality and Hash behavior for CascadeKind (e.g., insert variants into a HashSet
and assert contains/len) and for TraversalMode; 2) a compile-time shape test for
the CascadeWalker trait by declaring a tiny local struct that implements
CascadeWalker (implement walk_dependents as a no-op) and calling its
walk_dependents with a dummy MailboxRow, Option<CascadeKind> and TraversalMode
to ensure signatures (refer to CascadeKind, TraversalMode, CascadeWalker, and
MailboxRow); keep tests scoped and small, using assert_eq!/assert_ne! and basic
HashSet assertions.
🤖 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 @.claude/board/AGENT_LOG.md:
- Line 3: Update the log entry that currently states the deferred bodies are
marked with "/// work" to reflect the actual comment style used in the codebase:
replace the phrase "/// work" with the exact text "// TODO(Stage 2)" in the
board entry so grep-based follow-ups match the source; ensure the sentence still
mentions that advancement verbs past resolve_ogit have TODO comments and keep
the rest of the wording intact (reference the phrase "advancement verbs past
`resolve_ogit`" and the marker strings "/// work" → "// TODO(Stage 2)").

In `@crates/lance-graph-contract/src/cognition/advance.rs`:
- Around line 37-60: Add a colocated #[cfg(test)] module in this file that
contains focused unit tests for the stage-transition and chaining behavior:
write tests that construct a NormalizedEntity<Raw>, call resolve_ogit (using a
test double or mock OgitCtx that returns a known URI) and assert the returned
NormalizedEntity<WithOgit> has ogit populated and other fields preserved; add
tests for advance_stage and any chain transition methods to verify stages change
as expected and that output (if present) produces the expected result when
invoked; keep tests small and targeted (one scenario per test), reference the
functions resolve_ogit, advance_stage, output and any chain transition methods
to locate code, and put them under #[cfg(test)] mod tests with simple test
helpers/mocks for OgitCtx.

In `@crates/lance-graph-contract/src/cognition/cascade.rs`:
- Around line 80-86: The doc comment for the enum is inconsistent: it claims
server actions are encoded as `Other`+tag but the enum already exposes a
`ServerAction` variant; update the documentation for the enum (referencing the
`ServerAction` and `Other` variants) so they follow one model—either (A)
document that server actions are represented by the `ServerAction` variant and
describe its encoding/usage, or (B) remove/adjust the `ServerAction` variant and
document that server actions are encoded via `Other`+tag; ensure the comment
clarifies which variant to use and how tags are interpreted to prevent
misimplementation.
- Around line 167-186: The CascadeWalker trait's walk_dependents currently
returns () so callers cannot obtain the produced dependent set; change the API
to surface dependents by either (a) changing fn walk_dependents(&self, from:
MailboxRow, kind_filter: Option<CascadeKind>, mode: TraversalMode) -> Box<dyn
Iterator<Item = MailboxRow> + '_> (or an associated Iterator type) or (b) add a
callback/sink parameter (e.g., &mut dyn FnMut(MailboxRow) or a &mut
Vec<MailboxRow>) so implementors of CascadeWalker can yield each dependent;
update the trait definition and all implementors and callers of
CascadeWalker::walk_dependents (and any tests) to use the chosen return/consumer
form so the Stage 2 fan-out can be expressed at the type level.

In `@crates/lance-graph-contract/src/cognition/entity.rs`:
- Around line 26-27: The documented envelope allows up to 256K rows but the
entity field row_idx is declared as u16 (in the struct in
crates/lance-graph-contract/src/cognition/entity.rs), which overflows at 65,535;
change the field type from u16 to a wider integer (e.g., u32) in the struct(s)
and any other locations referencing row_idx, update constructors/serializers and
pattern matches to use the new type, and adjust the doc comment to remain
consistent (or lower the documented limit if you intend to keep u16); ensure any
tests or conversions that assumed u16 are updated accordingly.
- Around line 144-185: NormalizedEntity's public stage fields (eg. ogit, owl,
dolce, fibu, and the row lens) and its public advance_stage method allow callers
to bypass the typestate sequencing; make the stage slots private (remove pub
from ogit, owl, dolce, fibu and the row field) and restrict direct mutation,
then replace/limit advance_stage visibility (make advance_stage pub(crate) or
private) and provide explicit controlled advancement APIs (eg. methods named
resolve_ogit, hydrate_owl, classify_dolce, align_fibu on NormalizedEntity that
perform the validations and set the corresponding private fields), plus public
getters (as_refs) for read-only access; reference NormalizedEntity, the
ogit/owl/dolce/fibu fields, row, and advance_stage when applying the changes.

In `@crates/lance-graph-contract/src/transaction/interactive.rs`:
- Around line 54-107: Add a small #[cfg(test)] mod tests that verifies the
Interactive contract surface: create an Interactive via Interactive::new() and
assert Default::default() == Interactive::new() (or that default constructs an
Interactive), then call the trait methods resolve_ogit, hydrate_owl,
classify_dolce, and align_fibu (via the Interactive instance or trait object)
and assert each currently panics/todos (use std::panic::catch_unwind or
#[should_panic] with the expected todo! messages) so the constructor/default and
trait-impl stubs are covered; reference the Interactive type and its new(),
Default impl, and the OgitCtx::resolve_ogit, OwlCtx::hydrate_owl,
DolceCtx::classify_dolce, FibuCtx::align_fibu methods to locate where to add the
tests.

In `@crates/lance-graph-contract/tests/cognition_typestate.rs`:
- Around line 1-66: The compile_fail doctests in tests/cognition_typestate.rs
aren’t run by CI because that file lives under tests/ and the crate is tested
with --lib; move the proof examples into crate documentation under
crates/lance-graph-contract/src (e.g., lib.rs or a dedicated module doc) so
rustdoc will run them, or add a trybuild harness in
crates/lance-graph-contract/src/tests/ that asserts the same failures (using
examples referencing NormalizedEntity<Raw>, NormalizedEntity<Reviewed>,
NormalizedEntity<Reported>, Stage and the sealed supertrait) and/or update CI to
invoke cargo test --manifest-path crates/lance-graph-contract/Cargo.toml --doc
so the existing compile_fail blocks are executed.

In `@docs/COGNITION_HOLY_GRAIL.md`:
- Around line 27-28: Update the docs text that currently refers to `/// work`
markers so it instead mentions the current anchor format `// TODO(Stage 2)` used
in the codebase (e.g., in `op.rs`); change the phrase "see `/// work` markers"
to something like "see `// TODO(Stage 2)` markers" and ensure any surrounding
explanatory text directs readers to search for `// TODO(Stage 2)` call-site
anchors.

---

Nitpick comments:
In `@crates/lance-graph-contract/src/cognition/cascade.rs`:
- Around line 1-187: Add a #[cfg(test)] mod tests in this file with focused unit
tests: 1) test equality and Hash behavior for CascadeKind (e.g., insert variants
into a HashSet and assert contains/len) and for TraversalMode; 2) a compile-time
shape test for the CascadeWalker trait by declaring a tiny local struct that
implements CascadeWalker (implement walk_dependents as a no-op) and calling its
walk_dependents with a dummy MailboxRow, Option<CascadeKind> and TraversalMode
to ensure signatures (refer to CascadeKind, TraversalMode, CascadeWalker, and
MailboxRow); keep tests scoped and small, using assert_eq!/assert_ne! and basic
HashSet assertions.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d6272fec-d869-4aec-ad99-47b15c82e40c

📥 Commits

Reviewing files that changed from the base of the PR and between 7bd38a1 and 8b3efca.

📒 Files selected for processing (19)
  • .claude/board/AGENT_LOG.md
  • .claude/board/EPIPHANIES.md
  • .claude/board/INTEGRATION_PLANS.md
  • .claude/board/STATUS_BOARD.md
  • .claude/plans/normalized-entity-holy-grail-v1.md
  • crates/lance-graph-contract/src/cognition/advance.rs
  • crates/lance-graph-contract/src/cognition/cascade.rs
  • crates/lance-graph-contract/src/cognition/entity.rs
  • crates/lance-graph-contract/src/cognition/mod.rs
  • crates/lance-graph-contract/src/cognition/op.rs
  • crates/lance-graph-contract/src/cognition/stages.rs
  • crates/lance-graph-contract/src/lib.rs
  • crates/lance-graph-contract/src/transaction/bulk.rs
  • crates/lance-graph-contract/src/transaction/ctx.rs
  • crates/lance-graph-contract/src/transaction/interactive.rs
  • crates/lance-graph-contract/src/transaction/mod.rs
  • crates/lance-graph-contract/src/transaction/periodisch.rs
  • crates/lance-graph-contract/tests/cognition_typestate.rs
  • docs/COGNITION_HOLY_GRAIL.md

Comment thread .claude/board/AGENT_LOG.md Outdated
Comment on lines +37 to +60
impl NormalizedEntity<Raw> {
/// Stage 1 → Stage 2: resolve Odoo model_name → OGIT URI.
///
/// Dispatches into the OGIT codebook via the transaction context
/// (which implements [`OgitCtx`]). Returns a `NormalizedEntity`
/// with the `ogit` slot populated.
///
/// Per E-CODEBOOK-INHERITS-FROM-OGIT: the resolved URI is a
/// stable codebook row index, not a freshly hashed value.
///
// TODO(Stage 2): also need to write back the resolved OGIT identity
// into the owning mailbox's SoA fingerprint column. Stage 2
// wires this once `cognitive-shader-driver` is a hard dep of
// contract (or the write-back goes through a trait adapter).
pub fn resolve_ogit<C: OgitCtx>(self, ctx: &C) -> NormalizedEntity<WithOgit> {
let ogit = ctx.resolve_ogit(self.odoo.0);
// Use advance_stage to copy the struct without touching _stage directly,
// then overwrite the ogit field via a fresh struct built from the advanced base.
// We need to set ogit, so we build from scratch using the public fields.
let mut advanced = self.advance_stage::<WithOgit>();
advanced.ogit = Some(ogit);
advanced
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add colocated #[cfg(test)] unit tests for advancement and chain methods.

The file adds core behavior (resolve_ogit, chain transitions, output) but has no alongside unit-test module. Please add focused in-file tests for stage transition correctness and slot population on the implemented paths.

As per coding guidelines, "Add Rust unit tests alongside implementations via #[cfg(test)] modules; prefer focused scenarios over broad integration tests".

Also applies to: 118-228

🤖 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/lance-graph-contract/src/cognition/advance.rs` around lines 37 - 60,
Add a colocated #[cfg(test)] module in this file that contains focused unit
tests for the stage-transition and chaining behavior: write tests that construct
a NormalizedEntity<Raw>, call resolve_ogit (using a test double or mock OgitCtx
that returns a known URI) and assert the returned NormalizedEntity<WithOgit> has
ogit populated and other fields preserved; add tests for advance_stage and any
chain transition methods to verify stages change as expected and that output (if
present) produces the expected result when invoked; keep tests small and
targeted (one scenario per test), reference the functions resolve_ogit,
advance_stage, output and any chain transition methods to locate code, and put
them under #[cfg(test)] mod tests with simple test helpers/mocks for OgitCtx.

Comment thread crates/lance-graph-contract/src/cognition/cascade.rs Outdated
Comment thread crates/lance-graph-contract/src/cognition/cascade.rs
Comment thread crates/lance-graph-contract/src/cognition/entity.rs Outdated
Comment thread crates/lance-graph-contract/src/cognition/entity.rs
Comment on lines +54 to +107
impl Interactive {
/// Construct a new `Interactive` context.
///
/// In Stage 1 this is a no-op constructor. Stage 2 wires the live
/// Lance read handle and Baton emission queue.
pub fn new() -> Self {
Self { _placeholder: () }
}
}

impl Default for Interactive {
fn default() -> Self {
Self::new()
}
}

// ── Trait impls ───────────────────────────────────────────────────────────────

impl Context for Interactive {}

impl OgitCtx for Interactive {
fn resolve_ogit(&self, _model_name: &'static str) -> OgitUriRef {
// TODO(Stage 2): dispatch into `crate::callcenter::ogit_uris` for the
// canonical OGIT URI lookup. The codebook maps `model_name`
// to a stable `OgitUriRef` via `OntologyRegistry::resolve`.
// Stage 2 also writes the resolved code into the owning
// mailbox's SoA fingerprint column via the Baton emission
// queue (E-CODEBOOK-INHERITS-FROM-OGIT).
todo!("D-NEH-2 wires the real OGIT codebook lookup via callcenter::ogit_uris")
}
}

impl OwlCtx for Interactive {
fn hydrate_owl(&self, _ogit_uri: OgitUriRef) -> OwlClassRef {
// TODO(Stage 2): dispatch OWL hydration via the TTL-join registry.
// Stage 2 wires this against the EXT-1 OWL extraction.
todo!("D-NEH-2 wires the OWL hydrator (TTL join on OGIT URI)")
}
}

impl DolceCtx for Interactive {
fn classify_dolce(&self, _owl_class: OwlClassRef) -> DolceCategory {
// TODO(Stage 2): dispatch into lance_graph_ontology::dolce_odoo::DolceClassifier.
todo!("D-NEH-2 wires the DOLCE classifier from lance-graph-ontology::dolce_odoo")
}
}

impl FibuCtx for Interactive {
fn align_fibu(&self, _dolce: DolceCategory, _odoo: OdooEntityRef) -> FibuAlignmentRef {
// TODO(Stage 2): dispatch into the Kontenerkennung alignment tables
// (SKR03/SKR04, UStVA Kennzahlen, GoBD wiring).
todo!("D-NEH-2 wires the FIBU/FIBO alignment overlay from EXT-1..6")
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether this file already has colocated unit tests.
rg -n -C2 'cfg\(test\)|mod tests' crates/lance-graph-contract/src/transaction/interactive.rs

Repository: AdaWorldAPI/lance-graph

Length of output: 49


Add focused local #[cfg(test)] coverage for Interactive contract surface.

crates/lance-graph-contract/src/transaction/interactive.rs currently has no colocated #[cfg(test)] / mod tests, so the constructor/default and trait-impl contract remains unguarded.

♻️ Proposed patch
 impl FibuCtx for Interactive {
     fn align_fibu(&amp;self, _dolce: DolceCategory, _odoo: OdooEntityRef) -&gt; FibuAlignmentRef {
         // TODO(Stage 2): dispatch into the Kontenerkennung alignment tables
         // (SKR03/SKR04, UStVA Kennzahlen, GoBD wiring).
         todo!("D-NEH-2 wires the FIBU/FIBO alignment overlay from EXT-1..6")
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    fn assert_ctx_impls&lt;T: Context + OgitCtx + OwlCtx + DolceCtx + FibuCtx&gt;() {}
+
+    #[test]
+    fn interactive_implements_all_stage_context_traits() {
+        assert_ctx_impls::&lt;Interactive&gt;();
+    }
+
+    #[test]
+    fn interactive_new_and_default_construct() {
+        let _ = Interactive::new();
+        let _ = Interactive::default();
+    }
+}
🤖 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/lance-graph-contract/src/transaction/interactive.rs` around lines 54 -
107, Add a small #[cfg(test)] mod tests that verifies the Interactive contract
surface: create an Interactive via Interactive::new() and assert
Default::default() == Interactive::new() (or that default constructs an
Interactive), then call the trait methods resolve_ogit, hydrate_owl,
classify_dolce, and align_fibu (via the Interactive instance or trait object)
and assert each currently panics/todos (use std::panic::catch_unwind or
#[should_panic] with the expected todo! messages) so the constructor/default and
trait-impl stubs are covered; reference the Interactive type and its new(),
Default impl, and the OgitCtx::resolve_ogit, OwlCtx::hydrate_owl,
DolceCtx::classify_dolce, FibuCtx::align_fibu methods to locate where to add the
tests.

Comment thread crates/lance-graph-contract/tests/cognition_typestate.rs Outdated
Comment thread docs/COGNITION_HOLY_GRAIL.md Outdated
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Actionable comments posted: 0

…row_idx + cascade sink + stale-marker fixes

Addresses Codex P1 + P2 and 6 CodeRabbit findings on the
normalized-entity-holy-grail-v1 Stage 1 surface. Two findings
(colocated unit tests in advance.rs + interactive.rs) deferred
to Stage 2 when concrete kernel bodies exist.

CRITICAL — typestate teeth (Codex P1):
- NormalizedEntity::advance_stage was pub; external code could
  cast Raw → Reported. Renamed to advance_stage_internal and
  demoted to pub(crate). External Op implementors cannot
  construct any NormalizedEntity<S> for S != Raw.
- Op trait redesigned: implementors override only step() (a
  validation + side-effect hook with default no-op success) +
  kind(). No more public apply() to override. Framework's chain
  methods (op / chk_data / review / abduct / report) call
  op.step() then perform the sealed transition.
- New OpError type carries a &'static str for Stage 1; Stage 2
  widens to typed reason enum + row ref for audit trail.

CORRECTNESS — row_idx widening (Codex P2 + CodeRabbit 5):
- MailboxRow::row_idx: u16 → u32. Matches PR #427's symmetric
  mailbox_ref widening; satisfies the documented 64K-256K
  per-mailbox envelope.

API DESIGN — CascadeWalker sink (CodeRabbit 4):
- CascadeWalker::walk_dependents now takes
  on_dependent: &mut dyn FnMut(MailboxRow). The walker output
  is expressible at the type level.

DOC DRIFT (CodeRabbit 1, 3, 9):
- cascade.rs: ServerAction doc no longer claims "encoded as
  Other + tag" (it IS its own variant).
- AGENT_LOG.md first entry + docs/COGNITION_HOLY_GRAIL.md:
  stale /// work references → // TODO(Stage 2): to match the
  post-strip state.

INTEGRATION TEST FIXUP:
- tests/cognition_typestate.rs: 5 fake Op impls (NoopOp,
  FakeChkData, FakeReview, FakeAbduct, FakeReport) updated to
  the new step()-only shape. Their old apply() overrides
  (which called the now-pub(crate) advance_stage) removed;
  default no-op step() suffices.

DEFERRED TO STAGE 2 (CodeRabbit 2, 7):
- Colocated #[cfg(test)] tests in advance.rs + interactive.rs.

Tests post-fix:
- cargo clippy -D warnings clean
- cargo test --lib green (472 tests)
- cargo test --test cognition_typestate green (7 tests)
- cargo test --doc green (3 tests; new compile_fail block in
  src/cognition/mod.rs proves the typestate seal)

https://claude.ai/code/session_017gZ6sPRXYPj5n7uJ7NBtRv

@coderabbitai coderabbitai 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.

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/lance-graph-contract/src/cognition/op.rs`:
- Around line 129-143: The trait method step(&self, entity:
&NormalizedEntity<I>) -> Result<(), OpError> currently promises Err(...) halts
progression but advance.rs ignores that; update the chain execution in
advance.rs so that callers of Op::step check the Result and stop advancing
(propagate/return the OpError) when Err is returned, ensuring entities are not
moved to later stages on validation failure; adjust any intermediate chain
methods to propagate the Result<_, OpError> instead of discarding it so the halt
semantics declared by step (and types NormalizedEntity<I>/O and OpError) are
honored.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9a08678a-f7d5-4d3c-b3c6-588334ac43e1

📥 Commits

Reviewing files that changed from the base of the PR and between eb6e802 and 3c93490.

📒 Files selected for processing (8)
  • .claude/board/AGENT_LOG.md
  • crates/lance-graph-contract/src/cognition/advance.rs
  • crates/lance-graph-contract/src/cognition/cascade.rs
  • crates/lance-graph-contract/src/cognition/entity.rs
  • crates/lance-graph-contract/src/cognition/mod.rs
  • crates/lance-graph-contract/src/cognition/op.rs
  • crates/lance-graph-contract/tests/cognition_typestate.rs
  • docs/COGNITION_HOLY_GRAIL.md
✅ Files skipped from review due to trivial changes (2)
  • docs/COGNITION_HOLY_GRAIL.md
  • .claude/board/AGENT_LOG.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • crates/lance-graph-contract/src/cognition/mod.rs
  • crates/lance-graph-contract/src/cognition/cascade.rs
  • crates/lance-graph-contract/src/cognition/advance.rs

Comment thread crates/lance-graph-contract/src/cognition/op.rs
AdaWorldAPI pushed a commit that referenced this pull request May 28, 2026
…nd-v1

Hand-crafted Stage 2 trunk plans for the holy-grail substrate, per the
2026-05-28 architectural session:

1. `.claude/plans/unified-spo-nars-codegen-v1.md` (~400 lines) — THE
   trunk follow-up to `normalized-entity-holy-grail-v1` Stage 1 (PR
   #431). Absorbs four architectural layers identified during the
   session: per-verb NARS auto-emission, capability-level method
   emergence from predicate conjunctions, meta-capability analogical
   transfer across domains, and the LabelDTO compression. Final
   consequence: substrate is one DTO type + one codebook + one chain;
   all typed shapes codegen'd from `format:domain:ogit` URNs.

   Six waves of deliverables (D-USN-1..Σ-3): typed surface + OGIT root
   vocabulary additions + HydratorCodegen pipeline + auto-emission +
   medical-side EXT projection + capabilities + meta-capabilities +
   LabelDTO carrier compression.

2. `.claude/plans/lance-graph-elixir-frontend-v1.md` (~250 lines) —
   Stage 5/8: Elixir-syntax script frontend that domain experts read
   + write; tree-sitter-elixir parser + typestate-aware resolver +
   Rust codegen against the codebook. **No BEAM at runtime** —
   Elixir is the SURFACE only; substrate stays typed Rust + SIMD +
   JIT. Eight deliverables (D-LGE-1..8); gated on `unified-spo-nars
   -codegen-v1` Wave D + Σ shipping the codebook target.

Plus board hygiene:
- INTEGRATION_PLANS.md PREPENDed with both plan entries
- EPIPHANIES.md PREPENDed with 15 load-bearing epiphanies from the
  session: E-LABEL-DTO-IS-THE-SUBSTRATE-1, E-FORMAT-DOMAIN-OGIT-IS
  -THE-URN-SCHEME-1, E-CODEBOOK-IS-THE-COMPILATION-TARGET-1, E-SHARE
  -SUBSTRATE-SEPARATE-OPERATIONS-1 (the SoC correction to LabelDTO),
  E-HYDRATOR-AS-OGIT-CODEGEN-1, E-EVERY-VERB-EMITS-NARS-METHODS-1,
  E-SPO-IS-THE-COMMON-OUTPUT-1, E-CAPABILITY-FROM-PREDICATE-CONJUNCTION
  -1, E-CROSS-DOMAIN-CAPABILITY-1, E-NARS-COMPOUND-TERM-IS-THE
  -CAPABILITY-1, E-META-CAPABILITY-PATTERN-1, E-NARS-CLOSED-UNDER-META
  -ELEVATION-1, E-NEW-DOMAIN-AUTO-METABOLIZES-1, E-MEDICAL-MIRRORS
  -FINANCIAL-1, E-FOUR-AXIS-DECOMPOSITION-1.

Plans authored on main thread (Opus accumulation); deliverable execution
is delegation-ready per the new agent workflow (per-wave Sonnet
spawning; main-thread review at wave boundaries; PRs against
adaworldapi/lance-graph + adaworldapi/OGIT).

https://claude.ai/code/session_017gZ6sPRXYPj5n7uJ7NBtRv
…-1 halt docs + CI gates

Three of the four remaining review findings on PR #431 (the typestate
cast is already locked via `advance_stage_internal` + `pub(crate)`; the
remaining items are field visibility, halt-semantics doc, and
compile_fail-gating in CI).

## Fix 1 — Lock NormalizedEntity fields to `pub(crate)`
(coderabbit Major, entity.rs:144-185)

Public stage slots (`odoo` / `ogit` / `owl` / `dolce` / `fibu` / `row`)
allowed external code to construct an arbitrary-stage entity directly
via struct-literal syntax, bypassing the five-verb algebra. Made all
six fields `pub(crate)`; external consumers continue to use the
already-existing public getters (`odoo()`, `ogit()`, `owl()`,
`dolce()`, `fibu()`, `row()`) for read access.

The typestate guarantee now holds: every write goes through
`advance_stage_internal` (also `pub(crate)`), which is only callable
from the verb methods defined in `advance.rs`.

## Fix 2 — Document Stage-1 non-halting chain execution
(coderabbit Major, op.rs:129-143 + advance.rs:140-145)

`Op::step()` doc claimed `Err(...)` halts the chain, but the chain
methods on `NormalizedEntity` (`op`, `chk_data`, `review`, `abduct`,
`report`) actually discard the `Result` via `let _ = ...` and advance
regardless. The current advance.rs comment ("Stage 1: ignore step
errors") only flagged this on `op()`.

Updated `Op::step()` rustdoc with a new "## Stage 1 halt semantics"
section that explicitly says: chain methods drop the Result;
implementors needing to halt must `panic!` or return a stage with no
further chain methods. Stage 2 (D-NEH-2) wires real `Result`
propagation through the chain.

## Fix 3 — Gate `compile_fail` typestate proofs in CI
(coderabbit Major, tests/cognition_typestate.rs:1-66)

`crates/lance-graph-contract` runs only `cargo test --lib` in CI, so:
- the integration test under `tests/cognition_typestate.rs` was never
  executed, and
- the `compile_fail` doctests in its `//!` module-level docs were
  silently un-gated (rustdoc doesn't run doctests on integration test
  crates).

Two-part fix:

1. Moved the 4 `compile_fail` proofs into `src/cognition/mod.rs`
   under a new "## What the type system forbids (compile-fail proofs)"
   section. `cargo test --doc` reliably picks them up there (verified
   locally: doctest count 6 → 10, all 4 new tests pass).
2. Added two CI steps to `rust-test.yml`:
   - `cargo test ... --tests` runs the integration test crate
     (positive `#[test]` functions).
   - `cargo test ... --doc` runs library doctests including the new
     `compile_fail` blocks.

The integration test file is reduced to a docstring pointing at the
canonical location plus its existing positive `#[test]` functions
(constructor smoke, Op trait impl, OpKind/Output coverage).

## Verification (orchestrator-run, contract crate only)

- `cargo test ... --lib`   → 472/472 passed (no regression).
- `cargo test ... --tests` → 4/4 passed (new CI gate).
- `cargo test ... --doc`   → 7 passed + 3 ignored = 10 total
  (was 3 + 3 = 6; +4 compile_fail proofs now enforced).
- `cargo fmt --check`      → clean on the 4 files touched.

No new dependencies; lance-graph-contract stays zero-dep std-only.

@coderabbitai coderabbitai 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.

Caution

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

⚠️ Outside diff range comments (1)
.github/workflows/rust-test.yml (1)

24-84: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add least-privilege permissions for GITHUB_TOKEN in rust-test.yml

.github/workflows/rust-test.yml has no top-level permissions: block, so GITHUB_TOKEN scopes fall back to repo/org defaults. Because the workflow only checks out code and runs tests, restrict the token to read-only (at least contents: read).

Suggested fix
 name: Rust Tests
 on:
   push:
@@
   pull_request:
@@
       - .github/workflows/rust-test.yml
+
+permissions:
+  contents: read
🤖 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 @.github/workflows/rust-test.yml around lines 24 - 84, Add a top-level
permissions block to the workflow to follow least-privilege for GITHUB_TOKEN:
set permissions: contents: read (and any other minimal read-only scopes needed)
for the entire workflow that defines the "test" job and its steps (e.g., the
checkout and test steps), ensuring the GITHUB_TOKEN does not inherit broader
repo/org defaults.
🤖 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.

Outside diff comments:
In @.github/workflows/rust-test.yml:
- Around line 24-84: Add a top-level permissions block to the workflow to follow
least-privilege for GITHUB_TOKEN: set permissions: contents: read (and any other
minimal read-only scopes needed) for the entire workflow that defines the "test"
job and its steps (e.g., the checkout and test steps), ensuring the GITHUB_TOKEN
does not inherit broader repo/org defaults.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: af935e41-f8de-4195-b0b0-87553f234ef5

📥 Commits

Reviewing files that changed from the base of the PR and between 3c93490 and 5d5c4e2.

📒 Files selected for processing (5)
  • .github/workflows/rust-test.yml
  • crates/lance-graph-contract/src/cognition/entity.rs
  • crates/lance-graph-contract/src/cognition/mod.rs
  • crates/lance-graph-contract/src/cognition/op.rs
  • crates/lance-graph-contract/tests/cognition_typestate.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/lance-graph-contract/src/cognition/mod.rs
  • crates/lance-graph-contract/src/cognition/op.rs

@AdaWorldAPI AdaWorldAPI merged commit 108bcd6 into main May 29, 2026
6 checks passed
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