Skip to content

mikeparcewski/wicked-garden / skills/domain-extractor

wicked-garden-domain-extractor

Verified

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). This is a substrate, not a modernization tool: the `modernize` archetype DERIVES from it, and build / migrate / review / specify / explore can consume the same domain model — none OWN it. Use when: dispatched by wicked-garden-domain to mine the business_rules of a codebase (or a module); "extract the domain rules", "what does this system require", building the requirements half of a domain model. NOT for grouping into domains (that is domain-modeler) or judging coverage (that is domain-coverage — a seat-distinct evaluator).

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. With "units": [] and a non-empty assign list, this assignment page needs no harness run; write the rules file with "rules": [] and the assignments, plus business_domains when propose: true. Follow "Business domains first" below, then check the file with wicked-garden run scripts/domain/extract_loop.py --check-rules .wicked/domain/rules.json --worklist .wicked/domain/worklist.json and fix what it names. With "units": [] and an empty assign list, write the rules file with "rules": [] and no other entries, and say so in one line. The engine fails the extract step when the file is missing or older than this page, so always write it. The host finishes that page ("map already current … nothing to extract") and refuses a missing file for a page that had units. 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.

Business domains first. Read the worklist's business_domains block. When it says propose: true, propose the repository's business domains as the wicked-garden-domain-modeler skill's "Business domains" section says, and write them before anything else as the rules file {"schema": "wicked-garden/domain-rules@1", "seat": "<your seat>", "business_domains": [...], "rules": []}. When it carries a catalog, pick from it and propose nothing. Either way, give each rule you state a "domain": "<id>" and "domain_confidence": <0..1> (leave both out when no area fits; a unit marked changed_since_build keeps the domain it had unless you pick one), and answer every entry of the worklist's assign list in the file's top-level "assignments": [{"symbol_id", "domain", "confidence"}]. The harness below keeps both top-level lists when it rewrites the file and gives its model the domain list. Choose each domain pick and assignment per symbol from that symbol's source. Never use a script or a path/directory mapping to assign domains. A file's units can serve different business areas. Set domain confidence from that symbol's read; never stamp one value on the page.

  1. 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.
  2. 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": [...]} (plus the business_domains / assignments lists above) 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, and "domain" + "domain_confidence" — no other keys. Then check it (it also checks the domains): 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 or a cut-off slice is low, and the host records it as a placeholder; a comment alone never sets a statement, so leave it empty. 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. State what the body enforces. State what the unit's body enforces: its values, limits, defaults, and what it does with each parameter. The statement comes from what the body does; a comment, docstring or parameter name that disagrees with the body never sets it (a docstring that says batches of 10 while the body passes 100 is a rule about 100). An abstract method or stub (a body of only a docstring, ..., pass, or raise NotImplementedError) takes an empty statement. When a test or a caller shows the code is wrong, state the intended requirement. State what the unit is meant to do, 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"). Say code_meets false only when a test or a caller shows the intended behaviour; a comment alone is never enough. 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.
  3. 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.
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall