Skip to content

perf: bound session startup work - #108

Merged
scawful merged 12 commits into
featuresfrom
perf/session-startup-bounds
Aug 5, 2026
Merged

perf: bound session startup work#108
scawful merged 12 commits into
featuresfrom
perf/session-startup-bounds

Conversation

@scawful

@scawful scawful commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • reuse the session harness bootstrap and task-matched skill results instead of collecting both twice during session prepare-client
  • carry a stale cache probe's mount fingerprint into the replacement write, avoiding a second recursive file walk
  • remove expired session-pack entries and keep hash-named cache entries bounded to 512 while preserving unrelated files
  • pass the MCP registry already built by serve() into startup diagnostics, while keeping afs doctor's independent registry build
  • remove afs.context_pack from the mypy grandfather baseline after cleaning its remaining type errors

Why

Each wrapper startup could perform two broad bootstraps, two skill discovery/ranking passes, and (on a stale cache entry) two recursive mount fingerprint walks. Every stdio MCP process also rebuilt its full tool registry in background diagnostics. Expired five-minute cache entries were never pruned, so the rebuildable cache could grow indefinitely.

The changes keep output contracts intact and only reuse state after validating the context and scope. Cache pruning is best-effort, only considers 64-character lowercase-hex JSON names owned by this cache, skips symlinks, retains the just-written entry, and never touches unrelated JSON files.

Verification

  • make VENV=/Users/scawful/src/lab/afs/.venv lint
  • make VENV=/Users/scawful/src/lab/afs/.venv type-check
  • HOME=/tmp/afs-perf-session-startup-home AFS_CONTEXT_ROOT= make VENV=/Users/scawful/src/lab/afs/.venv test — 2525 passed, 4 skipped
  • focused session/context pack tests after the type-ratchet cleanup — 70 passed
  • focused diagnostics/MCP tests — 188 passed

The full suite used an isolated temporary HOME; no user cache files were read, pruned, or modified.

@scawful
scawful marked this pull request as ready for review August 5, 2026 03:23
@scawful
scawful requested a review from robbdi as a code owner August 5, 2026 03:23
@scawful
scawful merged commit ece4805 into features Aug 5, 2026
12 checks passed
@scawful
scawful deleted the perf/session-startup-bounds branch August 5, 2026 03:24
scawful added a commit that referenced this pull request Aug 5, 2026
* perf: bound session startup work

* fix: harden session pack cache validity

* fix: ignore cache special files without blocking

* fix: revalidate cache ownership before removal

* fix: harden session cache consistency

* fix: serialize context pack artifact pairs
scawful added a commit that referenced this pull request Aug 5, 2026
* perf: bound session startup work

* fix: harden session pack cache validity

* fix: ignore cache special files without blocking

* fix: revalidate cache ownership before removal

* fix: harden session cache consistency

* fix: serialize context pack artifact pairs
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