Skip to content

Comments

refactor(server): harden failure-path firewall (SanitizedError, DLQ scrub, drop ledger, ENTRY_ANALYZED contract)#620

Merged
wileland merged 2 commits intodevelopfrom
codex/implement-run-b-failure-path-firewall
Feb 20, 2026
Merged

refactor(server): harden failure-path firewall (SanitizedError, DLQ scrub, drop ledger, ENTRY_ANALYZED contract)#620
wileland merged 2 commits intodevelopfrom
codex/implement-run-b-failure-path-firewall

Conversation

@wileland
Copy link
Owner

Motivation

  • Prevent plaintext transcript or model-output fragments from leaking via worker errors, logs, events, or queue payloads by introducing a failure-path firewall and strict contract enforcement.
  • Provide a deterministic consumer contract for ENTRY_ANALYZED so downstream consumers can safely rely on schemaVersion and processingStatus semantics.
  • Record drops in a structured ledger that contains only safe metadata (no plaintext), enabling auditability without exposing sensitive text.

Description

  • Added central contract and types in server/src/utils/failureFirewallContracts.js including ENTRY_ANALYZED_SCHEMA_VERSION, PROCESSING_STATUS, PROCESSING_WARNING_CODE, DROP_REASON_CODE, and a UNANCHORED_SIGNAL schema stub.
  • Implemented SanitizedError + utilities in server/src/utils/failureFirewall.js to sanitize errors, fingerprint messages, enforce a job-payload whitelist (entryId,taskId), validate/produce ENTRY_ANALYZED envelopes, and build structured drop-ledger records.
  • Hardened orchestration and worker boundaries: agentOrchestration enforces whitelisted job payloads and sanitizes enqueue-failure messages; eventBus.emitEntryAnalyzed now wraps/validates envelopes before emitting; reflection, scribe, and archivist workers enforce whitelists and record only sanitized error metadata (warning codes + fingerprints) instead of raw fragments.
  • Added tests and docs: server/src/utils/__tests__/failureFirewall.test.ts (whitelist, schema branching, ledger shape), server/src/orchestration/__tests__/eventBus.contract.test.ts (envelope + canary check), a leak-canary test in server/src/workers/__tests__/reflection.worker.test.ts, and documentation server/docs/run-b-failure-firewall.md.

Testing

  • Ran pnpm lint:ci locally and it completed successfully (no JS/TS changes detected).
  • Ran node scripts/codex_preflight.mjs --ci and it passed alignment checks.
  • Ran focused server test subset with pnpm --filter server exec vitest run src/utils/__tests__/failureFirewall.test.ts src/orchestration/__tests__/eventBus.contract.test.ts src/workers/__tests__/reflection.worker.test.ts and all three test files passed.
  • Ran the broader pnpm --filter server test / pnpm test:ci in the sandbox; the full suite failed in this environment due to missing optional runtime test dependencies (examples: express, supertest, mongoose, langfuse, openai, jsonwebtoken), not due to the new firewall logic itself; targeted unit tests for the new contracts passed.

Codex Task

@github-actions
Copy link

github-actions bot commented Feb 20, 2026

Audit

Audit artifacts not found.

Schema

No drift detected ✅

Codex

No Codex outputs yet.

@wileland wileland changed the base branch from codex/run-b-failure-firewall-exec-2026-02-20 to develop February 20, 2026 17:58
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 11241e8427

ℹ️ 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 on lines +11 to +12
const envelope = toEntryAnalyzedEnvelope(payload);
validateEntryAnalyzedEnvelope(envelope);

Choose a reason for hiding this comment

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

P2 Badge Preserve legacy ENTRY_ANALYZED payload compatibility

This new validation path now rejects payloads that only carry entryId/userId (because toEntryAnalyzedEnvelope defaults missing processingStatus to complete, then validateEntryAnalyzedEnvelope requires non-empty bloomCards), which breaks existing emitters that still send minimal events such as scripts/simulate_nervous_system.js (lines 88-99 and 148-153). In those flows, emitEntryAnalyzed(...) now throws ENTRY_ANALYZED complete status requires cards, so the simulation/experiment path aborts before Crucible side effects can run.

Useful? React with 👍 / 👎.

@wileland wileland merged commit ba0692e into develop Feb 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant