Krypton
Architecture

How Krypton is put together

Krypton has a local half that reads your code and a scoring half that only receives its structure. This page covers both, the format between them, and what each side can see.

A local halfReads and parses your code, keeps the names.
A scoring halfReceives only structure, stores nothing.
HTTPS betweenStructure and hashes out, numbers and hints back.

Overview

A file is parsed into a syntax tree on your machine, and only that is scored. Where the scorer needs a name it gets a short fingerprint, and the real name stays in a local book. The scorer returns numbers and hints, and your machine puts the names back.

Components

ComponentWhere it runsWhat it does
Client (krypton)Your machineParses each file (Python, JavaScript, TypeScript, TSX), writes the request, posts it, and keeps the names book.
Wire formatBetween the twoThe request body: flat arrays for the tree, fingerprints for names, line shapes. See Wire format.
Scoring serverHostedValidates the tree, scores it, returns JSON. Stateless: nothing from a request is stored. See API reference.
EngineThe scoring serverCounts decisions and nesting, applies the thresholds, raises flags, writes hints and the purity score. What it measures is in How it works.
Names bookYour machineA map from fingerprint to name, kept on your machine. It is how the answer gets its names back.
OrderYour machineReads git history locally and sends only file names, token counts and which files each commit touched; the server decides whether a different file order would reuse more of a prompt cache. See file ordering.

The path of a file

Your machineReads and parses each file, swaps names for hashes, keeps the table, puts names back in the answer.
Over HTTPSStructure and hashes out; numbers and hints back.
Scoring serverChecks the tree, scores it, builds hints, returns JSON, stores nothing.

Only the middle step crosses the network, over HTTPS.

What each side sees

ItemStays on your machineSent to the scoring server
Source textAlwaysNever
Identifiers and stringsThe real text, and the names bookA 16-character fingerprint where a name is needed
StructureThe full parseType, parent and position of every node
LinesThe lines themselvesEach line's length and where its visible characters are
ImportsThe import textCandidate file paths that exist in the same request
Waiver commentsThe commentWhether the line is a comment by itself, and a fingerprint of the reason
Credentials, repositoryAlwaysNever
The limits. The server still sees file paths, the shape of every tree, line lengths and file sizes. Names are keyed with a fresh secret for every scan, so they cannot be recovered by hashing guesses. Two equal names have equal fingerprints, which is what lets the server compare them without reading them.

The scoring server

How it is checked

Ways to run it

ModeWhere code is readNetworkStatus
Command line (krypton)Your machine; the server gets the structure onlyHTTPS to the serverAvailable
DemoThe repository you connect is read on the demo's server, in memory, then droppedHTTPS to GitHub and the serverLive: it builds the trees itself and uses the same server