agentleFS
mikeparcewskimikeparcewski/wicked-garden/skills/domain-extractor/SKILL.md

wicked-garden-domain-extractor

Skill9 starsChanged 7 months agoMITView on GitHub

Rule-extraction worker for the FOUNDATIONAL domain-model capability. Mines testable business rules from a codebase — each with a numeric confidence and a provenance{source, ref, source_kinds} — and annotates them into the estate store so wicked-core can build the domain-model requirements graph (coverage-gated).

  • Installs packages

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If none of these is available, or Python 3 is missing, skip the script-backed step, say so, and follow the manual alternative where one is …

    line 34
  2. Very specific:

    When .wicked/domain/worklist.json exists in your working directory, the run's host step extract-prepare wrote it: behaviours that are not …

    line 39
  3. Very specific:

    Run the harness in file mode (one Bash call.

    line 54
  4. Very specific:

    Read each unit's source and write each statement yourself: Create and change the file with your file write and edit tools, never with an …

    line 73
  5. Distinctive:

    Leave a statement empty for pure plumbing too (a re-export, a trivial getter, a pass-through wrapper, formatting), never because the rule …

    line 84
  6. Very specific:

    Every output is validated — a real SymbolId, numeric confidence ∈ [0,1] (ISS-11 hard-fail), grounded provenance{source,ref,source_kinds} — …

    line 172
  7. Very specific:

    Every requirement has business_rules with minItems 1.

    line 186
  8. Very specific:

    Every business rule: numeric confidence ∈ [0,1] and provenance{source, ref, source_kinds}.

    line 187

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Domain Extractor

You extract testable business rules from a codebase — what the business requires, not how the code does it — and annotate them into the estate store, so wicked-core builds the domain-model requirements graph (coverage-gated, fail-closed below the configured minimum: by default, 80% of the behaviours in product code stated as real requirements). You are the Creator role; a seat-distinct evaluator (domain-coverage) judges coverage, never you.

Runtime

Script-backed steps use the wicked-garden launcher: wicked-garden run <plugin-root-relative path, e.g. scripts/…> [args]. It is on PATH after npm i -g wicked-garden; otherwise use npx wicked-garden run …; inside a wicked-crew run it is "$WICKED_GARDEN_ROOT/scripts/wicked-garden". If none of these is available, or Python 3 is missing, skip the script-backed step, say so, and follow the manual alternative where one is given next to it — never invent the script's output. Relative paths in this skill are relative to the directory that contains this SKILL.md.

Inside a crew run: the worklist is in your worktree (file mode)

When .wicked/domain/worklist.json exists in your working directory, the run's host step extract-prepare wrote it: behaviours that are not real requirements yet (the unmapped ones, then placeholders an earlier page left empty or under the confidence threshold, then mapped behaviours whose code changed since the map was built, marked changed_since_build with their prior_statement), hub-first, each framed with its source slice and neighbours. Your seat cannot write the store and needs no wicked-core or wicked-estate — the host step extract-apply checks and writes what you produce. Do this, and only this:

  1. A worklist with no units ("units": []): there is nothing to state. Write no file and say so in one line. The host's apply step reads its own record of the page it prepared and finishes it ("map already current … nothing to extract"); it applies no rules file for such a page. It refuses a missing file for a page that had units, so never leave the file out when the worklist has any. A review that sends back a page with no units asks for work the host cannot apply: say so plainly, and the person decides at the step's gate.
  2. Run the harness in file mode (one Bash call; it stops inside its budget):
    wicked-garden run scripts/domain/extract_loop.py --worklist .wicked/domain/worklist.json \
      --rules-out .wicked/domain/rules.json --time-budget 480
    It states each unit's rule with the bounded rule model and writes .wicked/domain/rules.json. If it says the budget was reached, run the same command again while your turns allow — it resumes after the units already stated.
  3. Exit 2, "no rule model in this seat": state the rules yourself. For each unit of the worklist, in order, add one entry to .wicked/domain/rules.json — the whole file is {"schema": "wicked-garden/domain-rules@1", "seat": "<a plain token: $WICKED_RUN_AGENT, or claude / codex / pi / copilot>", "rules": [...]} and each entry is exactly {"symbol_id": "<the unit's id, verbatim>", "statement": "<the business rule, or \"\" when the source does not let you state one>", "confidence": <0..1>, "provenance": {"source": "<module>", "ref": "<the symbol_id>", "source_kinds": ["code-body"|"type-def"|"comment"|"doc"]}}, plus "code_meets": false, "mismatch": "<one line>" only when the code does not meet the requirement — no other keys. Then check it: wicked-garden run scripts/domain/extract_loop.py --check-rules .wicked/domain/rules.json --worklist .wicked/domain/worklist.json and fix what it names. Read each unit's source and write each statement yourself. Create and change the file with your file write and edit tools, never with an inline interpreter (python3 - <<…, node -e …): the seat's input governance refuses that. A script that composes statements from names or slices is wrong anyway: it describes code, and the page's review fails it. State what the business requires (who may do what, what must hold, what is refused and why, what a caller must supply, what a result must carry), not what the function does. Most product code encodes a rule: state it. A check, a refusal, a limit, a default, an ordering, a permission or a state change is a rule even when it is small. An interface or type is a rule only when the type itself encodes a constraint the business relies on (a closed set of values, a limit, a required field whose comment says what it means); a plain list of fields describes code, so leave it empty. Leave a statement empty for pure plumbing too (a re-export, a trivial getter, a pass-through wrapper, formatting), never because the rule is small or obvious: the page's review lists an empty statement whose source shows a rule as a missed rule, and fails a page that leaves most of the units whose source shows a rule empty, or whose statements mostly describe code (a page of mostly plain types and plumbing, left empty, is fine). A restated shape is never a rule at any confidence: leave it empty. A unit marked changed_since_build was mapped before: its prior_statement (and any old mismatch) may be out of date, so state it, and judge code_meets, against the code as it is now. Only a statement the host resolves replaces its rule; an empty, invalid or low-confidence one keeps the earlier rule (never a placeholder). Set each confidence by how directly the source supports the rule: a constraint visible in the unit's full definition (enforced in its body, or encoded in its type: a closed set, a limit, a documented required field) is high (0.85 or more); a rule only guessed from a name, a comment alone or a cut-off slice is low, and the host records it as a placeholder. Judge each statement's confidence on its own; never stamp one value on the whole page (equal values are fine where the support is equal). Only real requirements count toward the target; a placeholder is shown, never counted. When the code is wrong, state the requirement anyway. State what the unit is meant to do (its doc comment, its tests, its name and callers agree), with your confidence in that requirement, and add "code_meets": false and a one-line "mismatch" saying how the code departs (e.g. "the loop starts at index 1, so the first element is skipped"), but only when a doc comment, a test or a caller shows the intended requirement; a unit whose intent is unclear still gets an empty statement and no mismatch. A unit whose intent is shown that way and whose own code is right, but whose result is wrong because a callee it relies on departs, inherits that mismatch: mark it "code_meets": false too, with a mismatch naming the callee (e.g. "inherits sum's skipped first element, so the numerator omits the first element"): say how the code departs, not which way the result is off, which can depend on the input. Never restate the bug as the requirement, and never lower the confidence because the code is wrong: the requirement counts, and the mismatch is shown beside it as a finding.
  4. Report how many units you stated. Write no other file, and never try to reach the store. The host refuses anything outside the schema, and any entry whose symbol the store does not report unmapped or as a placeholder (or that the run's own host-side record does not list as changed since the map was built: the worklist's mark is framing, not permission), or whose file the repository does not track; it re-judges the rest itself and writes it as extract-loop (the seat a file names is reported, never trusted).

Outside a run: you DRIVE the deterministic harness — you don't loop yourself

A single agent (max-turns 12) cannot iterate thousands of nodes. Completeness is a deterministic loop in code (scripts/domain/extract_loop.py); you are its driver, not the loop. With wicked-core, wicked-estate and a writable store at hand (no worklist file in your working directory), your whole job:

  1. Run the harness (one Bash call):
    wicked-garden run scripts/domain/extract_loop.py --db "<estate-store>" --time-budget 780
    It seeds its worklist from wicked-core coverage's own unaccounted_nodes — the SAME authority the coverage gate re-derives against, so there is no denominator drift — and takes it hub-first: the most central symbols (estate's PageRank, wicked-estate rank) first, then their neighbours and onward by graph distance, so the load-bearing behaviour is mapped first. It loops every behavior-bearing node, calls the bounded per-node model for the one thing code can't do (stating the rule), validates each returned rule, and writes annotate + semantics. Every node terminates RESOLVED-or-RISK (the RISK-floor invariant), so given enough passes every behaviour is accounted for. Only RESOLVED ones are real requirements; a RISK one is a placeholder, which the minimum never counts.
  2. Watch stderr (coverage=… unaccounted=… processed=…; coverage there is the accounted share, placeholders included). If it exits within budget with unaccounted > 0, re-invoke it to resume — the shrunk worklist re-seeds and the hub-first order is re-derived, so work resumes at the frontier and never repeats (a later run continues the same way). The graph is built once real requirements reach the configured minimum (the repository's own, else WICKED_REQUIREMENTS_MIN_COVERAGE_PCT, default 80) — check it with wicked-core coverage --db "<estate-store>" --min-coverage-pct (exit 0 at or above it; below, it prints "N% real requirements, minimum M% (R of B behaviours; P placeholders, U unmapped)" and exits 3). Keep re-invoking while unaccounted shrinks; once the check passes, more is better but enough, so stop when your budget is spent. Always stop when unaccounted hits 0 or stops shrinking. This mode maps unmapped behaviours only: it never revisits a placeholder, so a share held below the minimum by placeholders needs a crew domain-extraction run, whose pages frame them again. What you mapped stays in the store for the next run either way. A WARNING: … annotation node_syms no longer exist line is the estate id-scheme migration signature — prior annotations are orphaned; see the migration section in wicked-garden-domain for the required re-run order.
  3. Never hand-annotate or assert a rule the harness RISK-flagged. The whole point is the deterministic RISK-floor + re-derived coverage — do not "help" by asserting an unvalidated rule.

Vault discipline (model-driven + deterministic)

Extraction is split exactly like the vault:

  • Deterministic backbone (record + verify): the harness owns enumeration, completeness, and a per-write read-back; coverage is re-derived COLD by the downstream domain-coverage phase (wicked-core coverage) — never trusted.
  • Model adjunct (analyze): the per-node rule statement is the ONE model call. Every output is validated — a real SymbolId, numeric confidence ∈ [0,1] (ISS-11 hard-fail), grounded provenance{source,ref,source_kinds} — before it counts, or it is RISK-flagged. Model-driven where judgment is needed; deterministic everywhere.

Config

  • WICKED_ESTATE_BIN / WICKED_CORE_BIN — the peer binaries (resolved by _clients; on a crew host WICKED_CORE_EXE, the engine's own CLI, is used when WICKED_CORE_BIN is unset).
  • WICKED_RULE_MODEL_BIN — the bounded per-node rule model (default claude -p). Set-but-empty is the kill-switch: no model, so only --dry-run (the deterministic stub) runs; file mode without --dry-run then exits 2 and you state the rules yourself.

Hard invariants (fail-closed — enforced by the harness + validator)

  1. Every requirement has business_rules with minItems 1.
  2. Every business rule: numeric confidence ∈ [0,1] and provenance{source, ref, source_kinds}.
  3. legacy_components[] is non-null, never dropped — the SymbolIds the requirement covers.
  4. disposition ∈ {keep, modify, drop, new}; a drop needs a disposition_reason.
  5. Rule ids: RULE-/VAL-/ERR- + 3–6 zero-padded digits, unique within a requirement.
  6. Facts REFERENCE SymbolIds; never embed code/file/line.
  7. metadata.schema_version ∈ {"1.0.0", "1.1.0"} (1.1.0 adds the optional coverage and corroboration fields core emits).

Depth

  • the wicked-garden-domain skill's refs/domain-model-emit.md — field map + the 7 invariants.
  • the wicked-garden-domain skill's refs/extraction-flow.md — the estate/core CLI surface + the _clients.py seam.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.