Deny retained-field content at model input boundaries

Merged
SI
2d ago
+850-25

Marked retained-field messages could reach model conversion, auto-routing and provider calls, and journaled conversion or tool-result iterations could bypass a conversion-only check.

The existing workflow body now denies marked original/converted/iteration content outside journaled steps. Conversion, routing and the actual provider step also check before their effects. Slack checks stored content before dropping metadata during reconstruction. setupChatRequest and getGeneralAgent reject before setup/downloads, and the actual ToolLoopAgent prepareStep checks each subsequent model input and tool result. The shared assertion reuses the reserved-family recognizer and throws a static, non-retrying FatalError. It rejects the whole invocation rather than orphaning tool-call/result pairs through filtering.

Existing server account/session/chat scope and unmarked behavior remain unchanged. No current-source grant, cached-ready admission, latest lookup, re-key, retain, expansion, public route, live provider call, SQL or activation.

Validation: 238 tests pass across 31 files, including actual caller wiring and actual ToolLoopAgent with synthetic model/tool seams. Initial marked messages cause no converter/download/provider invocation; marked tool results stop before the next provider call. All17 compiled offline workflow cases passed at8f57, with zero network attempts. Independently captured journals qualify real running-workflow resumption after completed conversion/agent steps and denial before subsequent provider calls. Explicit reenqueueRun after terminal failure is skipped by the runtime: unchanged traces prove duplicate-delivery no-op, not another disclosure-assertion execution. Full lint and strict guard types pass. Local whole-production types are limited by missing MCP extension dependencies/generated UI in the reused tree; clean-install CI passed on implementation head 8f57c584, including production and response/release TypeScript checks.

Call graph and limits: lib/chat/retained-field/README.md. Unmarked prose/serialized content, independent system/knowledge sources, other callers, metadata/stream/export paths, previously emitted output and positive authority integration remain separate. This is source qualification only; no live account/history/provider request, merge or manual deployment.

Reviewed implementation head 8f57c5848fedefc26135194b2edd6cb573024f7f, tree 00d4e391322ed3c3f5bd5aac11157a5c45d505ce, base main 4b7e344b82ea013fff24ee0e6219afe959c3e370. Source-only candidate; implementation CI passed at8f57 and independent reviews returned bounded PASS.

Documentation-only successor afcaac4ba92aba3599fa139ce8bc2549e2686ee6 (tree 78527e505c2b6a728070ca6e0451b59dd52edc16) corrects that evidence distinction. Every tracked entry except the qualification README is byte-identical to reviewed8f57, including production, tests and fixture. No tests rerun; prior CI/test receipts remain attributed to8f57. Root owns final release checks.
Cleanup repair successor d1a2948489bf551cf4160c5cdc3f4ea67d7af4f7 (tree db8343ffa173bc535fdc840f43c80bf64273eca3): early raw/converted privacy denials now run existing legacy CAS-clear, terminal finish/close, and owned headless-key cleanup. Fenced and unrelated startup-failure behavior is preserved. The setup test now contains a matching tool-call/result pair and verifies unchanged input. Validation for this repair: failing-first four regressions, then 70 passing focused tests, full lint, and four compiled offline legacy denial cases with zero network attempts. Exact-head CI and independent closure remain pending; prior receipts above are not attributed to this successor.

Review-test successor 70bf470661909ea87e6e96fc53cc548c051a7811 changes only the general-agent test and compiled harness. Adds a reachable artist-knowledge fixture (late-guard mutation fails the knowledge assertion), accurately names mixed file/tool-result SDK coverage, and shares the terminal-delivery no-op assertion. 31 focused tests, four compiled cases with zero network attempts, lint and formatting pass. Production is byte-identical to d1a29484. The custom P2 100-line finding is an explicit proposed scope exception: step was already 271 lines; this PR adds only three guard-related lines. Hosted Rule3 configuration was not available in repository sources; final exception disposition remains with the coordinating review. Successor CI and independent closure pending.