Skip to content

Rename the cache-tm input to parse-cache - #9

Merged
asgeirf merged 21 commits into
mainfrom
parse-cache-input
Nov 23, 2026
Merged

asgeirf merged 21 commits into
mainfrom
parse-cache-input

Conversation

@asgeirf

@asgeirf asgeirf commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

This changes checks and narrows what the Windows jobs test. The founder decided that Windows has no listed Bowrain plugin until the next kapi release: registry#6 removed every kapi-bowrain version except 1.3.0 and 1.4.0-rc5, and neither has a Windows build. So setup-kapi@v1 with the default plugins fails on Windows until then. The Latest, Pinned and Cache hit jobs therefore run with plugins: "" on Windows, and each has a step (test/plugins/windows-unlisted.sh) that asserts the default install still fails with "no version of plugin "bowrain" … for platform windows/". That step fails when a Windows build is listed again, which is the reminder to restore the default in those jobs. The plugin-cache seed changes from bowrain 1.0.2, which is no longer listed, to 1.4.0-rc5 from the beta channel. That is a bowrain the newest stable kapi does not pick on a fresh install, so the upgrade test asserts the same thing as before. kapi 1.2.0, the seed kapi, installs it (checked locally).

Renames the cache-tm input to parse-cache and carries kapi's parse cache for both generations of kapi.

What it does now

  • parse-cache (default true) keeps kapi's parse cache between runs for a project with a kapi.yaml.
  • Where the cache is. The action writes KAPI_PARSE_CACHE_DIR=<runner.temp>/kapi-parse-cache to GITHUB_ENV and gives actions/cache two fixed paths: that directory and <project-dir>/.kapi/work/cache/docs.
    • A kapi that reads the variable keeps the parse cache there. A kapi up to 1.3 ignores it and uses the in-tree path, and the unused path is absent.
    • Both path strings are the same on every run, so the cache version stays stable.
    • The action runs no kapi state path, makes no link, and takes no path from a command's output.
    • If the workflow already set KAPI_PARSE_CACHE_DIR, the action keeps it and caches it when it lies under runner.temp with no .. component. Otherwise it warns and carries no cache.
  • Key. The key is unique per run (OS, kapi version, ref, job, run, attempt), with restore keys by ref and then by kapi version. It hashes no source file on purpose: kapi keys each entry by path and content, so a cache from before a source edit still serves every file the edit left alone. One effect of the change: the cached path list changed, so the first run after upgrading starts cold.
  • Cache safety. The README states in one paragraph that the cache key and who can write the cache are the trust boundary. GitHub scopes caches by ref, so the default branch never restores a cache a pull request saved, fork or not. A pull_request_target, workflow_run or issue_comment run restores and never saves.
  • Values written to GITHUB_OUTPUT and GITHUB_ENV.
    • A caller's KAPI_PARSE_CACHE_DIR is refused when it has a control character (a line break included) or names runner.temp itself (also as / or /.), and dir= is written only after the checks.
    • The version must look like a release version.
    • The parse-cache output is only true or false.
    • The auth token and server URL go to GITHUB_ENV with a random delimiter.
  • Cache key. An underscore now ends the version in the key (kapi-parse-<os>-<version>_<ref>-…). Before, the restore prefix for 1.2.0 matched a 1.2.0-rc32 cache, as the run against neokapi main showed.
  • README and input descriptions are in plain sentences, and the README names the variable for other CI systems. Main is merged.

Compatibility for v1 callers

cache-tm still works: when it is set, it is used in place of parse-cache, with a deprecation warning. For kapi 1.3 and earlier the in-tree path is still cached, under the same key.

Verified

  • test/parse-cache/env.sh (in CI) runs the step out of action.yml. It covers the variable unset (exported, output), a caller value under runner.temp or the workspace (kept, not overwritten), and values outside both, relative, with .., or sharing a prefix (warned, skipped). It asserts that both cache steps carry both paths.

  • test-parse-cache-in-tree runs the real kapi 1.3.0 and 1.4.0-rc5. The variable is exported, kapi writes the in-tree cache, and the fixed directory stays absent. The existing save/restore warm-vs-cold jobs on 1.2.0-rc32 cover the round trip.

  • actionlint and shellcheck.

  • Cache cleanup: I deleted the kapi-parse-* caches on refs/pull/9/merge whose keys contain e2e-. I also deleted the 1.4.0-rc5 test-parse-cache-in-tree caches from runs 45242099518 and 45243184972. The temporary #3804 jobs had saved, or caused to be saved, a parse cache under the 1.4.0-rc5 key, and other jobs then restored it. No cache on any other ref was touched.

  • Against a kapi that reads KAPI_PARSE_CACHE_DIR: neokapi main at 24b78f1, with #3804 merged, built in CI. Cold and warm runs went through this action on Linux and macOS in run 45248697071. Each job had its own runner, so the checkout folder and the data root were new each time. The jobs were removed again; the earlier run 45245109823 used #3804 at bd3ab4986.

    • Cold run: kapi created the directory at 0700 and wrote 4 entries and 4 part files there, and none in the checkout or the state directory.
    • Warm run, with the cache restored onto a new runner: the directory came back 0700, owned by the job user.
      • On Linux, strace shows kapi opening the recorded part files for reading 52 times.
      • On both systems the warm run wrote no entry, and its output matched a cold run, both in the same job and from the earlier job.
      • Control: with one byte of a part file changed, kapi parsed that file again.
    • Refusals:
      • A caller-set directory inside the project, and one in the repository outside the project: the action warns and caches nothing, and every kapi command fails with "inside the checkout ; name a directory outside the checkout".
      • A directory widened to 0755: kapi fails with "mode -rwxr-xr-x gives group or other users access".
    • The workflow keeps no job for the variable until a kapi release reads it. That job is added then; until then these runs are the evidence.

🤖 Generated with Claude Code
https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr

asgeirf and others added 21 commits October 2, 2026 10:14
The input caches kapi's parse cache, which has nothing to do with content
memory. cache-tm stays as a deprecated alias: when a workflow sets it, it
decides and the action prints a warning naming parse-cache. One step
resolves the value and both conditions read it.

The input description and the README now describe kapi 1.3: the project's
context lives in kapi's workspace and moves through a context backend with
kapi context pull, which this action leaves to kapi-action's context-sync
input or the workflow's own step. The test workflow covers parse-cache:
false, cache-tm: false, and cache-tm deciding over parse-cache.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWc9qYQJ93y88XrN6TkMvT
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
A kapi that keeps each checkout's state outside the checkout prints that
directory with `kapi state path`. The action keeps the cache in a fixed
directory under runner.temp and links the state directory's work/cache/docs to
it, so actions/cache saves it in its post step. A kapi without the command keeps
the in-tree path. A pull_request_target run restores and never saves.

Verified: test/parse-cache/locate.sh with the stub, against kapi 1.4.0-rc5 (tree) and a build of neokapi#3780 (state); two-run warm/cold comparison with the #3780 build; actionlint; shellcheck

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
The answer must be one line, an absolute path with no control characters,
shaped <data root>/checkouts/<32 hex>, with no symbolic link among its
components. Anything else carries no cache, prints a warning, and leaves the
file system untouched.

Verified: test/parse-cache/locate.sh (good, empty, two lines, relative, outside the data root, not a checkout, control character, through a link) and against kapi 1.4.0-rc5 and a neokapi#3780 build; shellcheck

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
…egistry#6

The action sets KAPI_PARSE_CACHE_DIR to a fixed directory under runner.temp
(or keeps a caller's value under runner.temp or the workspace) and caches that
directory and the in-tree .kapi/work/cache/docs. It no longer runs kapi state
path, makes no link and takes no path from a command's output.

Tests: the Windows jobs install no plugin and assert that bowrain has no
Windows build (registry#6); the plugin seed is bowrain 1.4.0-rc5 from beta,
since 1.0.2 is no longer listed.

Verified: test/parse-cache/env.sh; kapi 1.2.0 installs bowrain@1.4.0-rc5 from beta; actionlint; shellcheck

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
kapi refuses a parse cache directory inside the checkout, a link, or one wider
than 0700, and creates it at 0700 itself, so the action creates no directory
and the README tells other CI systems to let kapi create it.

Verified: test/parse-cache/env.sh; actionlint

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: none (a measurement job, removed before merge)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: none (a measurement job, removed before merge)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: none (removes a measurement job; results in run 45239899921)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
…3804

Verified: none (a measurement job, removed before merge)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: none (a measurement job, removed before merge)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: none (a measurement job, removed before merge)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: none (a measurement job, removed before merge)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: none (a measurement job, removed before merge)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: none (a measurement job, removed before merge)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
…README

Verified: cold and warm runs against the neokapi#3804 build through this action on Linux and macOS (run 45245109823); actionlint

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: none (README only; actions/cache@v5 runs its save step under post-if: success())

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
…en other output writes

- A caller's KAPI_PARSE_CACHE_DIR with a control character, or naming
  runner.temp itself, is not cached; dir= is written only after the checks.
- The version must look like a release version; parse-cache's output is true
  or false; the auth values go to GITHUB_ENV with a random delimiter.
- workflow_run and issue_comment runs restore the parse cache and never save.
- README: repository wording, scoped test claim, gh cache commands for the
  kapi-parse- prefix only, kapi up example without a pin, no em dash.

Verified: test/parse-cache/env.sh (newline, CR, runner.temp itself and with / and /., nested, auth token with a line break); the resolve step on a version with a line break; actionlint; shellcheck

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: none (a measurement job, removed before merge)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
The restore prefix kapi-parse-<os>-1.4.0- matched caches saved by 1.4.0-rc5,
as the run against neokapi main showed (1.2.0 restored a 1.2.0-rc32 cache). An
underscore now ends the version, which the version check does not allow inside
one.

Verified: cold and warm runs against neokapi main 24b78f1 (with #3804) through this action on Linux and macOS, run 45248697071; test/parse-cache/env.sh; actionlint

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
…through a real run

- 'False' and 'FALSE' turn the cache off for parse-cache and cache-tm, as
  v1's expression comparison did.
- Each line of auth-token is masked before it is written to GITHUB_ENV.
- A job passes a two-line dummy token through the action on Linux, macOS and
  Windows and reads both variables back.

Verified: test/parse-cache/env.sh (False/FALSE/false for both inputs, the mask commands); actionlint; shellcheck

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
@asgeirf
asgeirf merged commit 05d88c8 into main Nov 23, 2026
29 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