Skip to content

feat(event): add failure-atomic slab/ring admission boundary (ADR-0009) - #1862

Merged
lavkushry merged 3 commits into
mainfrom
feat/event-admission-adr-0009
Jul 13, 2026
Merged

feat(event): add failure-atomic slab/ring admission boundary (ADR-0009)#1862
lavkushry merged 3 commits into
mainfrom
feat/event-admission-adr-0009

Conversation

@lavkushry

@lavkushry lavkushry commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #1861 (which merged before this work was pushed to its branch — these three commits are rebased onto main).

ADR-0009 — failure-atomic slab/ring admission (lib/event/src/admission.rs, Proposed): composite volatile channel binding one published-prefix page to one SPSC descriptor ring.

  • try_admit publishes page-then-ring with no fallible work between the publication phases; a caught unwind closes the page, Release-stores FAULTED, closes the ring, and resumes the panic — a retained producer is terminal, never an atomically open poisoned lane.
  • Consumer validation fails closed: sequence gap/duplicate/reorder, arena identity, payload range, and CRC faults withhold the tail, disconnect the producer, and poison the consumer; ring invariant errors Release-close the ring before surfacing. Malformed terminal closure states never report CleanEnd.
  • Endpoints are Send but deliberately not Sync; frame leases are neither Send nor Sync — enforced by compile_fail doc-tests.
  • Success tokens are documented as volatile publication only — never a receipt, durability acknowledgement, or authorization result.

CI-gate fixes (both were failing on #1861 and will fail on every PR until landed):

  • docs: three Installation.md links in the World-Class HLD/LLD break on Linux's case-sensitive filesystem (pre-existing from docs(architecture): add bare-metal Thread-Per-Core blueprint (HLD/LLD/migration matrix) #1858) — fixed to installation.md.
  • ci(sast): the community blanket rust.lang.security.unsafe-usage rule blocks on any unsafe repo-wide, including the ADR-gated event crate's isolated, // SAFETY:-documented unsafe. Replaced with rust-unsafe-outside-reviewed-crates, which still blocks unsafe everywhere except lib/event (gated by the event-concurrency / event-miri / event-sanitizers lanes). Verified with semgrep 1.169 locally: fires outside lib/event, silent inside it, and --exclude-rule suppresses the registry rule. Operator-approved trade-off (scoped rule swap over per-site nosemgrep annotations).

Status honesty (per docs/architecture.md vocabulary)

ADR-0009 is Proposed; the admission prototype is current only as isolated, unwired code + tests. The production event fabric remains target — no shadow traffic, no performance claims. Implementation_Status.md, MIGRATION_MATRIX.md, ROADMAP.md, ARCHITECTURE.md, docs/LLD.md, and the ADR index are updated in the same change.

Test plan

All verified locally on the final state:

  • cargo fmt --all -- --check, cargo clippy -p aegis-event --all-targets --all-features -- -D warnings
  • cargo test -p aegis-event and --all-features (retained-producer caught-unwind tests at every publication phase, corrupt-descriptor and terminal-state fail-closed fixtures)
  • cargo test -p aegis-event --features loom loom_ (incl. validation-failure vs reserved-publication race model)
  • cargo +nightly miri test -p aegis-event (incl. compile_fail doc-tests)
  • ASan + TSan (-Zbuild-std) on admission + published_slab suites
  • cargo check --workspace, node scripts/validate-docs.mjs, node scripts/audit-doc-quality.mjs --check
  • PR CI green, including previously-failing Demo guardrails and Semgrep SAST

Summary by CodeRabbit

  • New Features

    • Added a volatile, process-local event admission prototype pairing slab storage with a bounded SPSC ring.
    • Added staged claim/commit handling, explicit clean/faulted termination, typed errors, and validation safeguards.
    • Added benchmark coverage for successful admission and full-ring scenarios.
  • Documentation

    • Added and accepted ADR-0009, with updated architecture, roadmap, status, and migration guidance.
    • Expanded CLI and benchmark reporting requirements.
  • Tests & Security

    • Expanded concurrency, stress, allocation, Loom, Miri, sanitizer, and fault-injection coverage.
    • Added safeguards against unsafe code outside reviewed areas.

Composite volatile admission channel binding one published-prefix page to
one SPSC descriptor ring, under Proposed ADR-0009:

- try_admit publishes page-then-ring with no fallible work between the
  page publication and ring publication phases; a caught unwind closes the
  page, Release-stores FAULTED, closes the ring, and resumes the panic so
  a retained producer is terminal, never an atomically open poisoned lane
- consumer validation fails closed: sequence gap/duplicate/reorder, arena
  identity, payload range, and CRC faults withhold the tail, disconnect
  the producer, and poison the consumer; ring invariant errors
  Release-close the ring before surfacing
- malformed terminal closure states (clean-without-page-close, unknown
  raw state, count mismatches in either direction) never report CleanEnd
- endpoints are Send but deliberately not Sync; frame leases are neither
  Send nor Sync (compile_fail doc-tests enforce all of it)

Evidence: retained-producer caught-unwind tests at every publication
phase, corrupt-descriptor and terminal-state fixtures, Loom models
including a validation-failure vs reserved-publication race, full Miri,
ASan/TSan clean on the final state, zero-allocation admission bench, and
CI lanes extended for the admission suite. Status honesty: ADR-0009 is
Proposed; the fabric remains target, unwired, with no performance claims
(Implementation_Status ledger, MIGRATION_MATRIX delta, ROADMAP, LLD
updated in the same change).
macOS resolves Installation.md case-insensitively, the Linux CI runner
does not — these three links failed the demo-guardrails docs validation
on every PR since #1858 landed.
Replace the community blanket rust.lang.security.unsafe-usage rule
(excluded via --exclude-rule) with rust-unsafe-outside-reviewed-crates,
which still blocks any unsafe outside lib/event. The event-fabric crates
(ADR-0006..0009) carry isolated, SAFETY-documented unsafe gated by the
event-concurrency, event-miri and event-sanitizers CI lanes, per the
CONTRIBUTING unsafe evidence standard and docs/architecture.md §8.

Verified with semgrep 1.169 locally: the scoped rule fires on unsafe
outside lib/event, stays silent inside it, and --exclude-rule suppresses
the registry rule (finding count 1 -> 0 on a synthetic case).

Approved by operator (scoped rule swap chosen over per-site nosemgrep
annotations).
Copilot AI review requested due to automatic review settings July 13, 2026 18:59

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ecc-tools

ecc-tools Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@lavkushry
lavkushry merged commit 499ab6d into main Jul 13, 2026
32 of 33 checks passed
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4093f408-4bab-4021-98dc-ab85a1203cac

📥 Commits

Reviewing files that changed from the base of the PR and between 16580f5 and 780ea4d.

📒 Files selected for processing (25)
  • .github/workflows/ci.yml
  • .github/workflows/sast.yml
  • .semgrep/aegisagent-rust.yml
  • ARCHITECTURE.md
  • MIGRATION_MATRIX.md
  • README.md
  • ROADMAP.md
  • docs/AegisAgent_World_Class_HLD.md
  • docs/AegisAgent_World_Class_LLD.md
  • docs/Documentation_Quality_Report.md
  • docs/Implementation_Status.md
  • docs/LLD.md
  • docs/adr/0009-failure-atomic-slab-ring-admission.md
  • docs/adr/index.md
  • docs/current-vs-roadmap.md
  • lib/event/Cargo.toml
  • lib/event/benches/admission.rs
  • lib/event/src/admission.rs
  • lib/event/src/lib.rs
  • lib/event/src/published_slab.rs
  • lib/event/src/ring.rs
  • lib/event/tests/admission.rs
  • lib/event/tests/published_allocations.rs
  • lib/event/tests/spsc.rs
  • mkdocs.yml

📝 Walkthrough

Walkthrough

Changes

The PR adds a process-local VolatileAdmissionChannel combining a published slab page with an SPSC ring, including typed errors, terminal states, leases, commit-based reclamation, and fault handling. It also updates ring/slab primitives, adds extensive concurrency and benchmark coverage, documents ADR-0009, and expands CI safety checks.

Event admission prototype

Layer / File(s) Summary
Admission contract and architecture
docs/adr/0009-failure-atomic-slab-ring-admission.md, ARCHITECTURE.md, docs/LLD.md, ROADMAP.md, README.md, docs/current-vs-roadmap.md, MIGRATION_MATRIX.md
Documents validation-before-reservation, page-before-ring publication, lease commit, terminal states, failure semantics, prototype constraints, and migration gates.
Ring and slab primitives
lib/event/src/ring.rs, lib/event/src/published_slab.rs
Adds typed ring invariants and reservation/claim lifecycles, commit-delayed reclamation, planned slab appends, closure handling, and published status snapshots.
Admission channel implementation and API
lib/event/src/admission.rs, lib/event/src/lib.rs
Adds the channel, producer, consumer, admitted-event lease, sequence identity, typed errors, fault injection, terminal handling, and public re-exports.
Concurrency validation and benchmark wiring
lib/event/tests/*, lib/event/benches/admission.rs, lib/event/Cargo.toml
Adds native, Loom, oracle, stress, allocation, SPSC lifecycle, and Criterion benchmark coverage.
Safety rules and CI lanes
.github/workflows/ci.yml, .github/workflows/sast.yml, .semgrep/aegisagent-rust.yml
Expands event safety lanes for admission benchmarks and sanitizers and adds path-scoped unsafe-code Semgrep enforcement.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Producer
  participant SlabPage
  participant Ring
  participant Consumer
  Producer->>SlabPage: validate and append payload
  Producer->>Ring: publish descriptor
  Consumer->>Ring: claim descriptor
  Consumer->>SlabPage: validate descriptor and payload
  Consumer->>Ring: commit lease and advance tail
Loading

Possibly related PRs

  • lavkushry/AegisAgent#1861: Adds the earlier SPSC ring and published-prefix slab primitives used by this admission implementation.

Suggested reviewers: copilot

✨ 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 feat/event-admission-adr-0009

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request implements a failure-atomic single-page slab/ring admission prototype (VolatileAdmissionChannel) under the proposed ADR-0009, introducing SPSC ring permit/claim APIs, benchmarks, and extensive test coverage. The documentation has been thoroughly updated to reflect these changes. Feedback on the changes highlights a critical issue in the Semgrep configuration, where the exclusion pattern for 'lib/event/*' needs to be recursive ('lib/event/**') to avoid failing SAST checks on unsafe blocks in subdirectories.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

- pattern: unsafe fn $F(...) { ... }
paths:
exclude:
- "lib/event/*"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The glob pattern lib/event/* is non-recursive in Semgrep and will only exclude files directly under the lib/event/ directory (such as Cargo.toml). It will not exclude files in subdirectories like lib/event/src/ring.rs, which will cause Semgrep to fail on the unsafe blocks in those files. Use lib/event/** to recursively exclude the entire directory.

        - "lib/event/**"

@lavkushry
lavkushry deleted the feat/event-admission-adr-0009 branch July 13, 2026 19:26
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