O1b-1c: bind closed absence to host identity - #481
Conversation
WalkthroughМодель point attachment переведена с linear lease и generic stamps на permit-based admission, closed leases и value-based sink stamps. Обновлены in-memory sink, lifecycle-логика, тесты и contract receipts. ChangesClosed point attachment lifecycle
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()
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
crates/labcolors-core/contracts/clean-set-srgb8-v1/receipt-v1.jsoncrates/labcolors-core/contracts/clean-set-srgb8-v1/receipt-v1.sha256crates/labcolors-core/src/program/attachment.rscrates/labcolors-core/src/program/attachment/support.rscrates/labcolors-core/src/program/attachment/tests.rs
Корневая проблема
Сырой sink-lease мог пересечь границу Attachment без доказанной закрытой пустоты, а adapter-owned stamp оставлял TOCTOU/ABA и возможность рассинхронизации фактического host binding с Core-authority.
Вертикальный срез
UnboundPointSinkLeaseV1в закрытый typestate только после полной compiler-backed bijection;-> Self;Доказательства
cargo +stable test -q --workspace --locked: GREEN;cargo +1.85.0 check --workspace --all-targets --locked: GREEN;--exact: каждый выполнил 1/1 тест;644195947c48b841dd319e7586700986ddf4fd4553d593d093c4e109a3002fe3.Correctness-root: O1b-1c.