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:
gabby committed 2026-10-11 07:33:03 +00:00
1 parent 1833932f1c
commit 9757ae893e
12 files changed
+527 -53

No files matched your search

+9
View File
@@ -550,6 +550,12 @@ therefore run as a later step of a chain.
see how `nextcloud.create_event` caches the extracted title/description and the
answers it collected.
- **Fail fast on budget.** Keep the work small; do not loop or retry in code.
- **Keep the body small — it is ingested whole.** The fidelity decision reads
the *entire* body, so a body that exceeds the engine's context budget is
rejected outright (the pipeline retries once with a "make it shorter"
instruction). Delegate protocol details to a bridge instead of hand-rolling a
client, and keep `act` to one purpose; a long body is a signal that the
integration belongs in a bridge.
- **The function is `act` exactly.** The module is imported under its registered
leaf name; the entry point is a module-level `act(ctx, request)`.
@@ -651,6 +657,9 @@ A generated skill is accepted only if:
13. If it is a messaging skill, it uses a bridge service over HTTP (never a
service's native protocol), resolves recipients with a SemIf sub-decision,
and sends only on explicit user intent.
14. It is small enough to be ingested whole by the fidelity decision (a body
over the engine's artifact budget is rejected as too long) — delegate
protocol details to a bridge rather than hand-rolling them.
Items 1 and 7 are hard checks in the parser (`parse_skill_body`) and reject the
body outright. The rest are not statically rejected: a missing or inconsistent