Skip to content

feat(secrets): streaming CoT-redaction prototype + feasibility (roadmap-v0.6 E.4)#84

Merged
RNT56 merged 3 commits into
mainfrom
claude/v06-e4-cotstream
Jun 29, 2026
Merged

feat(secrets): streaming CoT-redaction prototype + feasibility (roadmap-v0.6 E.4)#84
RNT56 merged 3 commits into
mainfrom
claude/v06-e4-cotstream

Conversation

@RNT56

@RNT56 RNT56 commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

Roadmap-v0.6 E.4 (analysis-first) — decides whether token-by-token chain-of-thought streaming is compatible with the redaction boundary. Conclusion: feasible, with a working prototype + a feasibility doc.

  • crustcore_secrets::token_stream::TokenRedactor — buffers streamed tokens to a redaction boundary (newline), scans with the existing Redactor, emits only fully redacted chunks. A forced (no-boundary) emit retains only the longest dangling needle-prefix suffix (Redactor::longest_dangling_prefix) — the start of a not-yet-finished secret — so the buffer stays bounded and a partial secret is never emitted.
  • docs/cot-streaming.md — the design, red-team analysis, latency bound, the one constraint, and the wiring (live seam reuses the net token stream behind reveal_reasoning).

CI core vs live seam

  • CI core (6 red-team tests): secret split across tokens; secret straddling a forced emit; full-secret-present at forced emit; no false positives; flush tail; bounded worst-case (buffer never grows past max_buffer + a token).
  • Live seam (not built): the provider must expose an incremental token stream; the dispatch loop forwards the redacted chunks; gated behind reveal_reasoning. No new #[ignore] test (the prototype is pure).

Trust boundary

No unredacted secret reaches the user mid-stream (invariants 2, 3); the buffer is bounded (invariant 11); behind the existing reveal_reasoning opt-in — no invariant relaxation. Adds two read-only methods to Redactor (length-only; leak nothing).

Tests run

cargo xtask verifygreen. Nano unchanged at 53.5%. Independent off main.

🤖 Generated with Claude Code

RNT56 and others added 3 commits June 29, 2026 10:35
…ap-v0.6 E.4)

Adds crustcore_secrets::token_stream::TokenRedactor + the supporting
Redactor::longest_dangling_prefix / max_needle_len.

TokenRedactor buffers streamed model tokens to a redaction boundary
(newline), scans with the existing Redactor, and emits only fully redacted
chunks — a secret split across tokens or lines is caught before any byte
reaches the user (invariants 2, 3). A forced (no-boundary) emit retains only
the longest dangling needle-prefix (the start of a not-yet-finished secret),
keeping the buffer bounded without ever emitting a partial secret.

6 red-team tests; docs/cot-streaming.md concludes token-level CoT streaming
is feasible behind the existing reveal_reasoning opt-in, with the latency
bound (<500ms) and the one constraint (boundary char not inside a secret).

Analysis + a pure core; zero nano impact. `cargo xtask verify` green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds token_stream::redact_stream — the transport-agnostic streaming pipeline
the live CoT loop runs: pulls each deframed provider token, hands every
redacted chunk to an emit sink in order, flushes the buffered tail at
end-of-stream. Streamed tokens are model output (untrusted, invariant 7);
every chunk passes through the redactor before emit (invariants 1-3). A
secret split across any number of tokens is still caught (TokenRedactor
buffers to a safe boundary and only emits a leak-free prefix).

This makes E.4 a real pipeline, not just the analysis doc + the buffering
core: the only remaining live inch is the SSE/websocket socket producing the
tokens, which lives in the daemon/net layer (this crate stays std-only).
2 new CI tests (split-secret end-to-end + empty stream); no lib.rs change
(not a further contract-file edit); zero nano impact. verify green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@RNT56 RNT56 merged commit aa544c0 into main Jun 29, 2026
3 checks passed
@RNT56 RNT56 deleted the claude/v06-e4-cotstream branch June 29, 2026 21:24
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