agent-bios 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEPENDENCIES.md +89 -0
- package/LICENSE +21 -0
- package/README.md +86 -0
- package/claude/CLAUDE.md +138 -0
- package/claude/guides/cli-multi-model-workflow.md +194 -0
- package/claude/guides/coding-staged-workflow.md +70 -0
- package/claude/guides/implementation-map.md +34 -0
- package/claude/guides/llm-capability-boundary-examples.md +123 -0
- package/claude/guides/llm-capability-boundary-patterns.md +339 -0
- package/claude/guides/llm-capability-boundary.md +255 -0
- package/claude/guides/mock-realization-boundary.md +275 -0
- package/claude/guides/svg-visualization-guide.md +321 -0
- package/codex/AGENTS.md +139 -0
- package/codex/agents/frontier.toml +8 -0
- package/codex/agents/reviewer.toml +9 -0
- package/codex/agents/sweep.toml +9 -0
- package/codex/agents/workhorse.toml +8 -0
- package/codex/guides/cli-multi-model-workflow.md +194 -0
- package/codex/guides/coding-staged-workflow.md +70 -0
- package/codex/guides/implementation-map.md +34 -0
- package/codex/guides/llm-capability-boundary-examples.md +123 -0
- package/codex/guides/llm-capability-boundary-patterns.md +339 -0
- package/codex/guides/llm-capability-boundary.md +255 -0
- package/codex/guides/mock-realization-boundary.md +275 -0
- package/codex/guides/svg-visualization-guide.md +321 -0
- package/config/agent-launch.toml +94 -0
- package/package.json +54 -0
- package/scripts/agent-launch.py +1742 -0
- package/scripts/check-parity.sh +1703 -0
- package/scripts/codex-helm.sh +370 -0
- package/scripts/codex-run.sh +176 -0
- package/scripts/install.sh +310 -0
- package/scripts/provision-venv.sh +28 -0
- package/scripts/session-cost.py +106 -0
- package/shell/agent-launch.zsh +38 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
---
|
|
2
|
+
guide_id: llm-capability-boundary-patterns
|
|
3
|
+
parent: llm-capability-boundary
|
|
4
|
+
language: en
|
|
5
|
+
status: active
|
|
6
|
+
use_when:
|
|
7
|
+
- implementing submit tools, runtime-owned fields, or output channel locks
|
|
8
|
+
- choosing provider strict schema vs runtime allowed-set validation
|
|
9
|
+
- implementing grounding, provenance, projection, or evidence-index mechanics
|
|
10
|
+
- handling security, side effects, persistence, idempotency, or retry policy
|
|
11
|
+
- managing schema single source of truth and migration
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# LLM And Capability Boundary: Enforcement Patterns
|
|
15
|
+
|
|
16
|
+
This guide is a scoped extension of
|
|
17
|
+
`${CODEX_HOME:-$HOME/.codex}/guides/llm-capability-boundary.md`.
|
|
18
|
+
Use it when implementing the enforcement mechanics that the boundary doctrine
|
|
19
|
+
assigns to runtime/tools and the capability surface.
|
|
20
|
+
|
|
21
|
+
## Structural Enforcement Patterns
|
|
22
|
+
|
|
23
|
+
### Bounded Submit Tool
|
|
24
|
+
|
|
25
|
+
Use a submit tool when an LLM must provide semantic content for a
|
|
26
|
+
machine-consumed artifact.
|
|
27
|
+
|
|
28
|
+
Pattern:
|
|
29
|
+
|
|
30
|
+
1. Runtime creates a submit tool with a narrow schema.
|
|
31
|
+
2. LLM submits only bounded semantic fields.
|
|
32
|
+
3. Runtime rejects unknown fields and runtime-owned fields.
|
|
33
|
+
4. Runtime validates enums, refs, grounding, and policy constraints.
|
|
34
|
+
5. Runtime writes the canonical artifact.
|
|
35
|
+
6. Downstream consumers read only the runtime artifact.
|
|
36
|
+
|
|
37
|
+
This is stronger than asking the LLM to "write valid YAML." The LLM can still
|
|
38
|
+
make semantic judgments, but shape, path, ids, metadata, and serialization are
|
|
39
|
+
owned by runtime/tools.
|
|
40
|
+
|
|
41
|
+
Illustrative implementation:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
type FindingSubmitPayload = {
|
|
45
|
+
findings: Array<{
|
|
46
|
+
target: string;
|
|
47
|
+
claim: string;
|
|
48
|
+
evidence_refs: string[];
|
|
49
|
+
rationale?: string;
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function submitFindings(payload: FindingSubmitPayload, ctx: RuntimeContext) {
|
|
54
|
+
rejectUnknownFields(payload, ["findings"]);
|
|
55
|
+
rejectRuntimeOwnedFieldsDeep(payload, [
|
|
56
|
+
"schema_version",
|
|
57
|
+
"session_id",
|
|
58
|
+
"lens_id",
|
|
59
|
+
"candidate_id",
|
|
60
|
+
"source_ref",
|
|
61
|
+
"output_path",
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
validateEvidenceRefs(payload.findings, ctx.allowedEvidenceRefs);
|
|
65
|
+
|
|
66
|
+
const artifact = {
|
|
67
|
+
schema_version: 1,
|
|
68
|
+
session_id: ctx.sessionId,
|
|
69
|
+
lens_id: ctx.lensId,
|
|
70
|
+
findings: payload.findings.map((finding, index) => ({
|
|
71
|
+
...finding,
|
|
72
|
+
candidate_id: stableCandidateId(ctx, finding, index),
|
|
73
|
+
source_ref: `${ctx.outputPath}#candidate-${index + 1}`,
|
|
74
|
+
})),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
atomicWriteYaml(ctx.outputPath, validateFindingArtifact(artifact));
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Runtime-Owned Deterministic Fields
|
|
82
|
+
|
|
83
|
+
Keep deterministic fields outside LLM authority when runtime/tools can derive
|
|
84
|
+
them.
|
|
85
|
+
|
|
86
|
+
Common runtime-owned fields:
|
|
87
|
+
|
|
88
|
+
- `schema_version`
|
|
89
|
+
- `session_id`
|
|
90
|
+
- `lens_id`
|
|
91
|
+
- `issue_id` when unit identity already determines it
|
|
92
|
+
- `candidate_id`, `finding_id`, `cause_id` when stable runtime assignment is
|
|
93
|
+
available
|
|
94
|
+
- `source_ref` when it can be derived from artifact path and local id
|
|
95
|
+
- `output_path`
|
|
96
|
+
- validation scaffolds
|
|
97
|
+
- artifact envelope and serialization
|
|
98
|
+
- source snapshot id, source hash, trust tier, permission scope, and staleness
|
|
99
|
+
metadata
|
|
100
|
+
|
|
101
|
+
The LLM may select a known id only when selection is the semantic task. If the
|
|
102
|
+
runtime already knows the id, the LLM should not submit it.
|
|
103
|
+
|
|
104
|
+
Stable ordering alone can break under retry, batching, dedupe, or parallelism.
|
|
105
|
+
Use normalized hashes, idempotency keys, persisted sequence tables, or prior-run
|
|
106
|
+
mappings when ids must remain stable across runs.
|
|
107
|
+
|
|
108
|
+
### Accepted Output Channel Lock
|
|
109
|
+
|
|
110
|
+
When structured output matters, make the submit path the only accepted path.
|
|
111
|
+
|
|
112
|
+
Examples:
|
|
113
|
+
|
|
114
|
+
- Canonical artifact writes happen only through runtime submit handling.
|
|
115
|
+
- Text output can be captured for diagnostics, but does not become artifact
|
|
116
|
+
truth.
|
|
117
|
+
- A text-only executor is rejected when the contract requires a tool-capable
|
|
118
|
+
structured-output path.
|
|
119
|
+
- Runtime-owned canonical paths are isolated from LLM-written scratch paths.
|
|
120
|
+
|
|
121
|
+
This turns "please use the right format" into "only this channel is accepted."
|
|
122
|
+
A read-only filesystem route is one implementation. The deeper rule is that the
|
|
123
|
+
canonical artifact truth is writable only through runtime-controlled paths.
|
|
124
|
+
|
|
125
|
+
### Provider Strict Schema For Short Closed Values
|
|
126
|
+
|
|
127
|
+
Provider strict schema is useful for short, stable, closed vocabularies. It is
|
|
128
|
+
not the artifact authority.
|
|
129
|
+
|
|
130
|
+
Good strict-schema candidates:
|
|
131
|
+
|
|
132
|
+
- `severity`
|
|
133
|
+
- `stance`
|
|
134
|
+
- `issue_role`
|
|
135
|
+
- `judgment_state`
|
|
136
|
+
- `impact_kind`
|
|
137
|
+
- `timing_class`
|
|
138
|
+
- `closure_class`
|
|
139
|
+
- short bounded `issue_id` values when the LLM must select one
|
|
140
|
+
- confidence or relation enums
|
|
141
|
+
|
|
142
|
+
Keep runtime enum validation too. Provider support depends on model, route,
|
|
143
|
+
schema subset, schema size, and refusal/incomplete behavior. Probe the route
|
|
144
|
+
before relying on strict schema, and fail or downgrade deliberately when support
|
|
145
|
+
is unavailable.
|
|
146
|
+
|
|
147
|
+
Keep sensitive data, long source text, private refs, and user-specific secrets
|
|
148
|
+
out of schema names, enum values, const values, and regex patterns. Schema text
|
|
149
|
+
itself is data.
|
|
150
|
+
|
|
151
|
+
### Runtime Allowed-Set Validation For Long Refs
|
|
152
|
+
|
|
153
|
+
Long refs, source-derived refs, quoted snippets, and path-heavy strings are
|
|
154
|
+
better handled as strings in provider schema plus runtime allowed-set
|
|
155
|
+
validation.
|
|
156
|
+
|
|
157
|
+
Good runtime allowed-set candidates:
|
|
158
|
+
|
|
159
|
+
- `evidence_refs`
|
|
160
|
+
- source refs containing quotes
|
|
161
|
+
- refs that include line text
|
|
162
|
+
- generated artifact anchors
|
|
163
|
+
- source snippets
|
|
164
|
+
- long path-like values
|
|
165
|
+
- user- or tenant-scoped ids
|
|
166
|
+
|
|
167
|
+
This keeps provider schemas robust while preserving fail-loud validation. The
|
|
168
|
+
LLM can emit a string, but runtime rejects strings outside the computed allowed
|
|
169
|
+
set.
|
|
170
|
+
|
|
171
|
+
### Grounding And Provenance
|
|
172
|
+
|
|
173
|
+
Use grounding as a hard gate only when source truth is decidable.
|
|
174
|
+
|
|
175
|
+
Good grounding-blocked candidates:
|
|
176
|
+
|
|
177
|
+
- evidence anchor resolves to a known source span
|
|
178
|
+
- quoted source text exists in the cited file
|
|
179
|
+
- ref belongs to a known artifact and anchor set
|
|
180
|
+
- count, id, or relation coverage can be deterministically checked
|
|
181
|
+
|
|
182
|
+
Keep warning-style audits for free prose when false positives are likely. A
|
|
183
|
+
free-text synthesis citation audit may be useful, but it should not become a
|
|
184
|
+
hard gate until the verifier is reliable.
|
|
185
|
+
|
|
186
|
+
Grounding is not provenance. A quote can match a source span while the source is
|
|
187
|
+
stale, unauthorized, poisoned, incomplete, or low-trust. Track provenance
|
|
188
|
+
separately:
|
|
189
|
+
|
|
190
|
+
- `source_snapshot_id`
|
|
191
|
+
- source hash or version
|
|
192
|
+
- ingest time
|
|
193
|
+
- permission scope
|
|
194
|
+
- trust tier
|
|
195
|
+
- retrieval policy
|
|
196
|
+
- staleness policy
|
|
197
|
+
- poisoning or integrity checks where relevant
|
|
198
|
+
|
|
199
|
+
Use robust quote checks in production: normalize whitespace and Unicode, use
|
|
200
|
+
stable offsets or line anchors, disambiguate duplicate spans, and record source
|
|
201
|
+
snapshot ids.
|
|
202
|
+
|
|
203
|
+
### Deterministic Projection
|
|
204
|
+
|
|
205
|
+
When an artifact is a direct projection from upstream artifacts, make it
|
|
206
|
+
runtime-owned.
|
|
207
|
+
|
|
208
|
+
Examples:
|
|
209
|
+
|
|
210
|
+
- Finding ledger from lens sidecars.
|
|
211
|
+
- Issue stance matrix from individual stance responses.
|
|
212
|
+
- Synthesis ledger from issue synthesis responses.
|
|
213
|
+
- Review record counts and classification summaries from canonical issue
|
|
214
|
+
artifacts.
|
|
215
|
+
|
|
216
|
+
Use the LLM to define projection rules when semantic design is needed. Use
|
|
217
|
+
runtime/tools to apply the rules.
|
|
218
|
+
|
|
219
|
+
Projection-first context is often better than asking downstream LLM units to
|
|
220
|
+
reread large raw artifacts. Add compact semantic fields from authoritative
|
|
221
|
+
upstream artifacts, such as `proposed_action`, `issue_statement`,
|
|
222
|
+
`domain_threshold_used`, `singleton_reason`, `shared_cause`, dependencies, and
|
|
223
|
+
bounded source refs.
|
|
224
|
+
|
|
225
|
+
Projection can also hide important evidence. Track coverage, omitted evidence,
|
|
226
|
+
and fallback triggers when the projection may be insufficient.
|
|
227
|
+
|
|
228
|
+
### Human View From Machine Artifact
|
|
229
|
+
|
|
230
|
+
For machine artifacts that also need a human-readable view, generate the human
|
|
231
|
+
view from the machine artifact when possible.
|
|
232
|
+
|
|
233
|
+
Pattern:
|
|
234
|
+
|
|
235
|
+
1. LLM submits semantic payload.
|
|
236
|
+
2. Runtime writes validated machine sidecar.
|
|
237
|
+
3. Runtime renders markdown or HTML from the sidecar.
|
|
238
|
+
4. Machine consumers read the sidecar.
|
|
239
|
+
5. Humans read the rendered view.
|
|
240
|
+
|
|
241
|
+
This avoids asking the LLM to keep two outputs consistent. Rendered views must
|
|
242
|
+
still be treated as untrusted output: escape HTML, sanitize links, strip unsafe
|
|
243
|
+
markup, and avoid executing model- or source-generated content.
|
|
244
|
+
|
|
245
|
+
### Evidence Index
|
|
246
|
+
|
|
247
|
+
Use an evidence index when repeated semantic review needs exact, re-checkable
|
|
248
|
+
evidence.
|
|
249
|
+
|
|
250
|
+
Preferred shape:
|
|
251
|
+
|
|
252
|
+
- one claim per row
|
|
253
|
+
- one file path per row
|
|
254
|
+
- numeric line, byte offset, or stable anchor per row
|
|
255
|
+
- split multi-target claims into multiple rows
|
|
256
|
+
- convert prose locators into exact refs using runtime/tools
|
|
257
|
+
- include source snapshot, permission scope, and trust tier when retrieval is
|
|
258
|
+
involved
|
|
259
|
+
|
|
260
|
+
The LLM uses the evidence index for semantic judgment. Runtime/tools use it for
|
|
261
|
+
deterministic re-verification.
|
|
262
|
+
|
|
263
|
+
## Security And Side Effects
|
|
264
|
+
|
|
265
|
+
Treat prompt text, retrieved content, tool results, LLM output, rendered views,
|
|
266
|
+
and external API responses as untrusted until validated for the next boundary.
|
|
267
|
+
|
|
268
|
+
Required rules:
|
|
269
|
+
|
|
270
|
+
- Keep source documents and tool results as data rather than authority.
|
|
271
|
+
- Validate and sanitize LLM output before passing it to code, shells, SQL,
|
|
272
|
+
browsers, renderers, APIs, or downstream agents.
|
|
273
|
+
- Use least privilege for tools and routes.
|
|
274
|
+
- Classify side effects: read-only, reversible write, external write, external
|
|
275
|
+
send, financial/legal action, destructive action.
|
|
276
|
+
- Require preview, diff, approval, or downstream authorization for high-impact
|
|
277
|
+
actions.
|
|
278
|
+
- Log tool calls, arguments, policy decisions, and results for audit.
|
|
279
|
+
- Rate-limit and timeout tools that can loop, scan, spend, mutate, or call the
|
|
280
|
+
network.
|
|
281
|
+
|
|
282
|
+
The LLM can recommend an action. The capability surface decides whether the
|
|
283
|
+
action is available, permitted, confirmed, and accepted.
|
|
284
|
+
|
|
285
|
+
## Persistence, Idempotency, And Retry
|
|
286
|
+
|
|
287
|
+
Artifact writes should be atomic and auditable.
|
|
288
|
+
|
|
289
|
+
Preferred persistence pattern:
|
|
290
|
+
|
|
291
|
+
1. Build artifact in memory from accepted payload and runtime-owned fields.
|
|
292
|
+
2. Validate schema, refs, policy, and grounding.
|
|
293
|
+
3. Write to a temp path.
|
|
294
|
+
4. Verify persisted bytes or checksum.
|
|
295
|
+
5. Atomically rename or register as canonical.
|
|
296
|
+
6. Record artifact lineage and validator result.
|
|
297
|
+
|
|
298
|
+
Retry policy must distinguish:
|
|
299
|
+
|
|
300
|
+
- transient provider failure
|
|
301
|
+
- invalid structured payload
|
|
302
|
+
- unsupported ref
|
|
303
|
+
- grounding failure
|
|
304
|
+
- permission or policy failure
|
|
305
|
+
- partial persistence failure
|
|
306
|
+
- side-effect uncertainty
|
|
307
|
+
|
|
308
|
+
Retries are safe for pure generation and validation. They are not automatically
|
|
309
|
+
safe for external side effects. Use idempotency keys, locks, duplicate detection,
|
|
310
|
+
or compensation plans where needed.
|
|
311
|
+
|
|
312
|
+
## Single Source Of Truth And Schema Evolution
|
|
313
|
+
|
|
314
|
+
Hybrid enforcement creates drift risk. A single constraint can appear in prompt
|
|
315
|
+
text, submit schema, provider schema, runtime validator, allowed-set builder,
|
|
316
|
+
artifact validator, and tests.
|
|
317
|
+
|
|
318
|
+
For each stage, define one canonical source and derive the others:
|
|
319
|
+
|
|
320
|
+
- submit tool schema
|
|
321
|
+
- provider schema
|
|
322
|
+
- runtime validator
|
|
323
|
+
- allowed-set validator
|
|
324
|
+
- artifact validator
|
|
325
|
+
- prompt contract
|
|
326
|
+
- tests
|
|
327
|
+
- migration sample artifacts
|
|
328
|
+
|
|
329
|
+
When this is not possible yet, mark the authoritative source explicitly and add
|
|
330
|
+
tests that catch schema/validator drift.
|
|
331
|
+
|
|
332
|
+
Versioned artifacts need a migration policy:
|
|
333
|
+
|
|
334
|
+
- what requires a schema version bump
|
|
335
|
+
- backward and forward compatibility expectations
|
|
336
|
+
- migration scripts or readers for old artifacts
|
|
337
|
+
- consumer contract tests
|
|
338
|
+
- deprecation window
|
|
339
|
+
- sample artifact updates
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
---
|
|
2
|
+
guide_id: llm-capability-boundary
|
|
3
|
+
language: en
|
|
4
|
+
status: active
|
|
5
|
+
use_when:
|
|
6
|
+
- designing structured outputs
|
|
7
|
+
- changing runtime-owned artifacts
|
|
8
|
+
- defining submit tools or accepted output channels
|
|
9
|
+
- separating LLM semantic judgment from deterministic execution
|
|
10
|
+
- designing validators, grounding checks, or capability-surface constraints
|
|
11
|
+
- designing tool use, retrieval, side effects, or artifact persistence
|
|
12
|
+
core_rules:
|
|
13
|
+
- instructions describe intended work, semantic criteria, and completion criteria
|
|
14
|
+
- capability surface enforces constraints through context, tools, permissions, routes, paths, output channels, validators, gates, and approvals
|
|
15
|
+
- assign each field or operation one primary authority, then add layered checks where needed
|
|
16
|
+
- LLM handles semantic judgment, rationale, tradeoffs, and evidence reduction
|
|
17
|
+
- runtime/tools handle deterministic execution, artifact creation, merge, serialization, validation, persistence, and tests
|
|
18
|
+
- machine-consumed artifacts are created through submit tools or equivalent constrained channels
|
|
19
|
+
- provider strict schema is an execution aid, not the source of artifact truth
|
|
20
|
+
- tool inputs, tool results, retrieved content, and rendered views are untrusted until validated or sanitized
|
|
21
|
+
field_assignment:
|
|
22
|
+
short_closed_values: provider_closed_selection_plus_runtime_enum_validation
|
|
23
|
+
runtime_known_ids: runtime_owned_unless_selection_is_semantic
|
|
24
|
+
long_refs_and_source_snippets: runtime_allowed_set_validation
|
|
25
|
+
evidence_anchors: grounding_blocked_when_source_truth_is_decidable
|
|
26
|
+
source_provenance: runtime_owned_snapshot_hash_scope_and_trust_tier
|
|
27
|
+
open_rationale: free_generation_with_shape_checks
|
|
28
|
+
side_effects: capability_surface_plus_policy_gate
|
|
29
|
+
artifact_envelope_and_serialization: runtime_only
|
|
30
|
+
verification_focus:
|
|
31
|
+
- accepted output channel is explicit
|
|
32
|
+
- LLM cannot create canonical machine artifacts through free prose
|
|
33
|
+
- runtime-owned fields and unknown fields fail loudly
|
|
34
|
+
- provider schema limits are known and probed before relying on them
|
|
35
|
+
- long refs are validated by runtime allowed sets instead of provider enums
|
|
36
|
+
- grounding gates are used only for decidable truths
|
|
37
|
+
- source trust, permission, staleness, and poisoning risk are checked separately from quote grounding
|
|
38
|
+
- side-effect tools are classified by risk and gated by permission or approval
|
|
39
|
+
- artifact writes are atomic, idempotent where possible, and auditable
|
|
40
|
+
- schema, validator, allowed-set, prompt, and tests share one authority or have drift-catching tests
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
# LLM And Capability Boundary Guide
|
|
44
|
+
|
|
45
|
+
Use this guide when an LLM produces, selects, validates, summarizes, or routes
|
|
46
|
+
machine-consumed artifacts, code, ontology, pipeline outputs, review findings,
|
|
47
|
+
structured documents, or runtime decisions.
|
|
48
|
+
|
|
49
|
+
The core lesson is simple: instructions describe the intended work; the
|
|
50
|
+
capability surface makes the valid execution path available, bounded, accepted,
|
|
51
|
+
and observable.
|
|
52
|
+
|
|
53
|
+
Scoped extensions:
|
|
54
|
+
|
|
55
|
+
- For enforcement mechanics — submit tools, runtime-owned fields, output
|
|
56
|
+
channel locks, provider schema use, allowed-set validation, grounding and
|
|
57
|
+
provenance, deterministic projection, security and side effects,
|
|
58
|
+
persistence and retry, and schema evolution — read and use
|
|
59
|
+
`${CODEX_HOME:-$HOME/.codex}/guides/llm-capability-boundary-patterns.md`.
|
|
60
|
+
- For worked case studies applying this boundary, read and use
|
|
61
|
+
`${CODEX_HOME:-$HOME/.codex}/guides/llm-capability-boundary-examples.md`.
|
|
62
|
+
|
|
63
|
+
## Core Model
|
|
64
|
+
|
|
65
|
+
- Instructions describe intended work, semantic criteria, tradeoffs, and
|
|
66
|
+
completion criteria.
|
|
67
|
+
- The LLM performs semantic work: intent clarification, meaning assignment,
|
|
68
|
+
materiality and causality judgment, rationale writing, option comparison,
|
|
69
|
+
and evidence reduction.
|
|
70
|
+
- Runtime/tools perform authoritative mechanical work: parsing, counting,
|
|
71
|
+
calculation, API calls, deterministic merge, serialization, validation,
|
|
72
|
+
persistence, tests, and diff comparison.
|
|
73
|
+
- The capability surface provides structural constraints: accessible context,
|
|
74
|
+
available tools, permissions, execution routes, artifact paths, accepted output
|
|
75
|
+
channels, validators, retry policy, approval gates, and failure behavior.
|
|
76
|
+
- Canonical artifacts are created by runtime/tools, not by raw LLM prose, when
|
|
77
|
+
downstream systems consume them.
|
|
78
|
+
|
|
79
|
+
Prefer this framing:
|
|
80
|
+
|
|
81
|
+
> The LLM may propose semantic content. The runtime decides what becomes
|
|
82
|
+
> artifact truth.
|
|
83
|
+
|
|
84
|
+
Use stronger prompts to clarify meaning. Use capability design to constrain
|
|
85
|
+
behavior that affects correctness, reproducibility, artifact truth, privacy,
|
|
86
|
+
security, or side effects.
|
|
87
|
+
|
|
88
|
+
## Capability Surface
|
|
89
|
+
|
|
90
|
+
The capability surface is the set of actions the LLM can actually take and the
|
|
91
|
+
outputs the runtime will actually accept. Shape it before relying on the LLM to
|
|
92
|
+
follow a rule.
|
|
93
|
+
|
|
94
|
+
Important levers:
|
|
95
|
+
|
|
96
|
+
- Accessible context: files, refs, rows, artifacts, source snippets, projections,
|
|
97
|
+
and retrieved evidence the unit may inspect.
|
|
98
|
+
- Available tools: read tools, submit tools, validation tools, search tools, API
|
|
99
|
+
tools, renderers, and their input schemas.
|
|
100
|
+
- Permissions: read-only, workspace-write, denied paths, network access,
|
|
101
|
+
sandbox mode, route-specific side effects, and user approval.
|
|
102
|
+
- Execution routes: tool-capable executor, text-only executor, structured output
|
|
103
|
+
route, direct-call route, deterministic runtime route, or human-review route.
|
|
104
|
+
- Artifact paths: exact output paths, canonical truth locations, temp paths,
|
|
105
|
+
and denied write locations.
|
|
106
|
+
- Accepted output channels: submit tool call, structured JSON payload, runtime
|
|
107
|
+
projection, generated YAML, markdown view, or final prose.
|
|
108
|
+
- Validators and gates: schema validation, unknown-field rejection,
|
|
109
|
+
runtime-owned-field rejection, enum validation, allowed-set validation,
|
|
110
|
+
grounding checks, provenance checks, citation checks, static checks, E2E
|
|
111
|
+
checks, and semantic quality gates.
|
|
112
|
+
- Retry/fail policy: retry transient generation failures; fail clearly when the
|
|
113
|
+
available route cannot enforce the required contract.
|
|
114
|
+
- Observability: prompt packet snapshot, model/provider version, schema hash,
|
|
115
|
+
source snapshot, validator decision, retry reason, and artifact lineage.
|
|
116
|
+
|
|
117
|
+
## Boundary Decision Table
|
|
118
|
+
|
|
119
|
+
| Need | Primary authority | Preferred mechanism |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| Clarify user intent or product meaning | LLM | Prose reasoning and decision framing |
|
|
122
|
+
| Choose tradeoffs or materiality | LLM | Bounded semantic judgment with evidence |
|
|
123
|
+
| Produce open rationale or explanation | LLM | Free generation with shape constraints when needed |
|
|
124
|
+
| Inspect files or fresh facts | Tools/runtime | Search, parse, read, API call, source snapshot |
|
|
125
|
+
| Create canonical machine artifact | Runtime | Submit payload plus runtime serialization |
|
|
126
|
+
| Assign ids, paths, metadata, timestamps | Runtime | Runtime-owned fields |
|
|
127
|
+
| Merge artifacts by explicit rule | Runtime | Deterministic projection or merge |
|
|
128
|
+
| Validate syntax, schema, refs, counts | Runtime | Parser, schema, allowed-set, tests |
|
|
129
|
+
| Check source-span truth | Runtime | Grounding gate when decidable |
|
|
130
|
+
| Judge source trust or completeness | Runtime plus policy | Provenance, permission, staleness, trust tier |
|
|
131
|
+
| Prevent forbidden action | Capability surface | Make it unavailable, invalid, or unaccepted |
|
|
132
|
+
| Perform side effect | Capability surface plus policy | Risk class, permission, approval, audit log |
|
|
133
|
+
| Structured output required | Capability surface plus runtime | Submit tool or equivalent constrained channel |
|
|
134
|
+
|
|
135
|
+
## Structured Output Field Assignment
|
|
136
|
+
|
|
137
|
+
For each artifact field, assign one primary authority. Add layered checks for
|
|
138
|
+
cross-field invariants, security policy, privacy policy, and artifact-level
|
|
139
|
+
consistency.
|
|
140
|
+
|
|
141
|
+
| Field kind | Primary mechanism |
|
|
142
|
+
|---|---|
|
|
143
|
+
| Short closed values | Provider closed selection plus runtime enum validation |
|
|
144
|
+
| Runtime-known ids | Runtime-owned; provider enum only when LLM must select |
|
|
145
|
+
| Long refs and source snippets | Runtime closed validation; provider enum excluded |
|
|
146
|
+
| Evidence anchors | Grounding-blocked when source truth is decidable |
|
|
147
|
+
| Source provenance | Runtime-owned snapshot, hash, scope, trust tier, staleness |
|
|
148
|
+
| Open materiality or causal rationale | Free generation with structured shape checks |
|
|
149
|
+
| Side-effect decision | Capability surface plus policy and approval gate |
|
|
150
|
+
| Artifact envelope and serialization | Runtime only |
|
|
151
|
+
|
|
152
|
+
The goal is not to force every field into provider strict schema. The goal is
|
|
153
|
+
to use the weakest mechanism that is strong enough for that field.
|
|
154
|
+
|
|
155
|
+
## Generate-And-Validate
|
|
156
|
+
|
|
157
|
+
Generate-and-validate means the LLM generates a payload through one accepted
|
|
158
|
+
output channel, and runtime validates after generation.
|
|
159
|
+
|
|
160
|
+
It is useful when:
|
|
161
|
+
|
|
162
|
+
- fields are open and expressive
|
|
163
|
+
- iteration speed matters
|
|
164
|
+
- shape correctness is enough for the current step
|
|
165
|
+
- validator failures can be retried safely
|
|
166
|
+
|
|
167
|
+
It guarantees:
|
|
168
|
+
|
|
169
|
+
- expected top-level shape
|
|
170
|
+
- absence of unknown fields
|
|
171
|
+
- absence of runtime-owned fields
|
|
172
|
+
- parseable structured payload
|
|
173
|
+
- canonical artifact written by runtime
|
|
174
|
+
|
|
175
|
+
It does not guarantee meaning by itself. A well-formed payload can still contain
|
|
176
|
+
an unsupported claim, wrong ref, stale source, unauthorized source, unsafe link,
|
|
177
|
+
or semantically wrong category unless a validator or review gate catches it.
|
|
178
|
+
|
|
179
|
+
## Construct-And-Verify
|
|
180
|
+
|
|
181
|
+
Construct-and-verify means the runtime owns artifact construction, provides
|
|
182
|
+
closed choices where possible, and verifies grounded claims.
|
|
183
|
+
|
|
184
|
+
It is useful when:
|
|
185
|
+
|
|
186
|
+
- options can be enumerated before the LLM call
|
|
187
|
+
- refs or anchors can be checked against source truth
|
|
188
|
+
- invalid values must be impossible or fail-loud
|
|
189
|
+
- artifact authority or downstream impact is high
|
|
190
|
+
- side effects require permission, preview, or approval
|
|
191
|
+
|
|
192
|
+
It costs more:
|
|
193
|
+
|
|
194
|
+
- runtime must enumerate option space
|
|
195
|
+
- validators become product-critical code
|
|
196
|
+
- false constraints can exclude the right answer
|
|
197
|
+
- nuanced judgments can be discretized into the nearest bucket
|
|
198
|
+
- dependencies become more sequential
|
|
199
|
+
|
|
200
|
+
Use it per field or operation, not as a blanket replacement for LLM judgment.
|
|
201
|
+
|
|
202
|
+
## Design Procedure
|
|
203
|
+
|
|
204
|
+
Use this procedure when designing a new LLM-assisted artifact or revising an
|
|
205
|
+
existing one.
|
|
206
|
+
|
|
207
|
+
1. Identify the canonical artifact and downstream consumers.
|
|
208
|
+
2. Split fields into semantic fields, deterministic fields, provenance fields,
|
|
209
|
+
and side-effect operations.
|
|
210
|
+
3. Assign each field or operation one primary authority.
|
|
211
|
+
4. Decide the accepted output channel.
|
|
212
|
+
5. Shape accessible context and available tools around the task.
|
|
213
|
+
6. Make deterministic fields runtime-owned.
|
|
214
|
+
7. Decide which provider schema constraints are actually supported for the
|
|
215
|
+
selected model and route.
|
|
216
|
+
8. Derive schemas and validators from one canonical source.
|
|
217
|
+
9. Add fail-loud checks for unknown fields, runtime-owned fields, unsupported
|
|
218
|
+
refs, and denied actions.
|
|
219
|
+
10. Add grounding checks only where truth is decidable.
|
|
220
|
+
11. Add provenance checks for source trust, permission, freshness, and integrity.
|
|
221
|
+
12. Decide retry/fail policy by failure kind and side-effect class.
|
|
222
|
+
13. Make artifact persistence atomic and auditable.
|
|
223
|
+
14. Add focused tests for invalid values, unsupported refs, route rejection,
|
|
224
|
+
grounding failure, policy failure, schema drift, and artifact persistence.
|
|
225
|
+
15. Report which checks prove shape, which prove wiring, which prove source
|
|
226
|
+
grounding, and which only estimate semantic quality.
|
|
227
|
+
|
|
228
|
+
## Verification Checklist
|
|
229
|
+
|
|
230
|
+
- The LLM cannot create the canonical machine artifact through free prose.
|
|
231
|
+
- The accepted output channel is explicit.
|
|
232
|
+
- Structured output uses a submit tool or equivalent constrained channel.
|
|
233
|
+
- Runtime-owned fields are rejected if submitted by the LLM.
|
|
234
|
+
- Unknown fields fail loudly.
|
|
235
|
+
- Short closed values are provider enums where supported and runtime enums
|
|
236
|
+
everywhere.
|
|
237
|
+
- Provider schema limits and refusal/incomplete behavior are tested for the
|
|
238
|
+
selected route.
|
|
239
|
+
- Long refs are not provider enums when they are quote-heavy, private,
|
|
240
|
+
tenant-scoped, or source-derived.
|
|
241
|
+
- Runtime allowed-set checks reject unsupported refs.
|
|
242
|
+
- Grounding gates are used only for decidable truths.
|
|
243
|
+
- Source trust, permission, freshness, and integrity are checked separately from
|
|
244
|
+
source-span grounding.
|
|
245
|
+
- Tool inputs, tool results, retrieved content, LLM output, and rendered views
|
|
246
|
+
are treated as untrusted at each boundary.
|
|
247
|
+
- Side-effect tools have risk classes, permissions, and approval gates.
|
|
248
|
+
- Human views are derived from machine artifacts when possible and sanitized
|
|
249
|
+
before rendering.
|
|
250
|
+
- Artifact writes are atomic or have a clear recovery path.
|
|
251
|
+
- Retries are safe, idempotent, or explicitly blocked for the failure class.
|
|
252
|
+
- Schema, validator, allowed-set, prompt, and tests share one authority or have
|
|
253
|
+
drift-catching tests.
|
|
254
|
+
- Observability captures prompt packet, model/provider version, schema hash,
|
|
255
|
+
source snapshot, validator decision, retry reason, and artifact lineage.
|