Repository navigation
feat(run): CK_LOG=debug prints one stderr line per call (LAB-8070) - #17
Merged
Merged
Conversation
A fresh hit and a stored miss printed nothing, so a caller could not tell whether ck served stored output or ran the command. With CK_LOG=debug, every ck run call that reaches an outcome prints one `ck: debug:` line naming it, with the backend, the program name, an entry id, the stored output's age, the exit code and the elapsed time. An env var rather than a flag: ck runs inside $(...) in startup files and scripts, and one export reaches every call site, nested calls included. Not RUST_LOG, which the wrapped command also sees, and not CACHEKIT_*, which is stripped from it. Any other value warns once and is ignored, so a typo never stops the command. The line never carries the command's arguments, its output or either key. The entry id is the first 12 hex characters of the keyed hash that names the entry's lock file, so it cannot be checked against a guessed command without the master key. No new dependency.
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Providing Context (Files & MCPs)Add these hints in your PR description (or a comment) to unlock deeper checks:
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
Kody Code Review — 1 suggested fix. 🛠️ Open Agent Prompt |
Contributor
Author
|
@kody start-review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
CK_LOG=debugmakes everyck runcall that reaches an outcome print one more stderr line saying what it did:The outcomes are
served fresh,served stale,ran and stored,ran, not stored,refreshed and stored,refreshed, not stored,suppressed,ran uncachedandcould not start the command. Any existing warning for the call comes first and is unchanged. WithCK_LOGunset or empty, ck behaves exactly as before.src/lib.rs:debug_enabled()readsCK_LOGonce per call, anddebug()sits besidewarn().src/run.rs: each terminal path returns throughCall::done, which prints the line when enabled.run_uncachedbecame a method so the uncached paths report too. A fresh hit now carries its age out offresh_or_stale.ck --helpand a new README section, "Seeing what ck did".Why
A fresh hit and a stored miss print nothing, so a caller cannot tell whether ck served stored output or ran the command.
It is an env var, not a flag, because ck runs inside
$(...)in shell startup files and scripts: one export reaches every call site, nestedckcalls included. It is notRUST_LOG, because the wrapped command sees every variable exceptCACHEKIT_*and would switch on its own logs. It is notCACHEKIT_LOG, becauseCACHEKIT_*is stripped from the child, so nested calls would go quiet. Any other non-empty value prints one warning and is ignored, so a typo exported from a startup file never stops the command or exits 125.What the line never carries
Only
argv[0]is printed, debug-quoted, so control characters cannot reach the terminal. The arguments, the output and both keys are never printed. The entry id is the first 12 hex characters of the keyed BLAKE2b hash that also names the entry's lock file in~/.cache/ck/locks/. An unkeyed digest of the command line could be checked against guessed arguments; this one cannot without the master key.Verification
New tests.
tests/run.rscovers every file-backend outcome, the line's fields and the entry id matching the lock file, a hit's stdout staying byte-identical with and withoutCK_LOG, and bad or empty values.tests/saas.rscoversran uncachedon a backend fault,ran, not storedpast the 1 MiB cap, and a sentinel test.The sentinel test runs the miss, hit, stale and 401-fault paths with a sentinel in the command's arguments, in its stdout, in
CACHEKIT_API_KEYand inCACHEKIT_MASTER_KEY, and asserts none of them reaches stderr. I broke the guard on purpose by printing the whole argv, and the test failed:Existing tests pass unchanged. The test sandbox and the README runner now drop an inherited
CK_LOG, as they already dropCACHEKIT_*, so a developer with it exported still gets a green suite.cargo fmt --check,cargo clippy --all-targets -D warnings,cargo test --locked(lib 17, run 45, saas 17, readme 1) andcargo +1.85 check --locked --all-targetsall pass. The hit-path bench passes:added 522µs (budget 5ms).[dependencies]is unchanged, and cachekit-rs'stracingfeature stays off.