docs: align CODEGEN.md/TESTGEN.md with the codebase
CODEGEN.md: - replace the stale "Manifest schema" (allowed_inputs/actions/cost_budget/ decision_log_ref, a dotted leaf name) with the real registry shape and note the body writer does not author it - document ctx.timers (and that ctx.admin is built-in-only) and the request.meta resume cache, both used by the authoritative seed set - correct acceptance criteria: INTEGRATION is not hard-rejected (inferred / fidelity-gated); note which items the parser actually enforces; compile -> ast.parse - fix the SemIf URL, the structured-state claim (state is a string here), the config_vars/CONTRACT relationship, and defer llm_bridge_* names to the catalog TESTGEN.md: - separate the only static check (ast.parse) from execution (exit 0); state that stdlib-only/inline-fixtures/hermeticity are required but not verified - clarify contract.json is handed to the test writer as context README.md: fix the same stale manifest field list. tests/test_codegen.py: add guards for the runtime surface and against the stale manifest fields returning.
This commit is contained in:
1 parent
dff4849947
commit
e64354e78d
4 files changed
+105
-45
No files matched your search
+72
-35
@@ -9,12 +9,12 @@ contract, `TESTGEN.md`. This file is about the runnable body only.
|
||||
## What a skill is
|
||||
|
||||
Semif-agent is an end-user application: an everyday person asks it to do a task,
|
||||
and it does that task using a combination of user-provided data and a catalog of basic services known as bridges. A skill is the thing that performs one of those tasks: it is the leaf in the skill tree that the agent navigates to when it has resolved a request to a single, concrete action. Navigation is performed by an llm-based classification engine known as SemIf.
|
||||
and it does that task using a combination of native python modules, user-provided data and a catalog of basic services known as bridges. A skill is the thing that performs one of those tasks: it is the leaf in the skill tree that the agent navigates to when it has resolved a request to a single, concrete action. Navigation is performed by an llm-based decision engine known as SemIf.
|
||||
|
||||
A skill is three things:
|
||||
|
||||
1. **A manifest** — the registry entry that makes it navigable and describes
|
||||
what it does.
|
||||
1. **A registry entry** — its navigable `name` + `description`, recorded in
|
||||
`data/categories.json` and mirrored in the running tree.
|
||||
2. **A code body** — a runnable Python module implementing a single `act`
|
||||
phase against a real service.
|
||||
3. **A declaration** — the `INTEGRATION` constant (which real system the body
|
||||
@@ -50,7 +50,10 @@ It performs one forward pass and reads the probabilities of the declared answer
|
||||
tokens directly. It returns a probability for each option — no sentence, no
|
||||
JSON, no decoding loop, nothing to parse. In effect it is a semantic `if`:
|
||||
software asks a yes/no/which question in natural language and gets back a typed,
|
||||
thresholdable number. The `state` may also be a nonempty JSON object or array.
|
||||
thresholdable number. In this agent the `state` is always a string
|
||||
(`request.text`, or the query plus a list of candidates); the broader SemIf
|
||||
project also accepts a nonempty JSON object or array as state, but a body here
|
||||
must pass a string.
|
||||
|
||||
The whole point is that the **question and options arrive with the request**.
|
||||
Routing, selection, and assessment are not baked into the model or the prompt;
|
||||
@@ -66,7 +69,7 @@ code.
|
||||
|
||||
### SemIf's feature set
|
||||
|
||||
SemIf (<https://github.com/TheoLeeCJ/SemIf-OpenJev>) is a broader project than
|
||||
SemIf (<https://github.com/TheoLeeCJ/SemIf>) is a broader project than
|
||||
the one call this agent makes. Its full feature set:
|
||||
|
||||
- **Runtime-defined decisions** — state, criterion, and option descriptions are
|
||||
@@ -161,33 +164,48 @@ Rules:
|
||||
the skill's confidence threshold, otherwise fall back to the configured default
|
||||
(see `calendar.create_event` and `simplex.next_message`).
|
||||
- **Use the LLM bridge for text, not for routing or assessment.** Generated text
|
||||
goes through the LLM bridge (`llm_bridge_url`, `llm_bridge_token`) — a generic
|
||||
`POST /chat` — never by speaking a model's protocol directly. Keep the model
|
||||
extractive and bounded (see how `calendar.create_event` asks only for a title
|
||||
and description), and report a real failure when the bridge is down rather than
|
||||
guessing the text.
|
||||
goes through the LLM bridge — a generic `POST /chat` whose base URL, token,
|
||||
and endpoint shapes are in the bridge catalog injected below — never by
|
||||
speaking a model's protocol directly. Keep the model extractive and bounded
|
||||
(see how `calendar.create_event` asks only for a title and description), and
|
||||
report a real failure when the bridge is down rather than guessing the text.
|
||||
- **Never blur the boundaries.** SemIf never generates; an LLM never routes,
|
||||
selects, or assesses; deterministic code never invents a value it cannot
|
||||
observe. A request input is resolved by SemIf, not by substring matching by
|
||||
hand; a title is generated by the LLM, not assembled by string concatenation
|
||||
when it should be written; a date is parsed by code, not asked of a model.
|
||||
|
||||
## Manifest schema
|
||||
## The registry entry
|
||||
|
||||
Registered in `data/categories.json` (and mirrored in the running tree). Fields:
|
||||
The body writer does **not** author a manifest. The `llm` provider authors the
|
||||
leaf's `name` and `description`, and the scheduler records them in
|
||||
`data/categories.json` (mirrored in the running tree). You are told the chosen
|
||||
`name` and `description` in the prompt; use them, and never invent or rename the
|
||||
skill.
|
||||
|
||||
| Field | Meaning |
|
||||
| -------------------- | -------------------------------------------------------------------- |
|
||||
| `name` | `category.skill` dotted snake_case id. Lowercase letters, digits, `_` and `.` only (`[a-z0-9_]+(?:\.[a-z0-9_]+)*`). Single purpose. |
|
||||
| `category` | The top-level category bucket the skill lives under. |
|
||||
| `description` | One to two sentences: what the skill does, for navigation. |
|
||||
| `allowed_inputs` | What the skill accepts / needs as input context. |
|
||||
| `actions` | The concrete actions the skill takes. |
|
||||
| `cost_budget` | Relative budget for one run; a run that exceeds it fails fast. |
|
||||
| `decision_log_ref` | Reference to the decision rows this skill logged during a run. |
|
||||
The registry is a map of category -> bucket:
|
||||
|
||||
Only `name` and `description` are required for a stub; the rest fill in as the
|
||||
skill is exercised.
|
||||
```json
|
||||
{
|
||||
"<category>": {
|
||||
"description": "<one to two sentences: the bucket's purpose>",
|
||||
"skills": [
|
||||
{
|
||||
"name": "<leaf_name>",
|
||||
"description": "<what this leaf does, for navigation>",
|
||||
"request_text": "<the originating request, optional>",
|
||||
"requirements": {"<question>": "<answer>"}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- A leaf `name` is a single snake_case token (`[a-z0-9_]+(?:\.[a-z0-9_]+)*`),
|
||||
not dotted with the category; the category is the key it lives under, and the
|
||||
runner joins them as `category.name` only when it builds the run summary.
|
||||
- `request_text` and `requirements` are recorded by the scheduler so a stub can
|
||||
be re-driven later; the body never sets them.
|
||||
|
||||
## Code body contract
|
||||
|
||||
@@ -261,8 +279,12 @@ def act(ctx, request) -> ActionResult:
|
||||
"""Perform the real action and return the result + new state."""
|
||||
```
|
||||
|
||||
- `ctx` is an `ActionContext` with `ctx.engine` (the real SemIf engine) and
|
||||
`ctx.config` (the resolved values for this skill, including its own config).
|
||||
- `ctx` is an `ActionContext` with `ctx.engine` (the real SemIf engine),
|
||||
`ctx.config` (the resolved values for this skill, including its own config),
|
||||
and `ctx.timers` (the in-process timer/alarm service — use it to schedule a
|
||||
notification, as the `time.set_timer` and `time.set_alarm` seeds do).
|
||||
`ctx.admin` exists for the built-in housekeeping meta skills only; an ordinary
|
||||
body must never touch it.
|
||||
- `request` is the `Request` being handled.
|
||||
- `ActionResult(action_log: str, new_state: str, needs_input: str | None = None,
|
||||
decisions: list = [])` is imported from `semif_agent.skills`; return that exact
|
||||
@@ -363,8 +385,10 @@ INTEGRATION = {
|
||||
(`http|caldav|imap|smtp|pop|subprocess|file|compute`). `compute` is only for
|
||||
skills that perform no external action at all (pure analysis/formatting); an
|
||||
action skill must not use it.
|
||||
- `config_vars` — the `ctx.config` keys the body reads for this integration.
|
||||
Empty list allowed for `compute`.
|
||||
- `config_vars` — the `ctx.config` keys the body reads for this integration. In
|
||||
the committed seeds this is exactly the body's `CONTRACT` key set; an empty
|
||||
list is allowed for `compute`. Declaring a variable the body never reads is a
|
||||
mismatch the fidelity check flags.
|
||||
|
||||
The auto-run test is a hermetic mechanics check and never exercises the live
|
||||
service, so this declaration is how the agent knows what the skill was built to
|
||||
@@ -488,10 +512,14 @@ Rules:
|
||||
pause the human's answer arrives on `request.user_input` and `act` is invoked
|
||||
again from the beginning — re-derive the query and config, consume
|
||||
`request.user_input`, and do not re-ask a question you already have an answer
|
||||
for.
|
||||
for. `request.meta` is a scratch dict carried on the same request across the
|
||||
pause, so a body can cache a computed value or an already-collected answer
|
||||
there and reuse it on the resume pass instead of recomputing or re-asking —
|
||||
see how `calendar.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.
|
||||
- **Names match the manifest.** The module is imported as its manifest name;
|
||||
the function is `act` exactly.
|
||||
- **The function is `act` exactly.** The module is imported under its registered
|
||||
leaf name; the entry point is a module-level `act(ctx, request)`.
|
||||
|
||||
## Bridge services
|
||||
|
||||
@@ -562,11 +590,12 @@ Rules:
|
||||
|
||||
A generated skill is accepted only if:
|
||||
|
||||
1. It compiles (`compile(..., "exec")` succeeds), imports every name it uses
|
||||
(`ActionResult` from `semif_agent.skills`; `DecisionRequest`/`Option` from
|
||||
`semif_agent.decisions` only when it actually builds a sub-decision; each
|
||||
stdlib module it calls — no `NameError` at run time), and defines `act`.
|
||||
2. Its `name` matches the manifest regex and its `category` is given.
|
||||
1. It parses as Python (`ast.parse` succeeds), defines a module-level `act`
|
||||
function, and imports every name it uses (`ActionResult` from
|
||||
`semif_agent.skills`; `DecisionRequest`/`Option` from `semif_agent.decisions`
|
||||
only when it actually builds a sub-decision; each stdlib module it calls — no
|
||||
`NameError` at run time).
|
||||
2. Its `name` matches the leaf-name regex and its `category` is given.
|
||||
3. Its body imports nothing outside the stdlib and the agent package.
|
||||
4. It uses `ctx.engine` (never mocks) and returns proper `ActionResult` types.
|
||||
5. It is single-purpose and does not duplicate an existing category leaf.
|
||||
@@ -590,3 +619,11 @@ 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.
|
||||
|
||||
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
|
||||
`INTEGRATION` (#11) is inferred and the body is accepted badged `unverified`, a
|
||||
third-party import (#3) only fails when the module is actually imported, and
|
||||
import-time work (#12) only shows up when it runs. The fidelity gate rewrites a
|
||||
body once for these, then accepts it — so treat every item as required, not
|
||||
optional.
|
||||
Reference in new issue
Block a user