> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metaphi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# CodeVal

> A private assessment of your codebase for data licensing, run on your own machine.

CodeVal helps you get a private assessment of the value of your codebase for data licensing. CodeVal is local only, and your codebase is never sent outside your environment during the diligence stage.

## Requirements

| Requirement | |
| - | - |
| Repository | Go, Python, JavaScript and TypeScript (Node.js), Java (Maven or Gradle), C# (.NET) or Rust (Cargo), with a build and tests that run on Linux |
| Clone | A full clone with its whole history, or the repository's git URL |
| Operating system | macOS or Linux, x86\_64 or arm64 |
| git | 2.32 or newer |
| Container runtime | Docker or Podman, recommended. Builds and tests run in containers when one is running, and on this machine otherwise |
| Time | From minutes to several hours per repository. Each repository stops at a time limit Metaphi AI sets |

## Installation

```sh Shell theme={"dark"}
curl -fsSL https://github.com/metaphi-labs/kennet-cli/releases/latest/download/install.sh | sh
```

```sh Homebrew theme={"dark"}
brew install metaphi-labs/tap/kennet
```

```sh pip theme={"dark"}
pip install kennet   # Python 3.10 or newer
```

The install script checks that the release is signed by Metaphi AI's release key before it installs. `kennet --version` prints the version.

## Usage

Name each repository as a path to a clone or as a git URL. With none, it uses the current directory.

```sh theme={"dark"}
kennet codeval ./core ./billing https://github.com/acme/ledger.git
```

The command:

1. Prints what it sends and a sign-in link with a code, and opens the link in your browser. Approve the code there. This is your only step. Nothing is built or sent before you approve, and a denied or expired code sends nothing.
2. Reads each repository's history and sends the profile.
3. Builds and tests the latest commit, then the past commits Metaphi AI names. It also swaps single operators at the latest commit, such as `<` for `<=`, and runs the tests over each swap. Each progress line shows about how long is left.
4. Sends the results and prints a reference, `cv_...`. Keep it: it identifies your submission.

A run can then be left unattended.

Results are sent for the organization you choose when you approve. To send on behalf of your company, create its organization first with `kennet org create "Acme"`.

## Data security

Builds and tests run in temporary copies on your machine. CodeVal sends typed measurements of your repositories: every value is a number, a yes or no, a choice from a fixed list, an id or a key. No field takes free text.

Metaphi AI checks the tip and root commit ids and the git blob ids it receives against Software Heritage's public archive, to see whether the code is already public.

### Data collected

Counts and ids for files, commits and authors; the shape of commit history; build and test results as typed outcomes. No source code, logs, file paths, author names or commit text. Public dependency names and standard build-file names are included.

Files, folders, authors and commits are numbered within the submission. A key is a 16-character HMAC under a key kept on your machine: equal inputs give equal keys within one repository, and the input cannot be read back from it.

**Repository**, sent once

| Field | What it is |
| - | - |
| Key id | 16 hex characters: an HMAC of a fixed label under this repository's key, so submissions from one repository match. The key stays on your machine |
| Latest and root commits | Their git ids |
| Branches, submodules, Git LFS, pack size | Counts, and whether LFS is used |
| Tags | For each: the commit, whether annotated, whether the name reads as a version, and for an annotated tag its time and zone as git stores them. Never the name |
| Licences | Each licence found, from a fixed list (MIT, Apache-2.0, GPL and the like) |
| CI | Each CI provider used, from a fixed list; counts of CI files and services |
| Containers | Counts of Dockerfiles, Compose files, Compose services and other images; whether there is a dev container; service images from a fixed list of official ones (`postgres`, `redis` and the like). Any other image is counted, never named |
| Agent files | Whether each of `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, Copilot instructions, Cursor rules, Windsurf rules, Aider config and an MCP config is present |
| Dependencies | Each dependency the lockfiles resolve from a public registry, by ecosystem and public package name. Any other dependency is counted, never named |
| Authors | For each: a number, a number for the email domain, and whether it is a bot. Never the name, email or domain |
| Folders | For each: a number and its parent's number |

**Commits**, for each

| Field | What it is |
| - | - |
| Numbers | The commit's number and its parents' numbers, in git's order |
| Author, committer | Their numbers |
| Times | Author and committer times as git stores them: Unix seconds, the zone in minutes from UTC, and whether the zone is git's `-0000` |
| Signature | Whether it is signed. Never the signature |
| Message shape | Characters and lines in the message, characters in the subject, lines in the body; ticket references; words that match a changed file's path, as a count; whether it has a type prefix (`fix:`), is a pull request merge, says fix, or is a revert, and which commit it reverts |
| Subject key | A key of the normalized subject line, so repeated templated subjects show as equal |
| Trailers | Each trailer's kind from a fixed list (`Signed-off-by`, `Co-authored-by` and the like), and whether its email domain belongs to a coding assistant vendor from a fixed list |
| Test overlap | How many identifiers the added test and source lines share |
| Changed files | For each: the file number, the change type (added, modified, renamed and the like), the old file number on a rename, lines added and removed, and each hunk's header numbers (old start, old lines, new start, new lines). Never the lines |

**Files**, for each

| Field | What it is |
| - | - |
| Numbers | The file's number, its folder's number and its depth |
| Type | The extension, from a fixed list; the kind (source, test, vendored, generated, doc, config, data, other); whether it is a build or project file from a fixed list (`package.json`, `go.mod`, `Dockerfile` and the like); whether it is a CI definition |
| At the latest commit | Whether it is there, and a key of its contents |
| Size | Bytes, lines, blank lines, comment lines and tokens; whether it is binary or has a generated-code header |
| Shape | Total and largest indentation, the longest line |
| References | Counts of internal and external imports, test functions, environment variable references, URLs and mocks |
| Operators | In a source file, counts of comparison, logic, arithmetic and boolean operators |
| Licence | In a licence file, the licence from the fixed list |
| Git blob id | Only for the files Metaphi AI names, at most 64: the file's git blob id. Never its contents |

**Results**, for each batch of up to 5 commits and 5 operator swaps

| Field | What it is |
| - | - |
| Key id | The same key id as the repository's |
| Batch | Its number, its time taken, and `rules`: the SHA-256 of the rule pack, shipped with the CLI, that classified each step |
| Machine | Operating system, architecture, CPUs, memory, whether runs used Docker, Podman or this machine, and the container image digest |
| Toolchains | Each toolchain used, from a fixed list, with its version number |
| Commands | Where the build and test commands came from (CI, build files, or the command you gave), and a key of each. Never the commands |
| Services | Whether they came from CI or Compose, how many, whether they came up, their time taken, and which settings were refused |
| Latest commit | Or only the class that stopped it, when it could not be built or tested. Otherwise: the build; up to 3 test runs; the tests again with the network off; bytes the build installed; peak memory; coverage per file, by statement or line, where the language reports it |
| Past commits | For each commit named: its parent with the commit's tests laid over it, built and tested once; then the commit, built and tested up to 3 times. Or the class that stopped it |
| Operator swaps | For each swap named: the file number, the operator class and position, and the tests over the swap. Or the class that stopped it |

**Steps**, for each build and test run in the results

| Field | What it is |
| - | - |
| Step | The last step reached: `setup`, `dep_resolve`, `compile`, `test_compile`, `test`, `lint` or `package` |
| Class | How it ended, from a fixed list: `ok`; a dependency, build configuration, compile, link or test failure; a test timeout; a quality gate; a flaky test; the environment (network, resources, timeout, missing toolchain, permission); cancelled; unknown |
| Codes | Up to 16 diagnostic codes, each from a fixed list of 53: Rust (`E0308` and the like), TypeScript (`TS2322`), C# (`CS0246`) and C compiler warnings (`-Wreturn-type`). Any other is sent as `other`. For a compile or link failure, its kind: missing symbol, type mismatch, syntax, semantic or other |
| Exit code | The exit code |
| Time taken | A bucket, never the exact time: under 100 ms, then buckets each 10% wider than the last, up to a week |
| Log fingerprint (SHA-256; the log stays on your machine) | The SHA-256 of the log. The log stays on your machine |
| Tests | In a test run: tests counted and passed, whether counted from JUnit XML or the runner's summary, and each test's outcome (passed, failed, error, skipped) under a key. Never the test's name |

Metaphi AI's server refuses any field not listed here.

**What Metaphi AI asks for**, in each batch

| Field | Limit |
| - | - |
| Batches | Up to 6 per repository |
| Latest commit | Whether to build and test it |
| Commits | Up to 5, by number |
| Operator swaps | Up to 5 |
| Git blob ids | Up to 64 files, by number |
| Test runs | 1 to 3 per commit |
| Time | Up to 240 minutes per run, and up to 24 hours left for the repository |

### Safeguards

| Safeguard | |
| - | - |
| Approval | Nothing is read, built or sent until you approve the sign-in code in your browser |
| Closed schema | Every field is typed. A value that is not a number, a yes or no, a choice from a fixed list, an id or a key is refused |
| Environment | Builds and tests run with a fixed set of environment variables (`PATH`, `HOME`, locale and the like), never your keys or cloud credentials |
| Container isolation | All but a few file-ownership capabilities dropped, no new privileges, process, CPU and memory limits, and a network of their own. A Docker Compose service asking for privileged mode, the host's network or process namespace, added capabilities, devices, or a bind mount outside the repository is not started |
| Audit trail | Every body sent is kept, exactly as sent, one folder per repository: `~/.local/state/kennet/codeval/<fingerprint>/sent/`, or under `$XDG_STATE_HOME` or `$KENNET_STATE_HOME` when set, where `<fingerprint>` is the first 32 hex characters of the SHA-256 of the repository's root commits. The last line of a run names it |
| Signed releases | The install script checks that the release is signed by Metaphi AI's release key |
| Open source | The CLI is open source: [metaphi-labs/kennet-cli](https://github.com/metaphi-labs/kennet-cli) |
| Encryption in transit | Results are sent over TLS to `api.metaphi.ai` |
| Storage | Each submission is stored under its reference, your organization and the id of the key that sent it, written once and never modified. Only your organization's keys can read its status |

## Options

```sh theme={"dark"}
kennet codeval [<path-or-url> ...] [--json] [--no-browser] [-- '<command>']
```

| Option | What it does |
| - | - |
| `-- '<command>'` | The command that builds and tests, as one shell line, when it cannot find one |
| `--no-browser` | At sign-in, prints the link and code and opens nothing |
| `--json` | Prints one JSON object on stdout; progress goes to stderr. Sign-in stops at once with exit 3 |

It finds how a repository builds and tests from its CI configuration, container files and build files. If your repository builds and tests with a command of its own, give it after `--`, and run that repository on its own:

```sh theme={"dark"}
kennet codeval ./core -- 'make test'
```

Test commands see `KENNET_TESTS`, `KENNET_JUNIT` (a directory for JUnit XML) and `KENNET_JOBS` (how many jobs to run at once).

## Errors

If a run stops, run the same command again. It goes on from the last finished unit and runs nothing twice.

| Exit | Meaning |
| - | - |
| 0 | Sent |
| 1 | Failed. The message says why |
| 2 | The command line was wrong |
| 3 | A sign-in is needed, or the code was denied or expired. Nothing was sent |
| 4 | Not finished yet. Run the same command again later |
| 5 | `kennet` is too old. The message gives the upgrade command |
| 6 | A person must act. Causes: a toolchain missing (install it, or give the command after `--`); an environment failure at the tip (network, memory, time or permissions); `key_mismatch` or `profile_gone`, where running again restarts the measurement of this repository and replaces earlier results |

With `--json`, a failure prints `{"error": {"code", "message", "next_step"}}`. `next_step` is the command that clears it, or null.

| `code` | What to do |
| - | - |
| `sign_in_required` | Open the sign-in link, approve the code, then run `next_step` |
| `toolchain_missing` | Install the toolchain the message names, then run the same command |
| `test_command_missing` | Give the command that builds and tests after `--` |
| `no_repository` | No full git clone at a path given. Each path's reason is in the output |
| `upgrade_required` | Run `next_step`, then the same command |

## Decision

Metaphi AI reviews the results and gets back to you with a decision. If they are accepted, Metaphi AI emails you an offer, and terms are put in place under a mutual NDA:

```sh theme={"dark"}
kennet mnda                 # whether your organization has one: signed, pending or none
kennet mnda sign            # create one and open it to sign in the browser
```

Questions: [agent@metaphi.ai](mailto:agent@metaphi.ai).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.