Skip to content

O1b-1b: make terminal stamps fixed values - #480

Merged
lemone112 merged 2 commits into
mainfrom
agent/o1b-1b-terminal-tail
Jul 27, 2026
Merged

O1b-1b: make terminal stamps fixed values#480
lemone112 merged 2 commits into
mainfrom
agent/o1b-1b-terminal-tail

Conversation

@lemone112

@lemone112 lemone112 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Проблема

Point-sink stamp мог владеть heap-ресурсом. Из-за этого terminal commit tail требовал отдельного deferred-retirement слота, а прежний allocation gate складывал alloc + realloc и не замечал освобождение памяти внутри проверяемого участка.

Корневая причина

Контракт допускал Stamp: Clone + Eq и возвращал proposed stamp по ссылке. Test sink закреплял epoch через Rc; allocator oracle не различал alloc, realloc и dealloc.

Изменение

  • Stamp: Copy + Eq; proposed stamp возвращается значением.
  • Удалён лишний Attachment::retired_stamp.
  • Test stamp — два u64: sequence и auto-minted sink epoch.
  • Checked AtomicU64 issuer исключает ручные коллизии, zero, wrap и ABA в пределах процесса.
  • Stale stamp другого sink epoch заканчивается StampMismatch.
  • Allocator oracle отдельно считает alloc, alloc_zeroed, realloc и dealloc.
  • Реальный Attachment post-install tail для SetAll, RevokeAll и ConfirmExact даёт ноль всех allocator events.
  • Allocator oracle включён в exact clean-set receipt cone и его missing/mutated hostile controls.

RED → GREEN

  • Новый Attachment checkpoint сначала не компилировался: measurement seam отсутствовал.
  • Receipt verifier затем fail-closed отклонил неполный source cone.
  • Пять exact proof-тестов запускаются по одному и проходят; zero-test прогон доказательством не считался.

Проверки

  • cargo test --workspace --all-targets --locked: 1081 passed, 7 ignored.
  • Clippy -D warnings, rustfmt, MSRV Rust 1.85.0, git diff --check: GREEN.
  • Mutation: 1 релевантный mutant killed, 1 unviable, 0 survived, 0 timeout.
  • Receipt hostile suite: 31 passed.
  • Product + committed research replay: GREEN.
  • Receipt pin: 369e1cf175ac10ab96ca1f6cb82e131e4c24fc43c698a0d853ccabdebb0386d5.
  • Независимый hostile-review: CLEAN.

Не входит

Здесь нет browser/CSSOM sink, публичного Program façade, WASM bridge или второго runtime authority. Следующий correctness-root — O1b-1c: typed closed absence, host codec/capability/root/sink-epoch binding и retryable cleanup там, где revoke не доказан infallible.

Summary by CodeRabbit

  • Улучшения

    • Оптимизировано обновление терминальных контрольных меток: снижены лишние копирования и уточнена логика публикации/ретайрингa.
    • Улучшено измерение событий памяти для более точного контроля аллокаций и освобождений в тестах.
  • Исправления

    • Усилена проверка согласованности контрольных данных при последовательных обновлениях и устранены ошибки в управлении временем жизни.
  • Тесты и проверки

    • Расширены сценарии тестов для корректного освобождения ресурсов и стабильности событий.
    • Добавлена дополнительная проверка обязательного артефакта при валидации clean-set receipt.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f8ce156d-edd4-4f5e-8f71-c145762e2e04

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Изменены контракты stamp для point-sink, retirement-состояние Attachment и тестовая реализация sink. Добавлен раздельный учёт событий аллокатора, расширены тесты terminal tail и обновлены роли и контрольные суммы clean-set receipt.

Changes

Point attachment и тестовые проверки

Layer / File(s) Summary
События тестового аллокатора
crates/labcolors-core/src/test_support.rs
Счётчики разделены на alloc, realloc и dealloc; добавлены API измерения событий и тест их различения.
Контракты stamp и retirement
crates/labcolors-core/src/program/attachment.rs
Stamp переведён на Copy + Eq с возвратом по значению, а retirement перенесён с stamp на deferred session.
Поддержка in-memory sink
crates/labcolors-core/src/program/attachment/support.rs
Тестовые stamp используют числовой epoch, а sink получил управление измерением terminal tail и обновлённое хранение retirement-состояния.
Проверки attachment и receipt
crates/labcolors-core/src/program/attachment/tests.rs, scripts/*.py, crates/labcolors-core/contracts/clean-set-srgb8-v1/*
Добавлены проверки Copy stamp, stale epoch и отсутствия allocator-событий; в receipt добавлена роль point_attachment_allocator_oracle и обновлены контрольные суммы.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • Labpics-Team/lab-colors#476: связанное расширение clean-set receipt verification и роли product-артефактов.
  • Labpics-Team/lab-colors#478: связанная реализация point-attachment и изменения stamp-семантики.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.64% 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 Заголовок точно отражает основное изменение: terminal stamps стали фиксированными значениями.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/o1b-1b-terminal-tail

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

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.

@lemone112
lemone112 marked this pull request as ready for review July 27, 2026 18:24

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

🤖 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/support.rs`:
- Around line 184-199: Replace the panic-based failures in
checkpoint_next_terminal_tail and in_memory_point_sink with typed
InMemoryPointSinkErrorV1 results: return the appropriate error when a
terminal-tail checkpoint overlaps and when NEXT_TEST_SINK_EPOCH is exhausted.
Update these crate-visible APIs and their callers to propagate or handle the
Result while preserving successful behavior.

In `@crates/labcolors-core/src/test_support.rs`:
- Around line 70-92: Измените reset_allocator_events и current_allocator_events
так, чтобы отсутствие активного измерения возвращало типизированную
AllocatorMeasurementError вместо panic через
assert_allocator_measurement_is_active. Обновите вызывающий путь checkpoint в
sink и связанные методы для проброса этой ошибки до API-границы, не подставляя
нулевые AllocatorEvents и не скрывая ошибку.
- Around line 27-30: Update record so the COUNT_ALLOCATIONS.try_with(Cell::get)
result is handled with an explicit branch instead of unwrap_or(false). Preserve
the inactive-measurement behavior when TLS access fails, and add a concise
comment explaining that this is permitted during thread teardown under the
GlobalAlloc invariant.
🪄 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: 12bc8187-b0b2-4973-b463-008820cff558

📥 Commits

Reviewing files that changed from the base of the PR and between 4ba86b0 and 62882a0.

📒 Files selected for processing (8)
  • 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
  • crates/labcolors-core/src/test_support.rs
  • scripts/test_verify_clean_set_receipt.py
  • scripts/verify_clean_set_receipt.py

Comment thread crates/labcolors-core/src/program/attachment/support.rs
Comment thread crates/labcolors-core/src/test_support.rs
Comment thread crates/labcolors-core/src/test_support.rs

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.

@lemone112
lemone112 merged commit 0df94d3 into main Jul 27, 2026
10 checks passed
@lemone112
lemone112 deleted the agent/o1b-1b-terminal-tail branch July 27, 2026 18:41
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