Skip to content

perf(infrastructure): memoize EvidenceLedger bundle, remove JSON tree generators, and borrow immutable snapshot members - #13606

Merged
morluto merged 1 commit into
mainfrom
perf/evidence-ledger-json-tree-and-snapshot-cache
Nov 22, 2026
Merged

morluto merged 1 commit into
mainfrom
perf/evidence-ledger-json-tree-and-snapshot-cache

Conversation

@morluto

@morluto morluto commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Closes #13605

Summary

  • Memoize #cachedImmutableBundle on EvidenceLedger, invalidated on #commitAccounting and clear().
  • Replace per-object Generator state machines in estimateJsonStorage (src/application/JsonAuthenticationHeadroom.ts) and freezeOwnedJsonTreeSnapshot (src/domain/immutableJson.ts) with explicit index-based frame stacks.
  • Preserve immutable snapshot membership via immutableJsonSnapshotMember in SessionEvidenceReuse.ts and reuse cached #target / #binding in AnalysisSnapshotCache.record and recordWorkflow.

Validation

  • npm run test:local -- src/domain/immutableJson.test.ts src/application/investigation/EvidenceLedger.test.ts src/application/binary/AnalysisSnapshotCache.test.ts (75/75 passed)
  • npm run check:fast (typecheck, lint, and architecture guards passed)

… generators, and borrow immutable snapshot members
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T20:51:38.538508Z 5e62c9c 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.

@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no actionable correctness or security issues were found.

Summary

This PR avoids repeated bundle construction and JSON-walk overhead.

  • Evidence bundles are reused until the ledger changes.
  • The JSON size scan walks containers with index frames.
  • Owned JSON trees are sealed with index-based frames.
  • Session results reuse sealed Evidence payloads.
  • Snapshot entries reuse the selected target and profile.

No actionable issues were found. Tests were not rerun. Supersession could not be checked because GitHub authentication was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Read["immutableBundle()"] --> Cached{"Bundle cached?"}
  Cached -->|Yes| Return["Return sealed bundle"]
  Cached -->|No| Build["createImmutableEvidenceBundle()"]
  Build --> Save["Cache sealed bundle"]
  Save --> Return
  Write["Committed ledger change"] --> Accounting["#commitAccounting()"]
  Accounting --> Invalidate["Clear cached bundle"]
  Clear["clear()"] --> Invalidate
Loading

Reviews (1) · Last reviewed commit: "perf(infrastructure): memoize EvidenceLe..." · Reviewed by Greptile

@morluto
morluto merged commit 1b828be into main Nov 22, 2026
41 checks passed
@morluto
morluto deleted the perf/evidence-ledger-json-tree-and-snapshot-cache branch November 22, 2026 20:56
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction performance Performance regressions, scaling limits, and bounded-resource work labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction performance Performance regressions, scaling limits, and bounded-resource work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(infrastructure): memoize EvidenceLedger bundle, remove JSON tree generators, and borrow immutable snapshot members

1 participant