Pattern Mining
Decide whether repeated code demonstrates a reusable rule or only a plausible
hypothesis. Similar names and syntax are not enough; the abstraction must
survive examples it was not designed around.
Constraints
- To prevent lineage copies from faking recurrence, use independently
implemented exemplars with repository anchors.
- Because the candidate must generalize, form it without seeing the holdout and
back-apply every holdout-driven refinement.
- To keep weak evidence from becoming architecture, route hypotheses to
no-action; only a fully proven promotion may reach operationalize.
Workflow
- State the candidate pattern and collect independently implemented
exemplars with repository anchors. Use
research when coverage is unclear.
- From the exemplars, separate required invariants, legitimate variation
points, and incidental similarity.
- Require at least three distinct exemplars before promotion is possible.
Form the candidate abstraction without using the holdout.
- Test it against every exemplar, then a separate holdout. Back-apply the
refined abstraction to the original exemplars so the holdout fix cannot
silently break them.
- Emit
outcome: promote only when the exemplar floor, holdout, and
back-application all pass. Route that evidence to operationalize, which
decides whether the eventual shape is a skill, gate, library, template, or
no action.
- Otherwise emit
outcome: hypothesis with route: no-action. Keep the
evidence bounded and name what additional observation would retest it.
Output Specification
- Artifact directory:
.agents/patterns/<run-id>/
- Filename convention:
pattern-mining.json
- Format:
pattern-mining.v1 JSON containing the outcome, distinct
exemplars, invariants, variations, incidental details, holdout result,
back-application result, and route.
- Validation command:
skills/pattern-mining/scripts/validate-output.sh <pattern-mining.json>
- Downstream handoff: pass a validated
promote artifact to
operationalize; retain a validated hypothesis artifact as bounded
evidence with route: no-action.
Promotion requires at least three distinct exemplars, one separate passing
holdout, successful back-application, and at least one invariant. Any weaker
packet remains a hypothesis and cannot route to reusable packaging.
The validator is the machine boundary:
skills/pattern-mining/scripts/validate-output.sh <pattern.json>
This skill owns evidence for the pattern. It never creates the reusable
artifact itself and never promotes a failed or untested holdout.
Executable behavior:
references/pattern-mining.feature.
Quality
- Exemplars are independent and repository-anchored; copied implementations do
not inflate the evidence floor.
- Invariants, legitimate variations, and incidental similarities stay distinct
through holdout testing and back-application.
- The named validator passes before a promotion reaches
operationalize or a
hypothesis is retained as no-action evidence.
Do not
- Count copies from one implementation lineage as independent exemplars.
- Hide variation by calling it incidental.
- Route a hypothesis directly to a skill, rule, gate, or library.
1---2name: pattern-mining-23description: Test repeated implementation shapes against independent exemplars and a holdout before routing an earned abstraction. Triggers: "mine a recurring code pattern", "is this abstraction earned", "extract invariants from implementations".4---56# Pattern Mining78Decide whether repeated code demonstrates a reusable rule or only a plausible9hypothesis. Similar names and syntax are not enough; the abstraction must10survive examples it was not designed around.1112## Constraints1314- To prevent lineage copies from faking recurrence, use independently15 implemented exemplars with repository anchors.16- Because the candidate must generalize, form it without seeing the holdout and17 back-apply every holdout-driven refinement.18- To keep weak evidence from becoming architecture, route hypotheses to19 `no-action`; only a fully proven promotion may reach `operationalize`.2021## Workflow22231. State the candidate pattern and collect independently implemented24 exemplars with repository anchors. Use `research` when coverage is unclear.252. From the exemplars, separate required invariants, legitimate variation26 points, and incidental similarity.273. Require at least three distinct exemplars before promotion is possible.28 Form the candidate abstraction without using the holdout.294. Test it against every exemplar, then a separate holdout. Back-apply the30 refined abstraction to the original exemplars so the holdout fix cannot31 silently break them.325. Emit `outcome: promote` only when the exemplar floor, holdout, and33 back-application all pass. Route that evidence to `operationalize`, which34 decides whether the eventual shape is a skill, gate, library, template, or35 no action.366. Otherwise emit `outcome: hypothesis` with `route: no-action`. Keep the37 evidence bounded and name what additional observation would retest it.3839## Output Specification4041- **Artifact directory:** `.agents/patterns/<run-id>/`42- **Filename convention:** `pattern-mining.json`43- **Format:** `pattern-mining.v1` JSON containing the outcome, distinct44 exemplars, invariants, variations, incidental details, holdout result,45 back-application result, and route.46- **Validation command:** `skills/pattern-mining/scripts/validate-output.sh <pattern-mining.json>`47- **Downstream handoff:** pass a validated `promote` artifact to48 `operationalize`; retain a validated `hypothesis` artifact as bounded49 evidence with `route: no-action`.5051Promotion requires at least three distinct exemplars, one separate passing52holdout, successful back-application, and at least one invariant. Any weaker53packet remains a hypothesis and cannot route to reusable packaging.5455The validator is the machine boundary:5657```bash58skills/pattern-mining/scripts/validate-output.sh <pattern.json>59```6061This skill owns evidence for the pattern. It never creates the reusable62artifact itself and never promotes a failed or untested holdout.6364Executable behavior:65[references/pattern-mining.feature](references/pattern-mining.feature).6667## Quality6869- Exemplars are independent and repository-anchored; copied implementations do70 not inflate the evidence floor.71- Invariants, legitimate variations, and incidental similarities stay distinct72 through holdout testing and back-application.73- The named validator passes before a promotion reaches `operationalize` or a74 hypothesis is retained as `no-action` evidence.7576## Do not7778- Count copies from one implementation lineage as independent exemplars.79- Hide variation by calling it incidental.80- Route a hypothesis directly to a skill, rule, gate, or library.