Repository navigation
improve: reduce session import, compaction, and UI startup overhead - #133446
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 3:24 PM ET / 19:24 UTC. ClawSweeper reviewWhat this changesThis PR replaces per-row streaming hashes during legacy session import, avoids unnecessary embedding-provider discovery after compaction, and removes unused duration-formatting imports from the Control UI boot path. Merge readinessKeep open for normal maintainer handling: the final head contains unique performance work, source review found no actionable regression, and required exact-head checks are still in progress. Priority: P3 Review scores
Verification
How this fits togetherLegacy session migration stages transcript JSON before importing it into SQLite, while embedded-session compaction may request a memory sync afterward. The Control UI formats elapsed durations during its booted views; this PR reduces work around all three paths without changing their intended outputs. flowchart LR
A[Legacy session data] --> B[SQLite import staging]
B --> C[One-shot row hash]
C --> D[Deduplicated transcript import]
E[Session compaction] --> F[Memory indexing eligibility]
F --> G[Available memory manager]
G --> H[Post-compaction sync]
I[Control UI boot] --> J[Localized duration output]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +9, Tests +32. Total +41 across 6 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: After exact-head checks are green, retain the shared provider-free eligibility resolver and the behavior-preserving UI cleanup, with no new configuration, schema, or compatibility surface. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: current main resolves the full memory configuration before learning whether a manager exists, while the final head isolates the provider-free eligibility path. This read-only review did not rerun the reported timeout scenario. Is this the best way to solve the issue? Yes. Reusing one eligibility resolver preserves the memory manager as the provider-validation owner, and deleting formatter calls whose values are discarded is the narrowest startup cleanup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d434b3dbe0b2. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
@clawsweeper re-review Head 4da5346 adds a bounded compaction performance fix found while diagnosing CI: shared provider-free memory indexing eligibility avoids embedding discovery before an unavailable backend. The unchanged timeout recovery reproduction improved from 225 seconds to 782 ms; all 242 memory/recovery/hook tests pass and full-priority Codex review is clean. Importer benchmark and packaged-upgrade evidence are in the updated body. Final exact-head CI remains required. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Final head 27e94db removes redundant UI duration formatting found while diagnosing the combined-tree startup budget failure. No budget was raised. Linux preview startup gzip fell from 346,677 B to 345,419 B, with all four redundant duration dependencies absent from startup source maps. All 58 formatter cases pass before and after. Full-priority Codex review is clean across the complete final diff; prior importer and compaction proof is retained in the updated body. Final exact-head CI remains required. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
Compute authorization metadata for spaced and punctuation-leading bang commands, including genuinely mentioned WhatsApp group messages. Keep ClickClack control-command mention bypass distinct from coarse metadata detection. Use the actual native command registry in regression fixtures. Align the UI formatter with the identical cleanup already landed in #133446; no additional UI change is claimed. Proof: native channel boundary RED/GREEN, exact canonical check-stage evidence, full build, fresh independent reviews, and 15 delivered-reply checks through a rebuilt isolated Gateway with real exec targets. Preserve the earlier failed startup attempt and aggregate-check limits in PR evidence.
…penclaw#133446) * perf(sessions): hash staged import rows without stream objects * perf(agents): resolve compaction indexing without embedding discovery * perf(ui): avoid redundant duration formatting at startup
What Problem This Solves
Large legacy-session imports spend avoidable CPU time constructing streaming hash objects for JSON strings that are already complete in the migration spool.
Why This Change Was Made
Use Node's one-shot SHA-256 API for both existing-row preload and incoming-row deduplication. The digest stays a Buffer with identical UTF-8 input, and exact JSON bytes still decide equality. Accepted-only acknowledgement, rejected-identity recency, bounded disk staging, cleanup, and all canonical write/transaction boundaries remain unchanged.
The importer change is a three-line substitution with no production LOC growth. There are no dependency, configuration, schema, index, or persistence-semantic changes. Every supported Node range includes the API; the Node contract, Node 22 source, and Node 24 native implementation were inspected. Streaming hashes elsewhere remain unchanged because their inputs are streamed.
User Impact
Median import wall time improved 3.6% for a deep history and 4.3% for many sessions in an isolated Linux Node 24 comparison. Branching and repeated imports were effectively unchanged. Imported data remains identical. The compaction follow-up below removes unnecessary embedding discovery without changing memory eligibility.
Evidence
tslogand UI declaration errors; the shared dependency tree was not modified. Clean exact-head CI is required before landing.1d628793d9e92775050a77a99ae41a97ee8c67e9against basea39e03cb299f141994ac0f231077b9194acfaa79, using Node 24.19.0 / SQLite 3.53.3. Only the staging owner differs; all other source and dependencies are identical.The branching/replay differences are too small to claim a material gain. Empty, ASCII, Unicode/NUL, lone-surrogate, and 5 MiB input digests also match between APIs.
Packaged stable
2026.7.1-2to candidate2026.8.1at importer head1d628793d9e92775050a77a99ae41a97ee8c67e9passed on Blacksmith Testbox: 4,800 sessions, 1,227,946 events, 10,000 cron jobs, and five complete state assertions. Automatic migration was checked after update and before standalone Doctor. Repeat Doctor completed in 39 seconds against a 60-second budget. Eight Gateway history samples across two agents (600 messages) were identical after restart; startup took 11 seconds and health/readiness/status checks took one second each. The synthetic plugin fixture required explicit capability consent; this proves automatic data migration, not unattended update-channel switching. Profiles and proof artifacts were collected before stopping the worker.Compaction follow-up found during CI
The first CI run failed the unchanged healthy timeout-compaction recovery test at 132.9 seconds. A focused local reproduction failed the same case at 225.1 seconds, with all 29 sibling cases passing. This was a reproducible cold-load defect, not dismissed as runner noise.
Post-compaction sync resolved the complete embedding configuration before discovering whether a memory backend was available. The fixture enables recall through the personal-install defaults but has no memory runtime; the unnecessary OpenAI capability lookup synchronously loaded provider code first. The fix extracts the existing eligibility/source/sync facts into a provider-free resolver shared with full memory configuration. Compaction consumes those facts, and an acquired memory backend owns provider resolution. The built-in manager still performs full provider/multimodal validation before cache reuse or creation; core secret-owner gating remains before any manager acquisition. Custom memory runtimes retain their own provider validation rather than being forced through the built-in adapter's checks.
No test timeout, fixture configuration, assertion, or plugin policy was weakened. The only test-support change points the existing mock at the narrower production resolver. The added 15 production lines establish this shared owner boundary; the importer itself remains net zero. All 242 memory/configuration/recovery/hook tests pass, including the unchanged failing case now completing in 782 ms. Fresh full-priority Codex review is clean. Core typechecking and changed structural guards pass; the local aggregate test typecheck still reports the pre-existing shared-install declarations described above. The full isolated Linux
pnpm buildpassed at head4da5346952f9d59e7f1b47c1d33e79fdc9b6c51e. The next CI run passed the previously failing compaction shard, but exposed the UI budget issue below. Final CI completed successfully for27e94db402d56a298dadd56c5f5a8d033cd57948, including both previously failing jobs. The Docker and benchmark evidence above applies to the unchanged importer at the named hash.ClawSweeper's final-head review found no actionable code issues. Its rank-up move—green exact-head CI—is satisfied. The remaining production growth (net +9) establishes the shared provider-free indexing boundary; the unchanged compaction recovery case and final CI verify that it removes the cold load. The review's stored-data heuristic does not describe a data-model change: this diff changes no SQL, schema, tables, indexes, retention, persistent shape, or configuration, and preserves all store/vector values.
Startup cleanup required by the final integration build
The combined tree with newer main (
5ce50c5cf5ba7454cced0be8079f5c2f7833c46e) exceeded the unchanged UI startup gzip limit by seven bytes: 346,768 B against 346,761 B. This was not dismissed as a flaky result: main had 77 intervening UI/protocol file changes, while the PR head alone built at 346,677 B. Startup source maps excluded the importer and memory changes.The UI's localized duration functions called the core formatter and discarded its result on every valid input. Removing those calls preserves their existing invalid-input returns and all localized rounding/Intl output, while removing the only startup import of the core duration helpers,
pretty-ms, andparse-ms. The Linux preview built at 345,419 B, 1,258 B smaller than the preceding head build; all four dependency sources disappeared (402 mapped sources to 398). Build identity differs between the two snapshots, so the exact byte delta includes that small variation. No budget, markup, stylesheet, or translation text changed.All 58 formatter tests pass before and after, including invalid values, zero versus positive fractions, rounding boundaries, and French output. These tests protect output equivalence; there is no visual change to illustrate. Final full-priority Codex review found no actionable issues across all six files. Production is +50/-41 (net +9), with +33/-1 test/test-support lines. The added core indexing boundary accounts for the remaining production growth; the UI cleanup deletes six production lines. All Testbox workers have been stopped after proof collection.