Skip to content

core: single-own compiled observation schemas - #460

Closed
lemone112 wants to merge 2 commits into
agent/owner-bound-program-projectionfrom
agent/session-schema-ssot
Closed

core: single-own compiled observation schemas#460
lemone112 wants to merge 2 commits into
agent/owner-bound-program-projectionfrom
agent/session-schema-ssot

Conversation

@lemone112

@lemone112 lemone112 commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Stack

Depends on #459. This is a stacked draft and must not be merged independently.

Law

The canonical observation schema is compiled-contract state, not generic runtime lifecycle state.

  • a Program schema is owned only by its exact compiled epoch;
  • a point-support schema is owned only by its compiled plan;
  • Session first pins the exact owner, then derives the schema from that same lease for both keyed and packed/schema-ordered admission;
  • empty/Unknown Program Sessions add no schema Rc handle;
  • an admitted immutable observation adds exactly one lifetime handle, shared by raw head and evidence;
  • value-equal schemas from another owner never gain authority.

General production Clone was removed from the schema type. The sole sharing capability is private to observation admission.

Proof

  • RED: Program owner count was 2 after one empty Session; point-support count was 2 after construction
  • GREEN: Program stays 1 for any empty Sessions, becomes 2 for one retained observation, replay remains 2, drop returns 1
  • GREEN: point-support stays 1 through Session construction, becomes 2 for retained observation, replay remains 2
  • Core: 756 passed, 6 ignored
  • Full workspace/all targets: passed
  • Clippy workspace/all targets with -D warnings: passed
  • Rustdoc + external Program boundary + WASM target: passed
  • Rust 1.85 MSRV: passed
  • Manual fresh-Rc mutant: both Program and point-support hostile tests RED
  • Full production source scan freezes the two allowed SessionPlanV1 implementations
  • Point-support proof source binding: 5/5; canonical replay byte-exact on system Python 3.9
  • Three independent architecture/performance/proof reviews: PASS

Proof rebind

The source closure changed, so the existing exact point-support proof was replayed and regenerated. Human/numerical claims, domains, exclusions, algebra and envelopes are unchanged; only binding/digest metadata changed. The verifier now preserves the same strict-length invariant on Python 3.9.

Next stacked slice

Hard-cut hidden package_bridge to an intentional documented public program Rust API, without aliases or root re-exports. That rename will remain explicitly distinct from the later Program→WASM/browser runtime cutover.

Summary by CodeRabbit

  • Надёжность

    • Улучшено управление и разделение канонической схемы наблюдений между обновлениями сессий без лишних копий.
    • Схема теперь однозначно привязывается к владельцу и корректно переиспользуется при повторных инстансах.
  • Проверки

    • Расширены граничные тесты для обычных и упорядоченных сценариев обновления.
    • Усилены проверки независимости данных между владельцами и точности порядка операций.
    • Обновлены верификационные расчёты для point-support surplus и контроль целостности входных сертификатов.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a4fb4d01-6910-41a9-994a-e88312c03a75

📥 Commits

Reviewing files that changed from the base of the PR and between f574140 and 43d9498.

📒 Files selected for processing (11)
  • crates/labcolors-core/contracts/point-support-reference-surplus-q55-bps-proof-v1.json
  • crates/labcolors-core/src/generic_boundary_tests.rs
  • crates/labcolors-core/src/observation.rs
  • crates/labcolors-core/src/observation_tests.rs
  • crates/labcolors-core/src/point_support.rs
  • crates/labcolors-core/src/point_support_tests.rs
  • crates/labcolors-core/src/program_session.rs
  • crates/labcolors-core/src/program_session_tests.rs
  • crates/labcolors-core/src/session.rs
  • crates/labcolors-core/src/session_tests.rs
  • scripts/verify_point_support_surplus.py

Walkthrough

Каноническая схема наблюдений больше не хранится отдельно в сессиях и планах: она извлекается через OwnerLease и явно разделяется при admission. Обновлены реализации планов, проверки владения, тесты жизненного цикла и контрольные хэши proof-артефакта.

Changes

Владение схемой и admission

Layer / File(s) Summary
Контракт схемы и admission
crates/labcolors-core/src/observation.rs, crates/labcolors-core/src/session.rs, crates/labcolors-core/src/point_support.rs
CanonicalObservationSchemaV1 больше не реализует production-Clone; схема разделяется через share_for_observation(), а SessionPlanV1::observation_schema принимает OwnerLease.
Интеграция Session и ProgramSessionPlan
crates/labcolors-core/src/session.rs, crates/labcolors-core/src/program_session.rs
Session и ProgramSessionPlan удаляют собственные schema-поля и получают схему из owner generation при keyed и schema-ordered обновлениях.
Проверки владения и жизненного цикла
crates/labcolors-core/src/*_tests.rs
Тесты проверяют backing pointers, strong counts, отсутствие лишнего клонирования, порядок admission и поведение при замене owner generation.
Обновление проверки сертификата
crates/labcolors-core/contracts/*.json, scripts/verify_point_support_surplus.py
Обновлены контрольные хэши proof/source closure и логика verifier для актуального исходного кода и проверки разреженных полиномов.

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

Sequence Diagram(s)

sequenceDiagram
  participant Session
  participant OwnerLease
  participant SessionPlanV1
  participant ObservationAdmission
  Session->>OwnerLease: try_acquire_owner()
  Session->>SessionPlanV1: observation_schema(&owner)
  SessionPlanV1-->>Session: canonical schema reference
  Session->>ObservationAdmission: prepare_observation(schema)
  ObservationAdmission->>ObservationAdmission: share_for_observation()
Loading

Possibly related issues

Possibly related PRs

  • Labpics-Team/lab-colors#447: напрямую связан с обновлением proof-контракта и ожиданий verifier для point-support retained-surplus.
🚥 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 Заголовок кратко и точно отражает основную суть PR: привязку скомпилированных схем наблюдений к одному владельцу.
Docstring Coverage ✅ Passed Docstring coverage is 93.48% 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.
✨ 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 agent/session-schema-ssot

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

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

Please review this stacked schema-SSOT slice for exact-owner/schema coupling, lifetime and Rc-count regressions, hidden allocations, equal-content authority leaks, proof-rebind honesty, and Python verifier portability. It must not be assessed as independently mergeable from #459.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

@lemone112 I’ll review this as a stacked slice dependent on #459—not as independently mergeable—with particular attention to exact compiled-owner/schema coupling, Rc lifetimes and counts, hidden allocations, equal-content authority boundaries, proof-rebind integrity, and Python verifier portability.

✅ Action performed

Review finished.

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

@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 `@scripts/verify_point_support_surplus.py`:
- Around line 388-392: Добавьте короткий комментарий перед вызовом zip в участке
с assert len(left_monomial) == len(right_monomial), объясняющий, что явная
проверка равенства длин гарантирует строгий zip, а zip(..., strict=True) не
используется для сохранения совместимости с Python 3.9.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f508d0ca-464e-44f3-86dc-c76187356c6e

📥 Commits

Reviewing files that changed from the base of the PR and between d00c63e and f574140.

📒 Files selected for processing (11)
  • crates/labcolors-core/contracts/point-support-reference-surplus-q55-bps-proof-v1.json
  • crates/labcolors-core/src/generic_boundary_tests.rs
  • crates/labcolors-core/src/observation.rs
  • crates/labcolors-core/src/observation_tests.rs
  • crates/labcolors-core/src/point_support.rs
  • crates/labcolors-core/src/point_support_tests.rs
  • crates/labcolors-core/src/program_session.rs
  • crates/labcolors-core/src/program_session_tests.rs
  • crates/labcolors-core/src/session.rs
  • crates/labcolors-core/src/session_tests.rs
  • scripts/verify_point_support_surplus.py

Comment thread scripts/verify_point_support_surplus.py
lemone112 added a commit that referenced this pull request Jul 25, 2026
…fact

The exact-length gate still pinned 376830B from
`canonical-authored-program-lowerer` (#456, run 29971399220). This slice
grew the runtime artifact to 376985B and did not carry the re-pin that
every earlier stacked slice performed (#450, #452, #454, #456), so the
gate has rejected this head and every head above it.

The +155B is attributable to this slice alone: runs 30115821523 (#457),
30124467410 (#458), 30125634830 (#459), 30129537515 (#460) and
30136346868 (#461) all measure exactly 376985B, so #458-#461 contribute
zero bytes to the artifact and were failing only on the inherited pin.

The new measurement is the CI run for this exact head
(39ee0a7), not a local build: the
canonical platform is linux-x64 and a local arm64 build only produces a
DIAGNOSTIC result. The budget file's own SHA-256 is re-pinned in the
checker so the drift gate keeps rejecting unattributed edits.

Co-Authored-By: Claude <noreply@anthropic.com>
@lemone112
lemone112 force-pushed the agent/owner-bound-program-projection branch from d00c63e to 6d9044b Compare July 25, 2026 17:01
@lemone112
lemone112 force-pushed the agent/session-schema-ssot branch from f574140 to cdba3fb Compare July 25, 2026 17:01
lemone112 added a commit that referenced this pull request Jul 26, 2026
This slice moves files inside the point-support semantic cone, so the capsule
digest and the committed surplus proof move with it. Both are now regenerated in
the same commit that causes the drift, matching the convention the rest of the
stack follows; previously the re-bind was batched at #460, which left #457-#459
fail-closed on their own heads and made the stack unmergeable in order.

Numerical review: every proof field is unchanged. Only the source-binding
identities move -- the file hashes of the cone files this slice edits, the
resulting closure digest, the verifier hash and the rolled-up payload hash.
The surplus mathematics is byte-identical.

Co-Authored-By: Claude <noreply@anthropic.com>
lemone112 added a commit that referenced this pull request Jul 26, 2026
This slice moves files inside the point-support semantic cone, so the capsule
digest and the committed surplus proof move with it. Both are now regenerated in
the same commit that causes the drift, matching the convention the rest of the
stack follows; previously the re-bind was batched at #460, which left #457-#459
fail-closed on their own heads and made the stack unmergeable in order.

Numerical review: every proof field is unchanged. Only the source-binding
identities move -- the file hashes of the cone files this slice edits, the
resulting closure digest, the verifier hash and the rolled-up payload hash.
The surplus mathematics is byte-identical.

Co-Authored-By: Claude <noreply@anthropic.com>
lemone112 added a commit that referenced this pull request Jul 26, 2026
This slice moves files inside the point-support semantic cone, so the capsule
digest and the committed surplus proof move with it. Both are now regenerated in
the same commit that causes the drift, matching the convention the rest of the
stack follows; previously the re-bind was batched at #460, which left #457-#459
fail-closed on their own heads and made the stack unmergeable in order.

Numerical review: every proof field is unchanged. Only the source-binding
identities move -- the file hashes of the cone files this slice edits, the
resulting closure digest, the verifier hash and the rolled-up payload hash.
The surplus mathematics is byte-identical.

Co-Authored-By: Claude <noreply@anthropic.com>
@lemone112
lemone112 force-pushed the agent/owner-bound-program-projection branch from 6d9044b to 8b5fb46 Compare July 26, 2026 04:18
@lemone112
lemone112 force-pushed the agent/session-schema-ssot branch from cdba3fb to 35472cb Compare July 26, 2026 04:18
@lemone112

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

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

lemone112 added a commit that referenced this pull request Jul 26, 2026
* feat(core): compile generic point-render sessions

* fix(core): satisfy format and all-target lint gates

* perf(core): recycle point-render session buffers

* style(core): format reusable session buffers

* feat(lcs): execute sealed sRGB8 tristimulus derivation

* style(lcs): format sealed tristimulus slice

* feat(lcs): derive versioned appearance views

* style(lcs): canonicalize Oklab coefficient

* feat(core): expose typed terminal program path

* fix(core): satisfy terminal Program quality gates

* feat(lcs): bind private output projection registry

* style(core): canonicalize release module order

* fix(core): scope private registry lint firewall

* fix(core): harden terminal Program admission

* style(core): match pinned Rust formatter

* feat(core): bind F0 release descriptors

* perf(core): add linear canonical surface ingestion

* refactor(core): unify terminal physical identities

* perf(core): prebind terminal evaluation slots

* perf(core): make present ingestion lazy and borrowed

* refactor(core): remove per-port surface mutation

* feat(core): evaluate typed constraints and emit terminal paints

* feat(core): bind observation groups to runtime streams

* refactor(core): share one encoded point Paint value

* refactor(core): share revision-bound observation state

- admit correlated scenario sets once behind shared immutable backing
- make joint selection domain-safe, linear, and ownership-retryable
- refresh source-bound release proof gates

* fix(ci): bind V2a budget to measured artifact

- keep allocation tests ownership-preserving without a large Result closure
- pin the zero-headroom WASM ratchet to the reproducible V2a artifact

* refactor(core): remove superseded Program runtime

Keep only the private Program compiler/lowering payload for the direct sole-Session bridge.
Delete the duplicate owner, lifecycle, output materialization, and test evaluator scaffolding.
Pin the hard cut with a negative facade gate and refresh the exact point-support source receipt.

* feat(core): execute compiled plans through sole Session

Replace the point-support-specific lifecycle with one sealed monomorphized Session, attach reusable CompiledProgram epochs through strong ownership, and retain complete case-by-constraint reports. Bind every decision to the exact admitted observation before atomic commit and refresh release proof pins.

* feat(core): bind Program assessments to context-bound LCS

* Hard-delete Pair taxonomy from shipping surfaces

* Compile typed finite targets into Program sessions

* quarantine unsupported Display P3 promises

* core: make compiled programs the sole session-generation owner

* core: close the evaluator union and package session bridge

* core: derive a typed CAM16-UCS occurrence view

* core: lower authored physical declarations into the canonical Program

* core: bind Program content identity

* core: name versioned identity discriminants

* fix(ci): re-pin the runtime WASM budget to this slice's measured artifact

The exact-length gate still pinned 376830B from
`canonical-authored-program-lowerer` (#456, run 29971399220). This slice
grew the runtime artifact to 376985B and did not carry the re-pin that
every earlier stacked slice performed (#450, #452, #454, #456), so the
gate has rejected this head and every head above it.

The +155B is attributable to this slice alone: runs 30115821523 (#457),
30124467410 (#458), 30125634830 (#459), 30129537515 (#460) and
30136346868 (#461) all measure exactly 376985B, so #458-#461 contribute
zero bytes to the artifact and were failing only on the inherited pin.

The new measurement is the CI run for this exact head
(39ee0a7), not a local build: the
canonical platform is linux-x64 and a local arm64 build only produces a
DIAGNOSTIC result. The budget file's own SHA-256 is re-pinned in the
checker so the drift gate keeps rejecting unattributed edits.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(ci): re-bind the point-support source capsule to this slice's cone

This slice moves files inside the point-support semantic cone, so the capsule
digest and the committed surplus proof move with it. Both are now regenerated in
the same commit that causes the drift, matching the convention the rest of the
stack follows; previously the re-bind was batched at #460, which left #457-#459
fail-closed on their own heads and made the stack unmergeable in order.

Numerical review: every proof field is unchanged. Only the source-binding
identities move -- the file hashes of the cone files this slice edits, the
resulting closure digest, the verifier hash and the rolled-up payload hash.
The surplus mathematics is byte-identical.

Co-Authored-By: Claude <noreply@anthropic.com>

* core: project complete program certificate evidence

* fix(ci): re-bind the point-support source capsule to this slice's cone

This slice moves files inside the point-support semantic cone, so the capsule
digest and the committed surplus proof move with it. Both are now regenerated in
the same commit that causes the drift, matching the convention the rest of the
stack follows; previously the re-bind was batched at #460, which left #457-#459
fail-closed on their own heads and made the stack unmergeable in order.

Numerical review: every proof field is unchanged. Only the source-binding
identities move -- the file hashes of the cone files this slice edits, the
resulting closure digest, the verifier hash and the rolled-up payload hash.
The surplus mathematics is byte-identical.

Co-Authored-By: Claude <noreply@anthropic.com>

* core: bind Program operations to exact owner snapshots

* fix(ci): re-bind the point-support source capsule to this slice's cone

This slice moves files inside the point-support semantic cone, so the capsule
digest and the committed surplus proof move with it. Both are now regenerated in
the same commit that causes the drift, matching the convention the rest of the
stack follows; previously the re-bind was batched at #460, which left #457-#459
fail-closed on their own heads and made the stack unmergeable in order.

Numerical review: every proof field is unchanged. Only the source-binding
identities move -- the file hashes of the cone files this slice edits, the
resulting closure digest, the verifier hash and the rolled-up payload hash.
The surplus mathematics is byte-identical.

Co-Authored-By: Claude <noreply@anthropic.com>

* core: single-own compiled observation schemas

* chore(proof): document Python 3.9 zip invariant

* core: define the public Program API

* core: address Program API review

* fix(ci): re-bind public Program proof capsule

* test: close compile-fail sentinel escape

* core: make joint order non-empty by construction and bound evidence cells

`AdmittedFiniteJointOrderV1` stored one flat tuple slice, so an empty
admitted order was representable and the evaluation path carried a
runtime `state_count == 0 -> InternalInvariant` guard to reject it. The
guard proved nothing about the type; it only re-checked a property the
constructor already enforced.

Split the order into `first + rest`. Non-emptiness becomes structural,
`state_count()` is total, and the `InternalInvariant` branch in
`prepare_program_evaluation_buffers` is deleted rather than left dead.
The `joint_state_count: Option<usize>` parameter disappears with it:
cell counts are now derived from the epoch itself.

The same pass stops reserving an exhaustive-conflict buffer that no
constraint can ever fill. `can_conflict` is false when every compiled
constraint is report-only, so a report-only program no longer reserves
`cases x constraints x states` cells and no longer reports
`ResourceExhausted` for a conflict it cannot produce.

`OwnerV1::evidence_cell_bounds` exposes the same arithmetic as a pure
preflight, with `EvidenceBoundsErrorV1::CardinalityOverflow` as the only
closed failure. It creates no Session and mutates no state.

Verified locally on the CI-pinned toolchain: full workspace tests green,
`cargo fmt --all --check` and `cargo clippy --workspace --all-targets --
-D warnings` clean.

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: explain packed proof invariants

* core: fail closed without current Program evidence

* core: revoke outputs on unknown session handoff

* core: keep incomplete Program crate-private

* perf: bind smaller private Program wasm

* core: make staged Program unexportable

* ci: explain rustdoc surface mismatch

---------

Co-authored-by: Claude <noreply@anthropic.com>
@lemone112

Copy link
Copy Markdown
Collaborator Author

Superseded by the reviewed cumulative squash merge #465 (24fd1f4). The lower stacked branch was intentionally not merged on its own because its intermediate head was not the safe terminal public boundary.

@lemone112 lemone112 closed this Jul 26, 2026
@lemone112
lemone112 deleted the agent/session-schema-ssot branch July 26, 2026 22:16
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