Skip to content

Seam audit 2026-09-02: Gate-only ingress, SDK chassis default, CEG→Gate→EIE enrich - #259

Merged
cryptoxdog merged 3 commits into
mainfrom
claude/gateway-seam-forensic-audit-m7cqt6
Sep 4, 2026
Merged

Seam audit 2026-09-02: Gate-only ingress, SDK chassis default, CEG→Gate→EIE enrich#259
cryptoxdog merged 3 commits into
mainfrom
claude/gateway-seam-forensic-audit-m7cqt6

Conversation

@cryptoxdog

Copy link
Copy Markdown
Collaborator

Problem

CEG (Graph Cognitive Engine) previously advertised 23 phantom graph-* actions that were never implemented, accepted the enrich action (which Gate owns for EIE), and could be deployed with the legacy dict-based chassis in production. This violated the bidirectional seam contract: Gate is the single routing authority and the only peer transport for CEG.

The seam audit (2026-09-02) identified three critical gaps:

  1. Advertised actions lie about routing readiness — spec.yaml listed unimplemented graph-* names
  2. CEG accepts EIE-owned namesenrich was advertised locally, conflicting with Gate's ownership
  3. Legacy chassis bypasses Gate — dict ExecuteRequest + api-key auth is a direct-ingress side door

Fix

1. Seam Architecture Guards (New)

Added tests/architecture/test_seam_gate_only.py — a forensic audit suite that locks the CEG side of the bidirectional seam:

  • Action ownership: spec.yaml advertises only CEG-owned, implemented actions (match, sync, outcomes, resolve); enrich, admin, health, healthcheck are forbidden
  • Chassis default: SDK (TransportPacket) is mandatory in prod; legacy is dev/test only
  • Egress routing: Every outbound packet CEG authors targets Gate (except inbound audit reconstruction to self)
  • No peer awareness: No PEER_URL, EIE_URL, or raw HTTP transport outside the SDK
  • Reverse path wired: CEG → Gate → EIE enrich is implemented, not dormant

2. Gate Egress Path (New)

Added engine/gate_egress.py — the only CEG → peer egress:

  • request_enrichment() asks Gate to run the enrich action (owned by EIE in Gate's action map)
  • One attempt per call; fail closed (no direct fallback if GATE_URL unset)
  • Every SDK error is reported as a typed failure, never swallowed
  • Idempotency key derived from tenant + entity_id + target fields (stable, order-independent)

3. Health Trigger Integration

Modified engine/health/enrichment_trigger.py:

  • trigger_reenrichment_v2() now dispatches through engine.gate_egress.request_enrichment()
  • Returns enrichment decision + Gate dispatch result
  • triggered is True only when Gate returns a non-failure packet

4. Spec and Deployment

  • spec.yaml: Replaced 23 phantom graph-* actions with 4 implemented CEG-owned actions: match, sync, outcomes, resolve
  • docker-compose.yml: SDK chassis is now default; Gate URL and registration are required
  • docker-compose.prod.yml: SDK chassis mandatory; Gate URL, admin token, and signing key are required (no defaults)
  • .env.template: Updated defaults; clarified legacy is dev/test only
  • Makefile: Added local-api-legacy target for explicit legacy testing

5. Chassis Entrypoint

Modified chassis/entrypoint.py:

  • DEFAULT_CHASSIS = SDK (was LEGACY)
  • LEGACY_PERMITTED_ENVS = {"dev", "local", "test"} — legacy refused at startup outside these environments when require_sdk_chassis_in_prod=True (the new default)
  • Error message clarified: "must be 'sdk'" instead of "production"

6. Settings

Modified engine/config/settings.py:

  • require_sdk_chassis_in_prod: bool = True (was False) — legacy side door is now opt-out, not opt-in

7. SDK Pin

Updated constellation-node-sdk from a770e853 to 69c6c67:

  • Current pin defaults attachments off (0 / 0), so bare `NodeR

https://claude.ai/code/session_0179fXWHFZQcA47NMj11345X

…IE egress

Forensic seam audit repairs (CEG side of EIE <-> Gate <-> CEG):

- engine/spec.yaml advertises only the CEG-owned, implemented, Gate-routable
  actions (match, sync, outcomes, resolve). The 23 unimplemented `graph-*`
  names are gone and `enrich` is never advertised: Gate owns that action name
  for EIE, and a CEG replica advertising it would collide on the same route.
- chassis/entrypoint.py defaults to the SDK TransportPacket chassis; the legacy
  dict chassis (api-key auth, no Gate provenance) is a direct-ingress side
  door and is refused outside dev/local/test. require_sdk_chassis_in_prod
  now defaults to True.
- engine/gate_egress.py is the only CEG -> peer egress: request_enrichment()
  asks Gate to run EIE's `enrich` with an EIE-shaped payload, one attempt,
  idempotency-keyed, fail closed when GATE_URL is unset. The ROI health
  trigger now actually dispatches through it instead of returning a payload
  it never sent.
- Gate_SDK pinned to main a0827f2 (pyproject, requirements, poetry.lock via
  `poetry lock`, validate_sdk_pin); test fixtures updated for the pinned SDK.
- docker-compose (dev + prod), Makefile, .env.template and the OpenAPI note
  select the SDK chassis, carry GATE_URL / registration / signing config,
  and drop `enrich` from L9_ALLOWED_ACTIONS.
- tests/architecture/test_seam_gate_only.py locks all of the above.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0179fXWHFZQcA47NMj11345X
The real-process seam E2E showed that with L9_REQUIRE_SIGNATURE=true every
env-configured node rejected Gate's signed responses, because the SDK's
get_gate_client_config_from_env() never loaded L9_VERIFYING_KEYS_JSON.
Gate_SDK 69c6c67 (main a0827f2 + that fix) is the one revision the whole
EIE <-> Gate <-> CEG rail now runs; poetry.lock regenerated with `poetry lock`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0179fXWHFZQcA47NMj11345X
Copilot AI lite review requested due to automatic review settings September 4, 2026 15:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T15:57:06.779914Z 38fc3de PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

⚠️ Large PR Warning
Reviewable lines changed: 737
Warning threshold: 300 lines
Consider splitting for easier review

📋 Best Practices for Large Changes

  1. Refactoring + Features: Separate into 2 PRs
  2. Multiple Features: One PR per feature
  3. Database + Code: Separate migration from logic
  4. Generated Code: Exclude it from reviewable-size accounting

This PR passes the blocking limit but is larger than recommended.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

L9 Audit Harness Report

  • Generated: 2026-09-04T16:10:10.996099+00:00
  • Repo root: /home/runner/work/Cognitive.Engine.Graphs/Cognitive.Engine.Graphs
  • Overall result: ✅ PASSED
  • Exit code: 0

Step Results

Step Status Exit Code Notes
Architecture Audit ✅ Passed 0
Spec Coverage ✅ Passed 0
Contract Wiring ✅ Passed 0

Architecture Audit Findings

Severity Count
🔴 CRITICAL 0
🟠 HIGH 0
🟡 MEDIUM 17
🔵 LOW 0

See artifacts/audit_report.md for full details.

Spec Coverage

  • ✅ Implemented: 37
  • ⚠️ Partial: 9
  • ❌ Missing: 0
  • Total features: 46
Category Implemented Partial Missing Total
gates 10 0 0 10
scoring 7 0 0 7
v1.1_node 2 0 0 2
v1.1_edge 2 0 0 2
v1.1_action 0 2 0 2
v1.1_scoring 1 1 0 2
action_handler 0 6 0 6
gds_algorithm 5 0 0 5
research_pattern 10 0 0 10

See artifacts/coverage_report.md for full details.

Next Steps

All checks passed. Safe to merge.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38fc3defdc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engine/health/enrichment_trigger.py
Comment thread docker-compose.yml Outdated
Comment thread engine/gate_egress.py Outdated

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.

🟡 Changes recommended

engine/gate_egress.py has concrete correctness/contract inconsistencies (idempotency normalization + entity field override risk) and several updated docs/help texts conflict with the actual allowed legacy env set.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR implements the 2026-09-02 seam audit outcomes by enforcing Gate-only ingress/egress boundaries for CEG: removing phantom advertised actions, making the SDK (TransportPacket) chassis the default (legacy allowed only in dev/local/test), and wiring the CEG → Gate → EIE enrich path through a single audited egress module.

Changes:

  • Introduces engine/gate_egress.py and updates the health enrichment trigger to dispatch enrich via Gate with fail-closed semantics.
  • Adds architecture/contract tests that lock seam invariants (advertised actions, chassis defaults, Gate-only egress/ingress, and no peer URL/raw HTTP).
  • Updates deployment + dependency pinning to default to the SDK chassis and require Gate configuration in production.
File summaries
File Description
tests/unit/test_node_app.py Updates SDK pin expectations around attachment/packet cap defaults.
tests/unit/test_gate_egress.py Adds unit coverage for Gate-mediated enrich egress behavior and idempotency.
tests/contracts/test_chassis_parity.py Extends contract tests for SDK default selection and stricter legacy refusal.
tests/architecture/test_seam_gate_only.py Adds forensic seam guardrails across spec, code, env vars, and transport usage.
tests/architecture/init.py Establishes tests/architecture as a test package.
scripts/validate_sdk_pin.py Updates the SDK git pin validator to the new revision.
requirements.txt Bumps constellation-node-sdk git pin.
pyproject.toml Bumps constellation-node-sdk git pin (Poetry).
poetry.lock Updates lockfile to reflect the new SDK revision and transitive dependency metadata.
Makefile Defaults local run to SDK chassis; adds an explicit legacy target.
engine/spec.yaml Replaces phantom graph-* advertised actions with implemented CEG-owned actions only.
engine/health/enrichment_trigger.py Routes reenrichment triggering through engine.gate_egress.request_enrichment() and returns dispatch results.
engine/gate_egress.py Adds the single permitted CEG→Gate egress API for requesting EIE-owned enrich.
engine/config/settings.py Turns on require_sdk_chassis_in_prod by default to block legacy direct-ingress outside dev/local/test.
docs/contracts/api/openapi.yaml Updates API contract docs to reflect chassis defaults and seam behavior.
docker-compose.yml Switches local compose default to SDK chassis and Gate configuration; removes enrich from allowed actions.
docker-compose.prod.yml Makes SDK chassis mandatory in prod and requires Gate + signing configuration (no defaults).
chassis/entrypoint.py Sets SDK as the default chassis and restricts legacy chassis selection to dev/local/test when enforcement is enabled.
.env.template Updates defaults and notes for SDK chassis + allowed actions consistent with seam ownership.
Review details

Suppressed comments (1)

engine/gate_egress.py:81

  • enrichment_idempotency_key() hashes target_fields without the same normalization used by build_enrichment_request() (dedupe + drop empty). For example, ['a'] vs ['a', ''] produce different idempotency keys even though the request payload is identical, which undermines stable retries.
def enrichment_idempotency_key(tenant: str, entity_id: str, target_fields: Sequence[str]) -> str:
    digest = hashlib.sha256("|".join([tenant, entity_id, *sorted(set(target_fields))]).encode("utf-8")).hexdigest()
    return f"ceg:enrich:{tenant}:{entity_id}:{digest[:16]}"
  • Files reviewed: 16/19 changed files
  • Comments generated: 6
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread engine/gate_egress.py Outdated
Comment thread .env.template Outdated
Comment thread Makefile Outdated
Comment thread docker-compose.yml Outdated
Comment thread docs/contracts/api/openapi.yaml Outdated
Comment thread engine/gate_egress.py Outdated
Opt-in auto_enrich_via_gate, keep routing identity authoritative over entity
payload fields, and align legacy/docs/compose with runtime contracts.

Remediation-Cycle: Cognitive.Engine.Graphs#259/cycle-1
Co-authored-by: Cursor <cursoragent@cursor.com>
@cryptoxdog

Copy link
Copy Markdown
Collaborator Author

PR Remediation — Cycle 1 Summary

Commit: e4fa205 | Findings processed: 9 | CI gates: Unknown (no precommit-repo target)

Fixed (9)

Finding File Change
auto enrich feature flag engine/health/enrichment_trigger.py auto_enrich_via_gate default False
no Gate service docker-compose.yml document external Gate + :8080
entity overrides identity engine/gate_egress.py entity_id/domain win
entity override (copilot) engine/gate_egress.py same merge-order fix
legacy env docs .env.template dev
legacy Makefile help Makefile dev
SDK defaults comment docker-compose.yml attachments intentionally disabled
legacy openapi docs docs/contracts/api/openapi.yaml dev
missing idempotency_key engine/gate_egress.py include on gate_not_configured

Deferred (0)

none

Acknowledged (0)

none

Disagreed (0)

none


Local verify: Unknown (no precommit-repo target) | Threads resolved: 9/9

@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

@cryptoxdog
cryptoxdog merged commit 90279a8 into main Sep 4, 2026
53 of 63 checks passed
@cryptoxdog
cryptoxdog deleted the claude/gateway-seam-forensic-audit-m7cqt6 branch September 4, 2026 16:11
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.

3 participants