Skip to content
pi-c Artifact [c1e775831c]
Login

Artifact [c1e775831c]

Artifact c1e775831c1fa238bbcecf9f5f6ea9f30e9cf53ca4453ab25d11913a4ac184ce:


Keel: what pic builds and what it hosts

Status: adopted 2026-11-21; first seam (context policy) cut 2026-11-22

The full study, with the sorting test, the hard cases and the first audit, is at https://artifacts.craftdesign.group/v/7AcFU37QOBvcGyD3TEMpp#8b97a2dfe17cd12d8d19f2b890bd60dc80e77ed6cfa7b22a13851a27c01d9630. The manifest and its checks are in tiers.

The principle

Core records and enforces; components decide. Core holds the mechanisms that make an agent durable, recoverable and observable. It holds no decision whose right answer depends on a model, a vendor's API or price list, or the current way of prompting. A decision is journaled before it takes effect, recovery reads the record and never asks the component again, and core runs with no components.

Tiers

main.c is the composition root and may name everything. The terminal interface (src/tui/) is a client.

The component ladder

Lowest rung that works: data, then a hook, then a protocol client, then a C interface, then the extension host.

The tier-line rule

A capability is not core by default. Every ticket or design note that adds one carries a line: Tier: ... Clock: ... Record: ... Default: .... A Tier: core line needs a design note in this directory with a status line. A new seam goes to the owner; a new component on an existing seam does not. Tiers move both ways, by a recorded decision.

The first seam: context policy

Status: landed 2026-11-22. Tier: core (src/policy.h). Clock: durability. Record: a pic_hook_run row per answer. Default: the built-in compaction component (src/compact.c).

Before each reply request core asks one question, PreRequest, through the hook host: the facts it owns go in (model, context window, cache lifetime, idle seconds), and the answer is "compact before this request in MODE, for REASON" or nothing. Core journals the answer before it takes effect, asks the component for that mode's plan, and runs it: a summary's requests are journaled and retried as before; a trim commits in one transaction. The first answer for a turn stands, so recovery and retries never ask again. loop.c no longer includes compact.h and decides nothing about compaction: Pi's threshold, overflow recovery's switch, lapse detection, the floor and the holdout draw are all the component's. Durability has the invariants.

How settings are scoped

A setting belongs to the tier that decides with it.

What it implies for the MCP seam (not built)

An out-of-process component could answer the same question: JSON facts in, a reason and a JSON context out, asked outside any transaction, journaled before it takes effect. Three things stand in the way today. The in-process answerer gets the journal's handle, which it uses for Pi's token estimate; an external one would need the estimate among the facts. Planning is in-process C over the journal, so an external component can only name a mode a built-in can plan, unless the plan becomes data (the first kept entry and the text, or the prompts), which pic_compact_plan nearly is. And the question blocks every request, so an external answerer needs a deadline whose default is no answer, as command hooks have.

The check that core stands alone is now real: check 5 in tiers links the core files with the vendored libraries alone, and ci/tiers.stubs lists the 29 bundled symbols core still takes, each a seam not yet cut.