Skip to content

feat(protocol): add EGRESS as a sixth categorization (Phase 2c-2d)#507

Merged
jinhongkuan merged 1 commit into
devfrom
feat/daemon-02c-2d-egress-category
May 23, 2026
Merged

feat(protocol): add EGRESS as a sixth categorization (Phase 2c-2d)#507
jinhongkuan merged 1 commit into
devfrom
feat/daemon-02c-2d-egress-category

Conversation

@jinhongkuan

Copy link
Copy Markdown
Contributor

Summary

Resolves the open question surfaced in #505: egress.deliver was on the namespace-invariant allowlist because the 2c-1 categorization committed to five prefixes and didn't include outbound delivery.

Option 1 chosen (with @jinhongkuan): add EGRESS_PREFIX = "egress." as a sixth category symmetric with IngestAdapterEgressAdapter in the Protocol surface.

Egress is structurally distinct from write.* — it pushes NotificationEvent to channel adapters, not rows to the ledger. Conflating them at the wire level would force adapter authors to reason about which write.X mutates state vs which fans out a notification. Cleaner mental model under its own prefix.

What changed

  • protocol/categorization.py:
    • new EGRESS_PREFIX constant
    • Category.EGRESS enum value
    • _PREFIX_BY_CATEGORY mapping entry
    • new egress_tool() decorator function
    • docstring updated 5 → 6 categories
  • protocol/__init__.py — export egress_tool, EGRESS_PREFIX
  • tests/test_protocol_categorization.py:
    • _PREFIX_BY_CATEGORY mapping extended
    • test_all_five_categories_smoketest_all_six_categories_smoke
    • new test_egress_tool_rejects_mismatch (parallel to existing read_tool mismatch test)
  • tests/test_protocol_namespace_invariant.py:
    • egress.deliver removed from WIRE_METHOD_ALLOWLIST (now matches proper EGRESS_PREFIX)
    • EGRESS_PREFIX added to _CATEGORIZED_PREFIXES tuple

Timing rationale

Egress dispatch is a stub today — no hosted-mode adapter speaks it yet. Renaming-the-namespace cost is zero now. Once 2c-3 spins up real egress dispatch and the daemon becomes a real process, the wire name becomes load-bearing and a hosted-mode rename means coordinated client+server release. Cheaper to settle the contract while no one's compiling against it.

Test plan

  • pytest tests/test_protocol_categorization.py — 9 passing (was 8 + new test_egress_tool_rejects_mismatch)
  • pytest tests/test_protocol_namespace_invariant.py — 3 passing (allowlist now empty)
  • Full protocol suite — 37 passing (was 36)
  • ruff format --check . && ruff check . clean
  • mypy protocol/ clean
  • CI green on dev

Known limitation

Bicameral preflight unavailable this session (MCP server disconnected). Will validate against the ledger before opening 2c-3.

Plan refs

🤖 Generated with Claude Code

Fourth in the daemon-as-process arc. Resolves the open question surfaced
in PR #505: ``egress.deliver`` was on the namespace-invariant allowlist
because the 2c-1 categorization committed to five prefixes and didn't
include outbound delivery.

Option 1 chosen (with @jinhongkuan): add ``EGRESS_PREFIX = "egress."``
as a sixth category symmetric with ``IngestAdapter`` ↔ ``EgressAdapter``
in the Protocol surface. Egress is structurally distinct from ``write.*``
(pushes NotificationEvents to channel adapters, not rows to the ledger);
conflating them at the wire level would force adapter authors to reason
about which ``write.X`` mutates state vs which fans out a notification.

Changes:
- protocol/categorization.py:
  - new EGRESS_PREFIX constant
  - Category.EGRESS enum value
  - _PREFIX_BY_CATEGORY mapping entry
  - egress_tool() decorator function
  - docstring updated 5 → 6 categories
- protocol/__init__.py: export egress_tool, EGRESS_PREFIX
- tests/test_protocol_categorization.py:
  - _PREFIX_BY_CATEGORY mapping extended
  - test_all_five_categories_smoke → test_all_six_categories_smoke (now
    includes egress assertion)
  - new test_egress_tool_rejects_mismatch (parallel to existing read_tool
    mismatch test)
- tests/test_protocol_namespace_invariant.py:
  - egress.deliver removed from WIRE_METHOD_ALLOWLIST (now matches
    proper EGRESS_PREFIX)
  - EGRESS_PREFIX added to _CATEGORIZED_PREFIXES tuple

Timing rationale: egress dispatch is still a stub today. Renaming-the-
namespace cost is zero now; once 2c-3 spins up real egress dispatch,
the wire name becomes load-bearing and a hosted-mode rename means
coordinated client+server release.

Bicameral preflight unavailable this session (MCP disconnected); will
validate against ledger before 2c-3.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 189e800f-c8a9-4f5e-8ed1-c792c02dbdd4

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/daemon-02c-2d-egress-category

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 and usage tips.

@jinhongkuan jinhongkuan merged commit 33e0477 into dev May 23, 2026
10 checks passed
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