返回 CodeWhale
CONSTITUTIONAL_KERNEL_AUDIT.md
根目录 / docs / CONSTITUTIONAL_KERNEL_AUDIT.md
1 # Constitutional kernel audit
2
3 This audit records the first-turn boundary after the progressive-context work in
4 PR #5077. Counts use Codewhale's conservative characters / 3 estimator and the same
5 workspace used by the PR receipts: `/Volumes/VIXinSSD/CW/codewhale`.
6
7 ## Measured result
8
9 | Receipt | Before kernel pass | After kernel pass | Change |
10 | --- | ---: | ---: | ---: |
11 | `doctor --context-json` active source total | 9,127 | 7,908 | -1,219 (-13.36%) |
12 | model-facing system blocks | 9,063 | 7,844 | -1,219 (-13.45%) |
13 | bundled constitution entry | 2,647 | 1,428 | -1,219 (-46.05%) |
14 | original installed-doctor baseline | 17,839 | 7,908 | -9,931 (-55.67%) |
15
16 The 64-token difference between the doctor total and model-facing blocks is
17 diagnostic accounting: project-context warnings (33) and provider facts (31).
18 It is not claimed as prompt savings.
19
20 ## Pi comparison
21
22 Pi 0.80.3 was measured through its installed SDK in the same working directory,
23 with its actual default `read`, `bash`, `edit`, and `write` prompt snippets and
24 with extensions disabled. The table applies the same conservative characters / 3
25 estimator used by Codewhale's doctor:
26
27 | Pi fresh system variant | Characters | Conservative tokens |
28 | --- | ---: | ---: |
29 | Default context and 16 discovered skills | 27,671 | 9,224 |
30 | Context, skills disabled | 17,719 | 5,907 |
31 | Skills, context disabled | 12,485 | 4,162 |
32 | Base and actual tool snippets only | 2,533 | 845 |
33
34 The full configured Codewhale system receipt is 7,844 model-facing tokens, 1,380
35 below the full configured Pi receipt. With skill indexes removed from both, the
36 comparison is approximately 7,050 versus 5,907. That 1,143-token Codewhale
37 premium is the deliberate constitutional, mode, and runtime-special-feature
38 budget rather than undisclosed project text.
39
40 This is a system-message comparison, not a provider token-billing receipt. It
41 does not include Codewhale's separately transported tool schemas. Pi's one-line
42 tool snippets are part of its system message and are included.
43
44 Pi discovered and eagerly read `/Volumes/VIXinSSD/CW/AGENTS.md` (1,635
45 characters) and `/Volumes/VIXinSSD/CW/codewhale/AGENTS.md` (13,280 characters).
46 Like Codewhale, it keeps skill bodies lazy; unlike this branch, its discovered
47 skill metadata was not bounded and added 9,952 characters in this environment.
48
49 ## First-turn constitutional kernel
50
51 The reduced constitution keeps these duties eager and test-locked:
52
53 - **Authority and user intent**: the current user request stays first in the
54 exact `Whose word wins` chain; the agent must do that request and avoid silent
55 scope expansion.
56 - **Safety and authorization**: irreversible actions, publication, spending,
57 credentials, and material scope expansion require express authorization in
58 the current request; otherwise the agent must name the decision and ask.
59 Tool, approval, sandbox, skill, role, and project gates remain binding, and
60 prose cannot manufacture authority the runtime withheld.
61 - **Truthfulness**: tool evidence remains ground truth; failures and uncertainty
62 must be reported; facts may be set aside but never invented.
63 - **Completion**: work is not done until checked; external actions require tool
64 confirmation; running work and partial results cannot be presented as whole.
65 - **Mechanism**: authorization, ordering, stopping, schemas, limits, and required
66 checks belong in code, types, tests, tool gates, and runtime policy.
67 - **Identity**: the short `The A is already yours` idea remains, without carrying
68 a second operational playbook inside the constitution.
69
70 `constitutional_kernel_keeps_first_turn_authority_safety_and_completion` proves
71 these clauses are present in the fresh static prefix, not merely available to a
72 later tool call. The ordering test separately locks the complete precedence
73 chain.
74
75 ## Procedural detail outside the constitution
76
77 These are useful procedures, not constitutional authority. They do not need to
78 out-shout every user turn:
79
80 - execution cadence and delegation live in the active mode doctrine and the
81 compact Core Execution block;
82 - causal debugging is discoverable through the bundled `debug` skill;
83 - candidate comparison is discoverable through `best-of-n`;
84 - minimal-change cleanup is discoverable through `simplify`;
85 - deep verification workflows are discoverable through `verify`, `test`, and
86 `review`, while the obligation to verify remains in the eager kernel;
87 - continuity structure is action-local to `/relay`.
88
89 This is not a byte-for-byte relocation of the deleted prose. The first-turn
90 duties remain in the kernel; these pre-existing skills and action-local surfaces
91 carry deeper procedure only when it is useful.
92
93 Language mirroring and terminal output formatting remain eager in this pass.
94 They are distinctive product behavior, and removing them was not necessary to
95 separate constitutional law from operational procedure.
96
97 ## Other eager entries
98
99 The remaining measured entries are intentionally distinct from the bundled
100 constitutional kernel:
101
102 | Entry | Tokens | Why eager |
103 | --- | ---: | --- |
104 | Repository constitution | 667 | Repository-scoped authority |
105 | Project instructions | 4,459 | Project law; eagerly discovered like Pi's `AGENTS.md` loader |
106 | Skills routing index | 794 | Bounded metadata only; bodies load on demand |
107 | Agent mode doctrine | 268 | Current execution mode |
108 | Core Execution | 119 | Compact execution/tool discipline |
109 | Authority recap | 88 | Recency-safe pointer to the one precedence chain |
110 | Environment | 21 | Exact workspace and locale facts |
111
112 The dominant remaining cost is project-owned instruction text, not hidden base
113 prompt policy. That boundary is deliberately preserved: Codewhale, like Pi,
114 discovers and loads applicable `AGENTS.md`/`CLAUDE.md` files itself rather than
115 asking the model to guess that they exist.
116
116 lines MARKDOWN