Cognitive Fab › Expertise › polyx
Expertise · released

Your agents’ history already holds your operating rules

polyx reads the record your agents and teams already produce, finds the rules that record supports, has a person approve each one, and serves them back to the agent the moment before it acts. Where no approved rule applies, it says so instead of guessing.

@cognitive-fab/polyx 0.1.1 Node ≥ 22.18 no model call in mining Claude Code hook Jev observation port
01 / What it tells you

What your agents do, set against what your policy says.

Every AI transformation starts by writing rules down. polyx measures how far practice and policy have drifted apart, and names each rule on either side.

The three-region report Two overlapping circles. Left: what your agents do. Right: what your policy says. Left only: followed, never written. Overlap: confirmed. Right only: written, not followed. WHAT YOUR AGENTS DO WHAT YOUR POLICY SAYS Followed, never written tribal knowledge Confirmed written and followed Written, not followed violated, or never exercised

Fig. 1 — polyx diff: the conformance report. Every finding links to the interactions behind it, and contradictions inside the mined set are listed separately.

Followed, never written

The knowledge that walks out the door

Rules your best people and agents keep that no document states. This is the part a written policy cannot give an agent, and the part a transformation most often loses.

Written, not followed

The compliance gap, with the evidence

Split into violated (it came up and was skipped) and never exercised (it never came up). The two are never merged, because only the first is a problem.

Confirmed

Policy that holds in practice

Each confirmed rule carries its support as a count, such as held 13 of 14, and the case that broke it.

02 / How it works

Mined, approved, served. Then logged for the next pass.

Five steps, one loop. No step asks a language model for a rule.

Scroll sideways to see the whole figure →
The polyx loop Record, typed events, miner, a person, advisor. The agent asks the advisor before acting; every decision is logged and becomes the next corpus. Jev optionally adds facts from what was said. 1 · RECORD2 · TYPE3 · MINE4 · APPROVE5 · SERVE RecordTyped eventsMiner A personAdvisorAgent, about to act Jev · optional actions and outcomesa reviewed alphabetno model call, ever marks each rule realanswers, or abstains Claude Code, or any SDK facts from what was said asks answers every decision is logged and becomes the corpus for the next pass

Fig. 2 — The polyx loop. The miner and the advisor are deterministic. The only judgement is a person’s, at step 4.

Reproducible

Same corpus, alphabet and thresholds give the same rule set. Every run writes a manifest, and every printed figure expands to its source records.

Evidence attached

Each rule shows its support, the cases that satisfy it and the cases that contradict it, in the reviewer’s own vocabulary.

A person decides

Nothing is served until someone marks it real. Verdicts survive re-mining; a rejected rule returns only if its evidence changes materially.

Abstains honestly

A missing fact is unknown, never false. The advisor says whether no rule applies or a rule applies but lacks a fact, and names the fact.

03 / Claude Code

Two ways in, and neither changes the agent.

Claude Code already records every session in ~/.claude/projects and already exposes a hook before each tool call. polyx uses both.

Look back
Session transcripts~/.claude/projects, read in place
→
polyx-lensfree, Apache-2.0, nothing leaves the machine
→
Which rules were keptand which were broken, with the count
Look ahead
Claude, about to run a toolBash, Edit, Write …
→
PreToolUse hookabout sixty lines; asks the polyx advisor
→
warn: the tool does not runand the model is told why, in the rule’s own words
otherwise: it runsrecommendations go to the model as context
# git push, in a session with no commit yet in this episode polyx: Before you push to the remote, commit — every time, in the same episode. (held 33/35, own@operator; action:git_commit has not happened yet in this episode)

What the model saw in one of our own sessions, from a rule mined on that project’s history and approved by a person. It can commit and push, or push anyway if the user asks. A habit nobody had written down is now a number, shown at the moment it matters.

FrameworkWhere polyx plugs in
Claude CodePreToolUse hook, shipped
Claude Agent SDKhooks.PreToolUse, same script, in-process
LangGraphwrap the tool node, or interrupt_before
OpenAI Agents SDKa tool guardrail
Vercel AI SDKtool middleware

Same verdicts everywhere. The work that differs per framework is typing its trajectory; for Claude Code that alphabet ships.

The hook fails open: if the advisor is unreachable, the tool runs and the hook says so once. POLYX_HOOK_STRICT=1 makes it fail closed.

The rules polyx found in our own Claude Code history

We run polyx on our own work: 198 Claude Code sessions across 46 projects. It proposed about four thousand candidates, and most were coincidences. These twelve were approved, each only in the projects whose own history keeps it. Each figure is how often the rule held across those projects.

Before the agent…RuleProjectsHeld
pushescommits first, in the same episode9529 of 552
pusheshas asked you something earlier in the session5321 of 354
pusheshas looked at the repository state3152 of 156
pushespushes at most once per episode4294 of 316
deletes fileshas asked you something earlier in the session9191 of 225
deletes fileshas looked at the repository state7257 of 297
discards changeslooks at the repository state, in the same episode333 of 35
stages changeshas run the tests8694 of 758
commitsstages first, in the same episode171,269 of 1,302
edits a filehas read or written that same file253,582 of 4,158
edits a filereads a file first, in the same episode3188 of 198
edits a .js filereads a file first, in the same episode326 of 26

Twelve rules become 96 project-level rules in service. Each was already how the work was done; now it is counted, and checked before the action. A rule that held 86% of the time is a practice, not a law, which is why a person decides which ones are served.

04 / Jev by TypeSafe

Facts the typed record cannot see, from a System One model.

Much of what decides the next action is said, not recorded. Jev, TypeSafe’s System One model, answers a declared yes/no question about a text with a calibrated probability in about 200 ms. polyx uses it only to add facts. Jev never decides a verdict.

What was said“My account was charged twice for the same order.”
→
Redacted on your machineidentifiers removed first; a dry run shows every payload
→
Jev“Does this message state the customer was charged twice?”
→
probability high: a factobs.states_double_charge = true
otherwise: nothingunknown, never “false”

Fig. 3 — An observation port. Silence in the text is not evidence that something did not happen, so a predicate can assert a fact but cannot deny one.

Rules on what the customer said

In the shipped walkthrough, ten complaints are identical in every typed field. With Jev, polyx recovers the rule that separates them: when the customer states a double charge, escalate, at 5 of 5.

It can only resolve, never retract

Observed facts are added first and only add keys. Switching Jev on can turn an abstention into an answer or surface a hidden warning. It cannot withdraw a warning or create an abstention. A property test checks this.

Recorded once, replayed forever

A Jev answer can vary slightly between calls, so answers are recorded in one pass and digest-pinned. Mining reads the recording, and anyone with the file reproduces every figure without a key.

The real cost of a predicate is about sixty labelled examples, which is one person’s afternoon. At TypeSafe’s published pricing, annotating a hundred thousand events costs about two dollars. A predicate is not a security control: one that reads a poisoned text reports what the poison says.

05 / Where it applies

Any work recorded as typed actions with a consequence.

polyx needs three things from a domain: actions typed against a reviewed alphabet, each declared none, reversible, compensable or irreversible; a way to split the record into episodes; and an outcome per episode. Rules are mined only around actions that cost something to undo.

Customer service

Refunds, credits, escalations

Evaluated on ABCD and τ²-bench retail: conversations where the consequential actions are already buttons in a CRM.

Lending & regulated ops

Origination and approval flows

Runs unchanged on BPIC 2017: 31,509 loan applications through a bank’s own process, with no dialogue and no conversational agent.

Software delivery

Coding agents

Claude Code transcripts: pushes, deletes, deploys and edits, each typed with its consequence, and the steps that should come first.

Back office

Any process log

If a system records who did what, in what order, and how it ended, it has a corpus. The adapter is the only per-source work.

06 / The packages

Start free. Mine when you are ready.

polyx is source-available under the Business Source License 1.1 and converts to Apache-2.0 four years after each version is published. Production use within your own organisation is granted. The Jev adapter is MIT.

07 / What it does not do

The limits, stated up front.