Skip to content

fix: cache the parse cache kapi 1.2 writes, not retired paths - #8

Merged
asgeirf merged 4 commits into
mainfrom
fix/cache-state-paths
Sep 15, 2026
Merged

asgeirf merged 4 commits into
mainfrom
fix/cache-state-paths

Conversation

@asgeirf

@asgeirf asgeirf commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

The state cache (cache-tm, on by default) cached .kapi/tm.db and .kapi/cache. kapi 1.2 writes neither, so it saved nothing.

What kapi 1.2 writes

From running v1.2.0-rc32 on a fixture and reading core/project/layout.go and core/projectdb at that tag:

  • Committed: kapi.yaml, and everything under .kapi/ except work/ and filters.local.json. That includes the content memory bundles and the unit-state record kapi up writes.
  • .kapi/work/cache/docs: the parse cache. Each entry is keyed by absolute path, content hash, parse configuration, recipe and kapi build.
  • The rest of .kapi/work/:
    • store.db, which holds stored targets and the unit working set
    • cache/extractions, cache/redaction and vault/
    • server sync state

Change

  • The cache step caches only .kapi/work/cache/docs.
    • Key: kapi-parse-<os>-<kapi version>-<ref>-<job>-<run id>-<attempt>.
    • A run restores the newest cache for the same kapi version, preferring the same ref.
  • cache-tm keeps its name. Its description, the step comments and the README say what is cached and why the rest is not.
  • The server-auth README example pins a prerelease, because latest installs a release without kapi up.

Tests

Two new jobs, State cache save and State cache restore, run on ubuntu and macOS.

  • They run kapi status, kapi check, kapi check --ship and kapi up on test/fixture.
  • A run with the restored cache must match a cold run of a pristine copy in exit codes, output and written files. It must still match after a source change.
  • A negative control restores store.db and requires a difference.

Evidence

  • Unchanged action (7087339): run 34937239658. The save jobs' post step logs Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved. The restore jobs find no cache and fail.
  • Fix (c4c0ad8): run 34937356412 is green.
    • The restore jobs log Cache restored from key: kapi-parse-Linux-1.2.0-rc32-8/merge-test-state-cache-save-34937356412-1, restore 5 files, and report Identical for all three comparisons.
  • Caching all of .kapi/work (6400119, reverted in 6e43d7b): run 34937481197 fails. With the store restored:
    • kapi status reports fr at 100% before kapi up
    • kapi check --ship changes exit code
    • kapi up runs 0 passes and writes no targets

🤖 Generated with Claude Code

https://claude.ai/code/session_01VRid8i4qnuNfE7Lio73Uu4

asgeirf and others added 4 commits September 15, 2026 08:28
Adds a fixture project and two jobs: the first runs it and lets the
action save its cache, the second restores the cache and requires a warm
run to match a cold run of a pristine copy in every exit code, output and
written file. A negative control restores .kapi/work/store.db and requires
the comparison to report a difference.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VRid8i4qnuNfE7Lio73Uu4
The state cache cached .kapi/tm.db and .kapi/cache, which kapi 1.2 never
writes, so it saved nothing. It now caches .kapi/work/cache/docs, the one
path under .kapi/work that kapi keys by content, configuration, recipe
and build. The store and the rest of .kapi/work stay out: restoring them
changes what kapi status, kapi check --ship and kapi up report. The key
carries the resolved kapi version, and the input keeps its name.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VRid8i4qnuNfE7Lio73Uu4
Temporary. Restoring the store has to fail the round trip; this commit is
reverted once the run shows it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VRid8i4qnuNfE7Lio73Uu4
…iling"

The run on that commit showed the round trip failing with the store
restored; the action caches .kapi/work/cache/docs again.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VRid8i4qnuNfE7Lio73Uu4
@asgeirf
asgeirf marked this pull request as ready for review September 15, 2026 06:35
@asgeirf
asgeirf merged commit f0ef52d into main Sep 15, 2026
14 checks passed
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