Skip to content

O1b-1c: bind closed absence to host identity - #481

Merged
lemone112 merged 2 commits into
mainfrom
agent/o1b-1c-closed-absence
Jul 27, 2026
Merged

O1b-1c: bind closed absence to host identity#481
lemone112 merged 2 commits into
mainfrom
agent/o1b-1c-closed-absence

Conversation

@lemone112

@lemone112 lemone112 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Корневая проблема

Сырой sink-lease мог пересечь границу Attachment без доказанной закрытой пустоты, а adapter-owned stamp оставлял TOCTOU/ABA и возможность рассинхронизации фактического host binding с Core-authority.

Вертикальный срез

  • атомарный admission переводит UnboundPointSinkLeaseV1 в закрытый typestate только после полной compiler-backed bijection;
  • host admission минтит process-local epoch для полного immutable binding; Core канонически начинает sequence с 0 и выдаёт exact successor каждой мутации;
  • owned sink scope проверяется как точное множество, без ложной зависимости от порядка;
  • Drop выполняет infallible zero-argument close на admission-bound ресурсе;
  • cold/admission failures сохраняют исходный retryable lease и неизменный host state;
  • Unknown, Violation, Revoke и Drop сохраняют closed absence; ambient fallback не открывается;
  • post-admission построение отделено типизированной infallible-функцией -> Self;
  • публичный Rust/WASM/config API не изменён.

Доказательства

  • cargo +stable test -q --workspace --locked: GREEN;
  • lib: 914 тестов, 908 passed / 6 ignored; остальные targets и 33 doctests: GREEN;
  • attachment slice: 28/28 GREEN;
  • MSRV cargo +1.85.0 check --workspace --all-targets --locked: GREEN;
  • clippy/fmt/rustdoc/diff-check: GREEN;
  • public-surface guard: 8/8 GREEN;
  • полный product+research receipt и hostile receipt tests: GREEN, 31/31;
  • 8 critical anti-vacuum targets через --exact: каждый выполнил 1/1 тест;
  • mutation: 36 total, 9/9 viable caught, 27 unviable, 0 missed, 0 timeout;
  • CodeRabbit: APPROVED; unresolved review threads: 0;
  • receipt SHA-256: 644195947c48b841dd319e7586700986ddf4fd4553d593d093c4e109a3002fe3.

Correctness-root: O1b-1c.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Модель point attachment переведена с linear lease и generic stamps на permit-based admission, closed leases и value-based sink stamps. Обновлены in-memory sink, lifecycle-логика, тесты и contract receipts.

Changes

Closed point attachment lifecycle

Layer / File(s) Summary
Admission и stamp-контракты
crates/labcolors-core/src/program/attachment.rs
Добавлены scope permit, unbound/closed lease-контракты, admission failure types и value-based mutation stamps.
Attachment update и commit
crates/labcolors-core/src/program/attachment.rs
Создание, обновление, rendering и drop используют closed lease, committed revision/stamp и close_before_release().
In-memory closed sink implementation
crates/labcolors-core/src/program/attachment/support.rs
Тестовый sink моделирует host layers, binding epochs, admission, staging, install swaps и rollback.
Lifecycle tests и receipt updates
crates/labcolors-core/src/program/attachment/tests.rs, crates/labcolors-core/contracts/clean-set-srgb8-v1/*
Расширены проверки admission, binding drift, stamp transitions, закрытия и disposal; обновлены размеры и SHA-256 receipts.

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

Sequence Diagram(s)

sequenceDiagram
  participant Attachment
  participant UnboundPointSinkLeaseV1
  participant ClosedPointSinkLeaseV1
  participant PreparedPointSinkWriteV1
  Attachment->>UnboundPointSinkLeaseV1: try_admit_closed(scope permit)
  UnboundPointSinkLeaseV1-->>ClosedPointSinkLeaseV1: return closed lease and initial stamp
  Attachment->>ClosedPointSinkLeaseV1: prepare(PointSinkIntentV1)
  ClosedPointSinkLeaseV1-->>PreparedPointSinkWriteV1: return prepared write
  Attachment->>PreparedPointSinkWriteV1: try_install()
  Attachment->>ClosedPointSinkLeaseV1: close_before_release()
Loading

Possibly related PRs

  • Labpics-Team/lab-colors#478 — предыдущий рефакторинг transactional point attachment, на котором строится текущая модель lease и attachment.
  • Labpics-Team/lab-colors#480 — связанные изменения модели terminal/published stamp и переход к value-based stamp semantics.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.00% 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
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 Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Заголовок кратко и точно отражает основное изменение: привязку закрытого отсутствия к идентичности хоста.
✨ 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/o1b-1c-closed-absence

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

@lemone112
lemone112 marked this pull request as ready for review July 27, 2026 20:08

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 27, 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.

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

🤖 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/labcolors-core/src/program/attachment.rs`:
- Around line 1038-1052: Rename the AttachmentInvariantV1 variant
MissingPublishedStamp to MissingCommittedRevision, since the check in the
PreparedDispositionV1::ConfirmExact branch validates the absence of
committed_revision. Update all references to this variant consistently,
preserving the existing invariant error behavior.
- Around line 575-596: Update AttachedPublishedStampV1 to store PointSinkStampV1
by value instead of by reference, remove its lifetime parameter and manual
Copy/Clone implementations, and derive Debug, Clone, Copy, PartialEq, and Eq.
Adjust its construction and sink_stamp accessor plus affected
AttachmentCommitV1::committed_sink_stamp and render_outputs call sites so the
committed API remains a reference where required while rendering dereferences
the stored stamp.

In `@crates/labcolors-core/src/program/attachment/support.rs`:
- Around line 603-610: Update close_before_release so closing a Published layer
does not drop its owned buffer: reuse and clear the existing layer storage while
transitioning it to Closed, preserving the allocation-free requirement. Keep the
revision, revoke_count, sequence, and revoke_sequence updates unchanged.

In `@crates/labcolors-core/src/program/attachment/tests.rs`:
- Around line 250-316: В тесте
every_host_binding_axis_is_checked_before_sink_mutation добавь краткий
комментарий перед повторным update после restore_host_binding, зафиксировав
инвариант: generation монотонно увеличивается, поэтому восстановление фактов не
восстанавливает исходный bound_host и закрытый lease нельзя реанимировать. Не
изменяй поведение проверок.
- Around line 1282-1306: Сделайте source-guard стабильным и точным: в проверке
порядка подготовки и admission используйте постоянный англоязычный маркер вроде
`// invariant: post-admission-tail-start`, а не текст комментария или порядок
`impl<SinkOutputId> PreparedAttachmentColdV1`. Для проверки post-admission-кода
исключите ложные срабатывания от `?` в комментариях и строковых литералах,
используя анализ токенов/AST либо более точный clippy-гейт; сохраните проверки
`admission.into_parts()` и запрещённых fallible/destructive операций.
- Around line 554-572: Устраните no-op действия в генерации actions: проверьте
ветвление по значениям из 0_u8..12, включая случаи 4 при revision == 0 и 11.
Если 11 зарезервировано намеренно, добавьте поясняющий комментарий; иначе сузьте
диапазон так, чтобы генерировались только покрываемые действия. Примените это
также к аналогичному месту около второй указанной позиции.
- Around line 527-669: Снизьте стоимость теста
admitted_state_machine_never_exposes_ambient_fallback: не вызывайте owner(...) и
не компилируйте DraftV1 для каждого сгенерированного кейса. Вынесите результат
подготовки owner в потокобезопасный OnceLock/lazy-кэш, сохранив корректное
создание независимого attachment и sink для каждого запуска, либо уменьшите
proptest-конфигурацию только для этого блока.
🪄 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: 38cc79d1-4f81-4470-bbaa-bf7e6005d323

📥 Commits

Reviewing files that changed from the base of the PR and between 0df94d3 and 29b3771.

📒 Files selected for processing (5)
  • crates/labcolors-core/contracts/clean-set-srgb8-v1/receipt-v1.json
  • crates/labcolors-core/contracts/clean-set-srgb8-v1/receipt-v1.sha256
  • crates/labcolors-core/src/program/attachment.rs
  • crates/labcolors-core/src/program/attachment/support.rs
  • crates/labcolors-core/src/program/attachment/tests.rs

Comment thread crates/labcolors-core/src/program/attachment.rs
Comment thread crates/labcolors-core/src/program/attachment.rs
Comment thread crates/labcolors-core/src/program/attachment/support.rs
Comment thread crates/labcolors-core/src/program/attachment/tests.rs
Comment thread crates/labcolors-core/src/program/attachment/tests.rs
Comment thread crates/labcolors-core/src/program/attachment/tests.rs
Comment thread crates/labcolors-core/src/program/attachment/tests.rs
@lemone112
lemone112 merged commit a05574d into main Jul 27, 2026
10 checks passed
@lemone112
lemone112 deleted the agent/o1b-1c-closed-absence branch July 27, 2026 20:35
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