Skip to content

Commit 2c03352

Browse files
authored
Merge pull request #1751 from entireio/fix/redact-layer-vocab-and-pins
fix(redact): reconcile layer-count vocabulary and pin provider-token boundaries
2 parents 85d9ec5 + 2d52797 commit 2c03352

21 files changed

Lines changed: 179 additions & 90 deletions

cmd/entire/cli/checkpoint/checkpoint_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4695,7 +4695,7 @@ func TestCheckpointSummary_HasReview(t *testing.T) {
46954695
// Summary.Intent and ReviewPrompt that previously bypassed redaction because
46964696
// the dispatcher only matched .jsonl. The PR 1236 fix extended the JSON-aware
46974697
// branch to .json. We assert via a low-entropy AWS-key shaped secret (catches
4698-
// the 7-layer pipeline) so the test stays deterministic without the OPF binary.
4698+
// the regex-only pipeline) so the test stays deterministic without the OPF binary.
46994699
func TestRedactBlobBytes_JSONMetadata(t *testing.T) {
47004700
t.Parallel()
47014701

cmd/entire/cli/checkpoint/persistent.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ func (s *treeWriter) applyTranscriptBackfill(ctx context.Context, opts UpdateOpt
448448
}
449449
}
450450

451-
// Replace prompts with 7-layer-redacted content.
451+
// Replace prompts with regex-only-redacted content.
452452
if len(opts.Prompts) > 0 {
453453
promptContent := RedactedJoinedPrompts(opts.Prompts)
454454
blobHash, err := CreateBlobFromContent(s.repo, []byte(promptContent))
@@ -715,7 +715,7 @@ func (s *treeWriter) writeSessionToSubdirectory(ctx context.Context, opts WriteO
715715
}
716716
filePaths.AssetsManifest = manifestPath
717717

718-
// Write prompts via the 7-layer pipeline. OPF runs only in the
718+
// Write prompts via the regex-only pipeline. OPF runs only in the
719719
// pre-push rewrite path (manual_commit_opf_rewrite.go).
720720
if len(opts.Prompts) > 0 {
721721
promptContent := RedactedJoinedPrompts(opts.Prompts)
@@ -2254,12 +2254,13 @@ func (s *treeWriter) copyMetadataDir(ctx context.Context, metadataDir, sessionDi
22542254
return fmt.Errorf("path traversal detected: %s", relPath)
22552255
}
22562256

2257-
// Create blob from file with 7-layer secrets redaction.
2258-
// Post-commit emits 7-layer-only blobs; the pre-push rewrite
2257+
// Create blob from file with regex-only secrets redaction (the
2258+
// eight always-on/opt-in layers).
2259+
// Post-commit emits regex-only blobs; the pre-push rewrite
22592260
// (strategy/manual_commit_opf_rewrite.go) walks the resulting
22602261
// tree, re-redacts these blobs with OPF when enabled, and
2261-
// rewrites entire/checkpoints/v1 into 8-layer commits before
2262-
// they leave the local machine.
2262+
// rewrites entire/checkpoints/v1 into OPF-applied (9-layer)
2263+
// commits before they leave the local machine.
22632264
blobHash, mode, err := createRedactedBlobFromFile(ctx, s.repo, path, relPath)
22642265
if err != nil {
22652266
return fmt.Errorf("failed to create blob for %s: %w", path, err)
@@ -2281,12 +2282,13 @@ func (s *treeWriter) copyMetadataDir(ctx context.Context, metadataDir, sessionDi
22812282
return nil
22822283
}
22832284

2284-
// createRedactedBlobFromFile reads a file, applies the 7-layer redaction
2285-
// pipeline, and creates a git blob. Used by committed-checkpoint writes
2286-
// at post-commit time. The OpenAI Privacy Filter is intentionally NOT
2287-
// run here — OPF lives in the pre-push rewrite path
2288-
// (strategy/manual_commit_opf_rewrite.go), which re-redacts the 7-layer
2289-
// blobs into 8-layer commits before they leave the local machine.
2285+
// createRedactedBlobFromFile reads a file, applies the regex-only redaction
2286+
// pipeline (the eight always-on/opt-in layers), and creates a git blob. Used
2287+
// by committed-checkpoint writes at post-commit time. The OpenAI Privacy
2288+
// Filter is intentionally NOT run here — OPF lives in the pre-push rewrite
2289+
// path (strategy/manual_commit_opf_rewrite.go), which re-redacts the
2290+
// regex-only blobs into OPF-applied (9-layer) commits before they leave the
2291+
// local machine.
22902292
// JSONL files get JSONL-aware redaction; all other files get plain byte redaction.
22912293
func createRedactedBlobFromFile(ctx context.Context, repo *git.Repository, filePath, treePath string) (plumbing.Hash, filemode.FileMode, error) {
22922294
info, err := os.Stat(filePath)
@@ -2328,8 +2330,8 @@ func createRedactedBlobFromFile(ctx context.Context, repo *git.Repository, fileP
23282330
// JSON-shaped files (.jsonl or .json) get JSON-aware redaction (falling
23292331
// back to plain bytes on parse failure so regex/credential layers
23302332
// still apply); other files get plain byte redaction. When
2331-
// usePrivacyFilter is true the full 8-layer pipeline (including OPF)
2332-
// runs; otherwise the 7-layer pipeline.
2333+
// usePrivacyFilter is true the full 9-layer pipeline (the eight regex
2334+
// layers plus OPF) runs; otherwise just the eight regex layers.
23332335
//
23342336
// .json is handled alongside .jsonl because checkpoint metadata files
23352337
// (metadata.json, per-session metadata.json) carry free-form fields

cmd/entire/cli/checkpoint/persistent_opf_trailer_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import (
1818

1919
// TestWriteCommitted_DoesNotEmitOPFAppliedTrailer is the regression guard
2020
// for the architectural promise: standard post-commit condensation writes
21-
// 7-layer-only blobs and MUST NOT mark them with the Entire-OPF-Applied
21+
// regex-only blobs and MUST NOT mark them with the Entire-OPF-Applied
2222
// trailer. The trailer is emitted exclusively by the pre-push rewrite
2323
// path; if a future change accidentally added it to the standard writer,
2424
// the pre-push rewrite would skip those commits (HasOPFApplied true →
25-
// reparent-only, no actual OPF run) and ship 7-layer content as if it
26-
// were 8-layer. This test pins down that contract.
25+
// reparent-only, no actual OPF run) and ship regex-only content as if it
26+
// were OPF-applied. This test pins down that contract.
2727
func TestWriteCommitted_DoesNotEmitOPFAppliedTrailer(t *testing.T) {
2828
t.Parallel()
2929

cmd/entire/cli/checkpoint/prompts.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ func SplitPromptContent(content string) []string {
2323
return prompts
2424
}
2525

26-
// RedactedJoinedPrompts joins prompts and runs the 7-layer redaction
27-
// pipeline. OPF runs exclusively in the pre-push rewrite (not here),
26+
// RedactedJoinedPrompts joins prompts and runs the regex-only redaction
27+
// pipeline (the eight always-on/opt-in layers). OPF runs exclusively in
28+
// the pre-push rewrite (not here),
2829
// so the writer's hot path stays predictable. Exported so alternate
2930
// persistent backends produce identically-redacted prompt blobs.
3031
func RedactedJoinedPrompts(prompts []string) string {

cmd/entire/cli/checkpoint/prompts_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ func TestSplitPromptContent_EmptyContent(t *testing.T) {
2828
}
2929

3030
// TestRedactedJoinedPrompts_AppliesSafetyNet verifies the helper joins
31-
// prompts with the canonical separator and runs them through the 7-layer
32-
// pipeline. OPF runs only in the pre-push rewrite path, never here.
31+
// prompts with the canonical separator and runs them through the
32+
// regex-only pipeline. OPF runs only in the pre-push rewrite path, never
33+
// here.
3334
func TestRedactedJoinedPrompts_AppliesSafetyNet(t *testing.T) {
3435
t.Parallel()
3536
got := RedactedJoinedPrompts([]string{"hello", "world"})

cmd/entire/cli/settings/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ type OPFSettings struct {
284284

285285
// PromptDefault controls whether the pre-push hook asks the user
286286
// before running OPF. "" (default) and "ask" both surface the
287-
// interactive prompt; "never" skips OPF and pushes 7-layer content;
287+
// interactive prompt; "never" skips OPF and pushes regex-only content;
288288
// "always" runs without asking. ENTIRE_OPF=yes|no on the push
289289
// invocation overrides this setting per-push.
290290
PromptDefault string `json:"prompt_default,omitempty"`

cmd/entire/cli/strategy/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ func EnsureRedactionConfigured() {
442442
})
443443
}
444444

445-
// OpenAI Privacy Filter (opt-in 8th layer).
445+
// OpenAI Privacy Filter (opt-in 9th layer).
446446
if s.Redaction != nil && s.Redaction.OpenAIPrivacyFilter != nil {
447447
opf := s.Redaction.OpenAIPrivacyFilter
448448
redact.ConfigurePrivacyFilter(redact.OPFConfig{

cmd/entire/cli/strategy/manual_commit_condensation.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,13 @@ type condenseOpts struct {
105105
allAgentFiles map[string]struct{} // Union of all sessions' FilesTouched for cross-session exclusion (nil = single-session)
106106
}
107107

108-
// redactSessionJSONLBytes runs the 7-layer redaction pipeline over a
109-
// session transcript at post-commit condensation. OPF is intentionally
110-
// NOT included here — it runs exclusively in the pre-push rewrite path
108+
// redactSessionJSONLBytes runs the regex-only redaction pipeline (the
109+
// eight always-on/opt-in layers) over a session transcript at
110+
// post-commit condensation. OPF is intentionally NOT included here —
111+
// it runs exclusively in the pre-push rewrite path
111112
// (strategy/manual_commit_opf_rewrite.go), which re-redacts the
112-
// 7-layer blobs and produces 8-layer commits before the push.
113+
// regex-only blobs and produces OPF-applied (9-layer) commits before
114+
// the push.
113115
//
114116
// Exposed as a var so tests can inject deterministic success/error
115117
// returns. The signature still takes a context so the var can be
@@ -355,7 +357,7 @@ func (s *ManualCommitStrategy) CondenseSession(ctx context.Context, repo *git.Re
355357
summary = generateSummary(ctx, redactedTranscript, sessionData.FilesTouched, state)
356358
}
357359

358-
// Post-commit emits 7-layer-only blobs. OPF runs later in the
360+
// Post-commit emits regex-only blobs. OPF runs later in the
359361
// pre-push rewrite path, never here.
360362
skillEvents := mergeSkillEvents(state.SkillEvents, withSkillEventTurnID(sessionData.SkillEvents, state.TurnID))
361363

cmd/entire/cli/strategy/manual_commit_hooks.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2842,9 +2842,9 @@ func (s *ManualCommitStrategy) finalizeAllTurnCheckpoints(ctx context.Context, s
28422842
// (attribution, files touched, prompts). Hooks run without user interaction
28432843
// so there is no retry path — preserving partial metadata is better than
28442844
// losing everything. Persisting an unredacted transcript would be worse.
2845-
// Run the 7-layer pipeline over the transcript — OPF runs later in
2846-
// the pre-push rewrite path, which re-redacts these 7-layer blobs
2847-
// and produces 8-layer commits before the push goes out.
2845+
// Run the regex-only pipeline over the transcript — OPF runs later in
2846+
// the pre-push rewrite path, which re-redacts these regex-only blobs
2847+
// and produces OPF-applied (9-layer) commits before the push goes out.
28482848
// Externalize inline images BEFORE redaction, mirroring CondenseSession, so the
28492849
// finalized (authoritative, full-session) transcript keeps its placeholders and
28502850
// matching assets instead of re-inlining what condensation lifted out. Opt-in;
@@ -2895,7 +2895,7 @@ func (s *ManualCommitStrategy) finalizeAllTurnCheckpoints(ctx context.Context, s
28952895
redactedTranscript = redact.RedactedBytes{}
28962896
}
28972897

2898-
// Post-commit emits 7-layer-only blobs; the writer joins + redacts
2898+
// Post-commit emits regex-only blobs; the writer joins + redacts
28992899
// via checkpoint.redactedJoinedPrompts. OPF runs later, once per
29002900
// push, in the pre-push rewrite path.
29012901
stores, err := checkpoint.Open(ctx, repo, checkpoint.OpenOptions{})

cmd/entire/cli/strategy/manual_commit_opf_prompt.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
type OPFDecision int
2222

2323
const (
24-
OPFRun OPFDecision = iota // run the rewrite, push 8-layer
25-
OPFSkip // skip the rewrite, push 7-layer
24+
OPFRun OPFDecision = iota // run the rewrite, push OPF-applied (9-layer)
25+
OPFSkip // skip the rewrite, push regex-only (8-layer)
2626
OPFAbort // cancel the push entirely (Ctrl-C / non-TTY abort)
2727
)
2828

0 commit comments

Comments
 (0)