Hoc test cache

From openreachtech/hora-skills-ort-core · View interactive version

Hoc test cache is an AI agent skill from the GitHub repository openreachtech/hora-skills-ort-core. Reuse a recorded test pass when a verification unit's inputs are unchanged, through the `mentsu-testcase-cache` CLI. Use when wiring cached test execution into a repository, or when reading a cached run's verdict. Driving a failing suite to green belongs to the test-execution convention; recording t

How to use this skill

Skill file

Test Cache

A skill for reusing a recorded pass instead of executing the same inputs twice.

What is skipped is the second execution, never a test. The suite a unit runs is its whole suite, and

the numbers reported are the runner's own.

Core principle: the cache records a pass, it never grants one

a declaration can only add to it. A wrong declaration costs time — it cannot manufacture a

green.

is what makes reuse defensible.

The unit — one directory, one command

A unit is the granularity of the cache, declared in .hora-cache.json at the project root. The file

is committed; the directory it names is not.

{
  "cacheDir": ".hora-cache",
  "units": {
    "backend": {
      "cwd": "myproject-backend",
      "command": "npm test",
      "extras": [".env*"]
    }
  }
}

| field | required | meaning |

| :-- | :-- | :-- |

| cacheDir | no, default .hora-cache | where records are written. Machine-local — add it to .gitignore |

| units.<name>.cwd | yes | the directory the command runs in, relative to the project root |

| units.<name>.command | yes | the unit's own test command, exactly as the repository already runs it |

| units.<name>.extras | no | files git ignores that behavior depends on, such as env files |

npm test and ./test.sh are different units even when one calls the other.

unit and never split per suite.

Declaration examples and the extras patterns are in unit-declaration.md.

Wiring a repository

npm install --save-dev @openreachtech/mentsu-testcase-cache
{
  "scripts": {
    "test": "mentsu-testcase-cache",
    "test:cold": "mentsu-testcase-cache --cold",
    "test:status": "mentsu-testcase-cache --status",
    "test:clear": "mentsu-testcase-cache --clear"
  }
}

in and never searches upward, and every unit's cwd is resolved from there. Started anywhere else

— a sub-package's own script, a shell that wandered — it stops at exit 2 without running anything.

platform it was made on, so another machine's key never matches it anyway.

directory looks like.

Reading a run

| line | meaning |

| :-- | :-- |

| ━━━ unit: <name> — hashing inputs … <n> files, key <key> | the key was computed over that many files |

| ✘ MISS — executing | no record for this key. The command runs, streaming its own output |

| ✔ passed in <t> — recorded as <key> | the execution passed and was recorded |

| ✘ failed in <t> — not recorded | the execution failed. Nothing was recorded |

| ✔ REUSED — pass recorded at <time> | a record matched, and its summary lines are replayed |

| ━━━ cache-audit: … | the spot audit's verdict for this run |

Report the replayed summary lines as the run's numbers. They are the runner's own output from the

execution that produced the record, so they are transcribed and never paraphrased.

Only a Jest-shaped summary is recorded. What a record keeps is the output lines beginning

Test Suites: or Tests:, and nothing else. A runner that prints its counts in another shape

records no summary lines at all, so its REUSED run replays none.

the audit's verdict. It is a statement that the inputs are unchanged, not a count.

unverified claim the whole convention exists to prevent.

output.

--status answers what the next run would do without executing anything: the cache directory, then

one line per unit — <unit>: <n> recorded pass(es), REUSE ready or … stale — would MISS, with the

key it judged that against. Keys are printed shortened, so two keys are compared by their first

characters, never assumed equal because both were abbreviated.

Exit codes are the contract

| code | meaning | what the caller does |

| :-- | :-- | :-- |

| 0 | every unit passed, reuse included | continue |

| 1 | a unit's execution failed | triage it as an ordinary test failure |

| 2 | config error — no config file, or an unknown unit name | fix the setup. This is not a verdict on the tests |

| 3 | audit mismatch | a defect of the measuring instrument. Trust no record |

is about the product.

failed, so exit 3 is never evidence that the other units passed. Read the per-unit summary lines

for that.

The spot audit

When at least one unit was reused, one reused unit is picked at random and executed for real.

match.

discarded and the run exits 3.

which is what the audit was there to obtain.

always shows which runs went unaudited.

On a mismatch:

  1. Treat it as a cache defect, not a product defect. The audited unit's failure is evidence about

the key, not a finding about the code.

  1. Raise it as a blocking question against the key definition, naming the unit, its key, and what the

key could not see.

  1. Execute the remaining units for real before any verdict is recorded.

When a record may not stand in for a run

release verdict rests on measured passes and a wrong reuse cannot outlive the version.

not checked, so a gate run always runs every unit.

node_modules/.package-lock.json under the unit's own cwd; where the installed tree lives at a

workspace root instead, that path is missing and digests the same before and after an install. Run

cold after installing dependencies in such a layout.

globally installed binary, state a previous run left in a database.

What the key covers, and what it cannot, is in key-composition.md.

A failing unit is handed on unchanged

The cache decides nothing about a red run. Exit 1 is where this skill ends and /hoc-test-execution

begins, with its prohibitions intact: reuse of a recorded pass over identical inputs is not one of

the ways a suite is weakened, and it is never a reason to skip, loosen or delete a test.

Prohibited

is a fabricated green.

Rationalization table

| Rationalization | Reality |

| :-- | :-- |

| "It passed five minutes ago, skip it" | Then the key matches and the tool reuses it. Deciding that by hand is what the key replaced |

| "The audit costs a whole extra unit" | The audit is what separates a reused pass from a guess. Its cost is one unit, once |

| "The mismatch is flaky, re-run it" | A mismatch says a recorded pass now fails. Find what the key cannot see |

| "This file cannot affect the tests" | Then including it costs one hash. Leaving it out costs a green nobody measured |

| "The reuse printed no counts, I remember them" | A remembered count is not a measurement. Report the reuse, or run cold |

| "Cache the failures too, it is the same mechanism" | Only a wrong green is dangerous. A wrong red re-runs and corrects itself |

| "Clear the cache and move on" | Clearing hides the mismatch that was the finding. Record it first |

Red flags — stop

Detail files

see, and the rule for a doubtful input.

the granularity rules.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.