codegen: fidelity gate reads the whole body; bound artifacts to engine ctx
The fidelity gate truncated the body to 4000 chars, so a body whose real
action sat after its helpers (the common shape) was judged on a prefix with
no action and wrongly returned `reconsider` -- a false reject that wasted a
rewrite and mislabeled a working skill. Live-engine probe: the truncated
state scored reconsider 0.96; the whole body scores accept 0.98.
- Fidelity gate: feed the whole body plus a deterministic operation
inventory and the de-identified goal; drop the raw request from the state
(a remote-engine PII path that added no signal). Ask the positive question
("is there a concrete operation that realizes the goal?") and give the gate
its own `codegen.fidelity.tau` instead of the run-assessment tau.
- Artifact size budget: a decision ingests a generated artifact whole, so
bound it. `parse_skill_body`/`parse_skill_test` reject an over-budget
artifact (`ArtifactTooLong`); the codegen retry ladder asks for a shorter
one. The ceiling derives from the active engine's context
(`DecisionEngine.context_tokens`: `engine.context_tokens` for the local
GGUF, `engine.winnow.context_tokens` for Winnow) minus
`codegen.decision_reserve_tokens`; `codegen.max_body_tokens` /
`max_test_tokens` override (separate limits).
- `codegen.operation_inventory()`: static HTTP-verb/path, CLI, mail, file,
and timer inventory, resolving the verb at the call site so a thin-helper
body's real endpoint is visible.
- Docs: AGENTS.md, README.md, CODEGEN.md, config.example.json.
- Tests: unit coverage for the budget, inventory, retry-shortening, and the
gate state; integration regression `test_fidelity_gate_reads_the_whole_body`
(real engine) guards the truncation bug.
This commit is contained in:
1 parent
1833932f1c
commit
9757ae893e
12 files changed
+527
-53
No files matched your search
@@ -191,9 +191,15 @@ worker. It is **asynchronous**, so the gate stays free while either model thinks
|
||||
codegen is the primarily-cloud model, so it receives only the de-identified
|
||||
spec — never the user's request, question answers, or run output.
|
||||
4. **Fidelity gate** (`authoring:fidelity` SemIf accept/reconsider decision +
|
||||
static `integration_findings`): is the action real, or simulated? One
|
||||
corrective regen with the de-identified evidence bundle, then accept-with-badge
|
||||
(`unverified`) rather than hard-fail.
|
||||
static `integration_findings`): does the body contain a concrete,
|
||||
side-effecting operation that really performs its goal? The state carries the
|
||||
**whole** body (never a prefix) plus a deterministic operation inventory and
|
||||
the de-identified goal — never the raw request — and asks the positive
|
||||
question rather than asking the model to prove a negative. Because a decision
|
||||
ingests the body whole, generated artifacts are size-bounded
|
||||
(`max_body_chars`/`max_test_chars`, derived from the engine's context). One
|
||||
corrective regen with the de-identified evidence bundle (inventory + findings
|
||||
included), then accept with a trace rather than hard-fail.
|
||||
5. **Contract** (`parse_contract`): read from the body's own `CONTRACT`
|
||||
constant — a flat map of snake_case variable name → semantic description, for
|
||||
user input and SemIf only; `contract.json` is a persisted mirror.
|
||||
@@ -211,9 +217,9 @@ onto the new leaf. On failure the leaf stays a restartable stub. A whole new
|
||||
category runs the same chain deterministically:
|
||||
`create_category` → `create_skill` → async body → re-dispatch.
|
||||
|
||||
A rejected/simulated body is traced (`fidelity_review`), badged `unverified`,
|
||||
and never blocks authoring. Codegen failures (including timeouts) surface as a
|
||||
graceful stub and are retryable with `restart <category> <skill>`.
|
||||
A rejected/simulated body is traced (`fidelity_review`) and never blocks
|
||||
authoring. Codegen failures (including timeouts) surface as a graceful stub and
|
||||
are retryable with `restart <category> <skill>`.
|
||||
|
||||
### What each model sees
|
||||
|
||||
@@ -245,7 +251,7 @@ receives the user's request, question answers, or run output.
|
||||
| `assess:outcome` | `skill.py:311` | skill label + goal + resolved inputs + bounded action log + steps already taken | `done` / `continue` / `failed` |
|
||||
| `config:search` | `scheduler.py:1477` | skill + variable name + its semantic description | each candidate config key (+ `ask`) |
|
||||
| `config:record` | `skill.py:112` | skill + `variable = value` | `record` / `ask_again` |
|
||||
| `authoring:fidelity` | `scheduler.py:1311` | skill, request, description, `INTEGRATION` JSON, static findings, first 4000 chars of body | `accept` / `reconsider` |
|
||||
| `authoring:fidelity` | `scheduler.py:1836` | skill, goal, description, `INTEGRATION` JSON, static findings, operation inventory, **whole** body (no raw request) | `accept` / `reconsider` |
|
||||
| `repair:choice` | `scheduler.py:658` | skill, request, integration, truncated failure | `retry` / `repair_skill` / `ask_user` / `no_repair` |
|
||||
| degeneration watchdog¹ | `cli.py:128` | `[codegen <model>]` + last 2000 chars of the stream | `continue` / `stop` |
|
||||
| `codegen_regen`¹ | `cli.py:165` | `[testgen <model>]` + last 1200 chars of the test error | `regen_code` / `regen_test` / `regen_contract` |
|
||||
|
||||
Reference in new issue
Block a user