Skip to content

[AI-0303] feat(endpoint): add fail-closed S-F strict seam - #514

Merged
Xuepoo merged 1 commit into
mainfrom
carryctx/ai-0303
Oct 17, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
carryctx/ai-0303

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Add opaque publication acknowledgement capability and strict pre-handler dispatch. No same-domain provider/routing snapshot binding exists yet, so strict requests fail closed as Unbound; normal dispatch remains tolerant. MCP tool-list version is not misused as the Core publication version. Live Core/Lua/IPC wiring remains out of scope.\n\nReview: APPROVE (PX-1419 ai-0303-domain-reviewer; PX-1415/PX-1417 blockers resolved by domain-safe fail-closed correction).\nGates: fmt, clippy, workspace tests, just check, act -n, green.\n\nPriority: P1 | Area: ipc | Labels: feat,P1 | Milestone: v0.1.0 | RFC: AIQ-38 | Task: AI-0303

Summary by CodeRabbit

  • Behavior
    • Existing AI correlator handling remains optional and tolerant.
    • Strict dispatch now fails closed: requests are refused before reaching handlers because no matching provider and routing snapshot is bound. Matching version numbers alone do not enable strict dispatch.
  • Documentation
    • Clarified the difference between publication and MCP snapshot versions, and that caller-supplied publication details do not establish authority.
    • Clarified that strict enforcement is not wired into Core, Lua, or IPC, and is not part of a production release.

Add opaque publication acknowledgement capability and strict
pre-handler dispatch. No same-domain provider/routing snapshot
binding exists yet, so strict requests fail closed as Unbound;
normal dispatch remains tolerant. MCP tool-list version is not
misused as the Core publication version. Live Core/Lua/IPC wiring
remains out of scope.

Review: APPROVE (PX-1419 ai-0303-domain-reviewer; prior blockers
PX-1415/PX-1417 resolved by domain-safe fail-closed correction).
Gates: fmt, clippy, workspace tests, just check, act -n, green.

Priority: P1 | Area: ipc | Labels: feat,P1
Milestone: v0.1.0 | RFC: AIQ-38 | Task: AI-0303
@Xuepoo Xuepoo added this to the v0.1.0 milestone Oct 17, 2026
@Xuepoo Xuepoo added feat Feature P1 Priority: high labels Oct 17, 2026
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

📝 Walkthrough

The endpoint package adds an opaque capability for validated publication acknowledgements and a strict dispatch entry. Strict dispatch currently refuses before handlers because no same-domain snapshot binding is available. Existing dispatch remains tolerant.

Changes: Strict dispatch

Layer / File(s) Summary
Acknowledged publication capability
crates/bitty-ai-endpoint/src/metadata_publication.rs
PublicationState::acknowledge_for_endpoint consumes a validated pending acknowledgement and returns an opaque capability. Tests cover single-use acknowledgement and superseded publications.
Strict dispatch and refusal
crates/bitty-ai-endpoint/src/lib.rs, crates/bitty-ai-endpoint/API.md
dispatch_with_strict runs the admission gates and parses the correlator before checking the endpoint binding. The current endpoint refuses as Unbound before handlers. Tests cover this refusal and confirm that default dispatch remains tolerant. The documentation distinguishes publication snapshot_version from MCP list_version.

Priority: ⬇️ Low

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant PublicationState
  participant StrictEndpoint
  participant Caller
  participant dispatch_with_strict
  PublicationState->>PublicationState: acknowledge_for_endpoint(frame)
  PublicationState-->>StrictEndpoint: AcknowledgedPublication
  Caller->>dispatch_with_strict: dispatch(input, strict_view, endpoint)
  dispatch_with_strict->>StrictEndpoint: enforce correlator binding
  StrictEndpoint-->>dispatch_with_strict: Unbound
  dispatch_with_strict-->>Caller: Denied, SnapshotCorrelator
Loading
Merge Risk: ⚪ Minimal · up to cf838

Strict dispatch remains fail-closed, and no actionable merge-blocking risk is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 68.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 2 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: adding a fail-closed strict endpoint dispatch seam. It is concise and directly matches the pull request objectives.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 68.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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

🔇 Additional comments: 4
crates/bitty-ai-endpoint/src/metadata_publication.rs: 1

35-68: LGTM!

Also applies to: 167-185, 491-542

crates/bitty-ai-endpoint/src/lib.rs: 2

76-87: LGTM!

Also applies to: 216-223, 248-249, 267-319, 562-574, 1095-1096, 1105-1117, 1214-1224, 1239-1240, 8136-8158, 8171-8174, 8455-8457, 8474-8543


637-688: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

The handler table after the unconditional refusal is unreachable. It also duplicates the dispatch_with table.

StrictEndpoint::enforce always returns Err(Unbound). As a result, the method table at Lines 656-687 never runs. That table copies the table in dispatch_with. If someone adds a method to one table and not the other, the two tables will disagree after a binding exists, and no current test will catch the difference. The project guide also says not to add product code before its gates are accepted. Two fixes are possible:

  • Return the refusal right after enforcement and remove the copied table until a same-domain binding is accepted.
  • Extract a shared run_e1a_table(view, input, scope) helper and call it from both dispatch entries.
♻️ Proposed refactor
-    if let Err(refusal) = endpoint.enforce() {
-        return DispatchOutcome::Refused(strict_refusal_error(refusal));
-    }
-    // Keep the E1a method table identical after the strict pre-handler check.
-    let result = match input.method {
-        ...
-    };
-    match result { ... }
+    if let Err(refusal) = endpoint.enforce() {
+        return DispatchOutcome::Refused(strict_refusal_error(refusal));
+    }
+    run_e1a_table(view, input, scope)
crates/bitty-ai-endpoint/API.md: 1

26-41: LGTM!


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6a1c75ea-289a-4d5e-b32a-265327465bb6
📥 Commits

Reviewing files that changed from the base of the PR and between b5bcdb3 and cf838b9.

📒 Files selected for processing: 3
  • crates/bitty-ai-endpoint/API.md
  • crates/bitty-ai-endpoint/src/lib.rs
  • crates/bitty-ai-endpoint/src/metadata_publication.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@Xuepoo
Xuepoo merged commit 900aa72 into main Oct 17, 2026
11 checks passed
@Xuepoo
Xuepoo deleted the carryctx/ai-0303 branch October 17, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Feature P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant