Repository navigation
perf(environment): index observed-state write cutoffs - #5350
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; no actionable issue was found. SummaryThis PR replaces repeated write-root scans with one index per projection.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Recorded writes in timeline order] --> B[Build admitted prefix and wildcard index]
C[Read type] --> D{Cutoff cached?}
D -->|No| E[Find earliest related write]
B --> E
E --> F[Cache write or no match]
D -->|Yes| G[Use cached cutoff]
F --> G
G --> H[Bound initial observations]
H --> I[Assemble backed types and entities]
Reviews (1) · Last reviewed commit: "perf(environment): index observed-state ..." · Reviewed by Greptile |
… into feat/environment-state-coverage Keep main's tool description and change only its environment-state documents clause to this branch's rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Index parsed recorded-write roots once per state projection and reuse positive and negative type cutoffs. Preserve wildcard, ancestor/descendant, canonical timeline and Evidence semantics under the existing representation budget. Follow-up to the final performance thread on morluto#5319, which was merged while this optimization was being validated. Validated with 508 relevant source tests, compiled state CLI/MCP cases, real Gitea HAR CRUD/search captures and Chromium captures, static/build/docs/catalog gates, and equivalent completed before/after projections.
Summary
State extraction reparsed every write root for each read type and repeated the search while assembling output. It now admits one prefix/wildcard index per projection, caches each type’s cutoff (including no match), and derives backed type membership once.
Follow-up to the final performance review on #5319. That PR was merged while this optimization was being validated; this diff is based on current main
3fca2e0ca.Problem and expected behavior
With 1,000 collection tools and 1,000 unrelated writes, repeated root parsing costs CPU even though the projected state is unchanged. The same completed file-to-state task changed from 1,301 ms warm / 1,300 ms CPU to 624 ms warm / 624 ms CPU, with identical parent IDs and normalized output digests. First-call and process-family memory results are in verification.md; no general memory reduction is claimed.
Change and scope
Contract and boundary impact
EnvironmentStateExtractionandStateWriteCutoffs.Expected effects:
Evidence and regression coverage
Validation performed
Relevant domain/application/contracts plus capture validation: 41 files, 508 passed, 3 existing skips.
Serial static/build/artifact gate: 11 tasks passed; both selected compiled state CLI/MCP cases passed.
Docs/catalog/format checks: 9 tasks passed; architecture guards passed across 1,603 source files; README consistency: 5 tests passed.
One CPU/worker throughout; static/build peak process-family RSS 4,745 MiB. No workspace OOM.
GitHub CI: all selected lanes passed, including source tests, all five built test shards, portable aggregation, AgentEnv bundle execution and Linux native package verification.
Greptile reviewed
27e3d5cd61: 5/5, no actionable findings. Codex cloud review was unavailable because its review quota was exhausted.The separate human-readiness declaration check is intentionally not attested and is bypassed under the operator’s explicit standing instruction.
Compatibility, safety, and release
No public schema, transport default, target authority or write-effect change. Matching and complete output digests are preserved. This optimization uses the existing first-related-recorded-write model and retains its documented inference limitations.
Author readiness
Human owner: @gensokyo-dev
Submitted ready under the repository operator’s explicit instruction. Human-review attestations remain unchecked.
Before merge