Skip to content
codedaptivePublic

About

Code Chi Jin (ccjin): runs a repository's tests and builds and keeps a receipt of each run in the repository. MIT.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Code Chi Jin: never re-run a test that already passed. Proof of every run, saved in your repo.

Code Chi Jin

Never re-run a test that already passed on the same code

Portable test evidence for agent teams

AI coding agents are trained to build with tests, and they love them, maybe more than the product code itself. That habit has a cost nobody planned for.

One agent writes code, runs the tests, sees them pass and hands the work on. The next agent loves tests too. It doesn't take the first agent's word that they passed, so it runs the same tests again to be sure. So does the reviewer after it, and so does the step that merges the work. Each run is reasonable on its own. Together they make a downward spiral: more and more of the day goes to re-running tests that already passed on code that hasn't changed, and less and less goes to writing code.

Code Chi Jin (ccjin) stops the spiral, for any coding agent you use. When a test suite passes, Jin writes a receipt into the repository: what ran, on exactly which code, with which tools, and the result. The next agent that asks gets the answer from the receipt in an instant, with no second run. It doesn't have to trust the first agent, because the receipt is proof anyone can check. Jin runs a test again only when something that could change the answer has changed: the code it covers, the test itself, the tools or the platform.

release platforms license

What it is

Jin is a command-line tool, ccjin, for a repository that coding agents, people or both work in. The repository says what its checks are in a file, jin.toml: each check is a command, the code it covers and a level such as unit or integration. Jin runs them and keeps the receipts in the repository, under validation/jin/.

It works with the tools you have now. A check is the test command you already run: cargo test, pytest, swift test, go test, vitest, or any other command. The repository stays plain git, a receipt is a plain JSON file, and nothing else has to be installed.

Jin never edits code, and it never decides what a result blocks. That stays with whoever asked.

What it takes off your hands

  • Tests that run again on code that has not changed. Jin answers from the receipt. A check runs only when the code it covers, its own definition, the tools or the platform have changed.
  • "The tests pass", with nothing to show for it. A receipt names the command, the exact code, the tool versions, the platform, the counts and each failing test. ccjin show prints it, and ccjin reproduce runs it again at its commit in a clean checkout and compares.
  • A whole suite run for a one-file change. Each check says what code it covers, so ccjin run <path> runs only the checks that cover that path, and a change outside a check's cover leaves its receipt standing.
  • A run that never finished, counted as a pass. A missing tool, a hung run and a run that found no tests each get their own verdict and exit code. None of them is ever "proven".
  • A flaky test that sends the work back. A failing test is run once more, alone. If it passes, the check is proven and the receipt records the test as flaky, so the flake is on the record and nobody loops on it.
  • Proof that stays on one machine. Receipts are committed with the change they prove. ccjin proven <commit> answers in any clone from the commit alone, with no checkout and no run, so a merge step asks once.
  • Secrets and machine names in shared files. A receipt is scrubbed before it is written: no path outside the repository, no host name, nothing that looks like a token or a key.
  • Pages of test output to read. The answer is a few lines with the next step as the last one. --json gives a script the same facts.

By hand, and with ccjin

You want to By hand With ccjin
Run the tests cargo test, pytest, ... ccjin run
Know whether they passed on this exact code Run them again ccjin status
Run only what a change touches Work out which suites it touches ccjin run <path>
Run only the tests that failed Copy their names into a filter ccjin run <check> --failed
See why a check failed Scroll back through the output ccjin show <check>
Check a commit before merging it Check it out and run everything, or find the CI log ccjin proven <commit>
Check a result someone else reports Take their word ccjin reproduce <receipt>

Install

You need macOS, Linux or Windows, git, a current stable Rust toolchain to build, and the test tools your checks name (cargo, swift, pytest, go, vitest, ...).

git clone https://github.com/codedaptive/jin
cd jin
cargo build --release -p cli
./target/release/ccjin install

ccjin install places ccjin in ~/.local/bin and offers a skill file for coding agents (Claude Code, Codex, Cursor); ccjin uninstall removes exactly what install placed and never touches a receipt.

Quick start

This is a small Rust library, invoice, with three tests, in a git repository. Every line of output below is what ccjin printed.

1. Say what the checks are. ccjin init proposes a check file from the build files:

$ ccjin init
wrote jin.toml (cargo workspace): invoice-unit
made validation/jin/
added validation/jin/** -diff to .gitattributes
next: git add jin.toml validation/jin .gitattributes, then: ccjin checks

The file it wrote holds one check: the command, the code it covers and its level.

[[check]]
id     = "invoice-unit"
run    = "cargo test --manifest-path Cargo.toml --lib"
covers = "package"
level  = "unit"

ccjin checks reads every jin.toml that git tracks and says whether each reads clean:

$ git add jin.toml validation/jin .gitattributes
$ ccjin checks
invoice-unit  test  runner cargo; covers its package
next: every check file reads clean; to prove the checks: ccjin run

2. Run, then ask again. The first ccjin run runs the tests and writes a receipt. The second finds that nothing the check covers has changed, and answers from the receipt without running anything.

ccjin run runs three tests and writes a receipt; a second ccjin run answers from the receipt and does not run again

3. Commit the receipt, and ask about the commit. The receipt is a file under validation/jin/, committed with the change it proves. After that, ccjin proven <commit> answers in any clone from the commit alone, and ccjin show prints what the receipt holds: the command, the exact code, the tools and the counts.

ccjin proven HEAD answers proven from the commit's receipt; ccjin show prints the receipt's verdict, code hash, command, platform, tools and test counts

4. Change the code. After an edit to src/lib.rs, ccjin status names the file that changed and the receipt that no longer answers. The run then names the failing test by file and line, and its last line is the next step.

ccjin status says src/lib.rs changed since the receipt; ccjin run reports one failed test at src/lib.rs:23 and the command to rerun it

With the code fixed, --failed runs only the test that failed:

$ ccjin run invoice-unit --failed
invoice-unit  test  proven  1 test  ran 5 s

1 check: 1 proven
next: those tests pass; now the whole check: ccjin run invoice-unit

Adopting ccjin below has a check file for a Rust workspace, a Swift package and a Python repository.

Commands

Verb What it gives
ccjin run [<check or path>...] Each selected check proven, failed or not: answered from a receipt where one holds, run where none does
ccjin run -- <command> One command run as a check, with no check file
ccjin status [<check or path>...] What is proven on the code as it stands, and what changed for the rest. Runs no check
ccjin proven <commit> Whether a commit is proven, check by check, read from the commit's own receipts. Runs no check
ccjin show <receipt or check> One receipt: verdict, code, command, platform, tools, each failing test
ccjin reproduce <receipt> Runs the receipt's check again at its commit in a clean checkout and compares
ccjin checks Reads and checks every jin.toml: each check and what it covers
ccjin init Proposes a jin.toml from the build files, makes validation/jin/, adds its line to .gitattributes

Output is plain text whose last line is the next step; --json gives the same facts as one object (crates/cli/JSON.md). Every verb is safe to repeat. ccjin help is the full reference.

Runners read the output of cargo test, swift test, pytest, go test, vitest and JUnit XML; any other command is a kind = "command" check, judged by its exit code.

Exit codes

The first that applies wins.

Code Meaning
2 Usage error, a problem in a check file, no check matches, not a git repository, a commit that does not resolve
1 At least one check failed
5 A run hung or broke, or a check is disputed
3 A check's runner or tool is not available
4 A check ran no test
6 A check is unproven: no receipt answers, or a --failed run passed, which does not prove the whole check
0 Every selected check is proven

Receipts and the store

validation/jin/<check>/<id>.json is one receipt, tracked by git. A receipt's id is a hash of its own text, so two branches never write different text to the same path and receipts merge without conflict. The directory is all another machine needs: ccjin proven <commit> gives the same answer in every clone.

A receipt is never changed. A new run is a new receipt, and a run that is killed leaves no half receipt.

.jin/ at the top of the working folder is the local store: an index of the directory, the logs and each run's full test list. It ignores itself in git. Delete it and no answer changes.

Adopting ccjin

ccjin help lists every verb, option and exit code. This is the short way in.

1. Draft. ccjin init at the top of the repository proposes a jin.toml from a top Cargo.toml (a unit and an integration check per package) and from pytest configuration (one pytest check), makes validation/jin/ and adds validation/jin/** -diff to .gitattributes. It never overwrites a jin.toml. Commit all three. One top jin.toml works: ccjin run <path> and ccjin status <path> select the checks declared at or under the path and the checks whose cover takes in a file at or under it. A check with no covers is selected by a path only when it is declared at or under that path, so a narrow run never starts a whole suite. A jin.toml beside the code it tests is the tidier shape for a large repository.

2. One [[check]] per command and level. id is unique across the repository. run is a command run from the file's folder with no shell (write sh -c '...' where one is needed). level is a label, and a receipt of one level never answers for another. Teams use:

Level What it runs
unit The tests of one file or function: fast, nothing real outside the code
zone The tests of one zone's parts working together
integration The tests across zones
validation A measure against its threshold, and the full drive of the product

3. Say what each check covers. covers is the code its receipt stands for: a list of paths and globs from the file's folder (* and ?; ** is refused, since a glob already reaches every depth), or "package" for a Cargo package. also names what the run reads outside covers, such as fixtures and test scripts. Each runner adds its own pin files to every cover by itself: Cargo.lock and rust-toolchain.toml for cargo; Package.resolved and .swift-version for swift; requirements.txt, poetry.lock, uv.lock, Pipfile.lock and .python-version for pytest. With no covers, a check covers the whole repository and runs again after any change.

A Rust workspace: one jin.toml beside each crate's Cargo.toml. covers = "package" is the package, the packages it depends on by path, and the files at the top of the repository other than .md files and its jin.toml.

# crates/store/jin.toml
[[check]]
id     = "store-unit"
run    = "cargo test --manifest-path Cargo.toml --lib"
covers = "package"
level  = "unit"

[[check]]
id     = "store-zone"
run    = "cargo test --manifest-path Cargo.toml --test zone"
covers = "package"
level  = "zone"

A Swift package tree: "package" reads only Cargo, so a Swift package names its paths. One jin.toml beside each Package.swift:

# apps/Viewer/jin.toml
[[check]]
id     = "viewer-unit"
run    = "swift test --filter ViewerTests"
covers = ["Package.swift", "Sources/", "Tests/ViewerTests/"]
level  = "unit"

A local package dependency (.package(path: "../Core")) is outside the folder: name it in covers ("../Core/") so a change there runs the check again.

A Python repository: one jin.toml per package folder, or one at the top when the repository is one package.

# search/jin.toml
[[check]]
id     = "search-unit"
run    = "pytest tests/unit"
covers = ["src/", "tests/unit/"]
also   = ["tests/conftest.py", "fixtures/"]
level  = "unit"

Behind a Python launcher (poetry run pytest, or pipenv, pdm, hatch, rye), add runner = "pytest": ccjin does not work the runner out through one, and ccjin checks says so. With the runner named, the run is read as a plain pytest run is: every test by name, and a failed test rerun alone. For JavaScript the runner is worked out behind npx, pnpm, yarn and bunx; behind bun x, add runner = "vitest".

A mixed repository: each language's folder gets its own jin.toml as above. A test that crosses them is an integration check in the top jin.toml, covering every folder it exercises. A command whose output no runner reads (a shell script, a make target) is kind = "command": its exit code is the verdict, and its report says no test count was read.

4. Check the file before it lands. ccjin checks reads every tracked jin.toml and prints each problem as file:line:col what fix; exit 0 means every file reads clean. Then ccjin run --level unit proves the first receipts, and ccjin status shows what is proven on the code as it stands. Commit the receipts under validation/jin/ with the change they prove.

How it fits Code Chi

Code Chi is a family of tools for teams of coding agents. Each is useful alone; Jin needs none of the others.

Tool What it does
Code Chi Dan (ccdan) Turns a git repository into a working team of coding agents and moves each change from a written task to tested code
Code Chi Ting (ccting) Reads a repository's source into an index and answers questions about the code from it
Code Chi Tao (cctao) Checks code against the rules a repository has chosen
Code Chi Jin (ccjin) Runs a repository's tests and builds and keeps a receipt of each run. This repository
Code Chi Wuji (ccwuji) Writes git history for a team of agents; the repository stays plain git
Code Chi Xiu (ccxiu) Changes source code by name: edits, renames, moves and deletes across files
ccvcslib The Rust library through which every Code Chi tool asks version control its questions. Jin builds against it

Tao checks code without running it; Jin runs it. Receipts are plain files in the repository, so whatever saves and lands the work carries its proof along.

What is in this repository

Folder What
crates/procio/ The one place that runs another program: limited environment, scratch home, time limit, kill
crates/checks/ The check file jin.toml: reading it, checking it, what each check covers
crates/receipts/ The receipt: hashes, the store, scrubbing, the answer from a receipt
crates/runners/ One runner per test tool: run it, keep what it printed, give the verdict
crates/cli/ The binary ccjin: verbs, output, exit codes; JSON.md is the --json reference
validation/jin/ The folder for this repository's own receipts
rules/, tao.toml The rules cctao check holds this code to
scripts/, Makefile The test and acceptance targets

Tests

make check
make test GROUP=unit
make test GROUP=integration
make accept

Security

See SECURITY.md for what ccjin does on your machine and how to report a vulnerability privately.

Contributing

Issues and pull requests are welcome; see CONTRIBUTING.md. Changes are listed in CHANGELOG.md.

License

MIT; see LICENSE. Third-party notices are in NOTICE.

About

Code Chi Jin (ccjin): runs a repository's tests and builds and keeps a receipt of each run in the repository. MIT.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages