The meta-skill that builds and improves all your skills, including itself. Watches your work sessions (autonomous or human-led), captures patterns, corrections and judgement calls, and turns them into skill improvements and new skill candidates for your review. Practical application of the Augmented Expertise methodology. Open source: CC BY 4.0.
Python agent-skillsai-skillsaugmented-expertiseawesome-skillsclaudeclaude-codeclaude-code-skillclaude-code-skillsclaude-coworkclaude-skillsmeta-skillrebelyticsskill-automationskill-builderskill-creationskill-improvementskill-managementskills
migrate-log.py: reject dropped override keys, flag skills in qualifiers
Eoghan Hennc09aaeb13b81
diff --git a/references/migration.md b/references/migration.mdindex 4aa408e..3d709fb 100644--- a/references/migration.md+++ b/references/migration.md@@ -38,7 +38,9 @@ Two rules protect the fields the format exists to make reliable:for hundreds of archived entries in testing.- **Ambiguity is flagged, never guessed.** Anything the parser is notconfident about — a missing status, a skill name it cannot parse, a- qualifier that could apply to one name or a whole group — is written+ qualifier that could apply to one name or a whole group, a qualifier+ that names another known skill (`skill-in-qualifier`, with+ `--known-skills`) — is writteninto the file as `migration_note: "needs review: …"` and listed in thereport. You resolve those by hand or, better, through an overrides fileso the run stays reproducible.@@ -104,16 +106,32 @@ it can be the Microsoft Store alias), use `py -3`.Keys starting with `_` are bookkeeping; every other key overwrites thatfrontmatter field. `_reason` is recorded in the file as- `migration_override` so the decision survives.+ `migration_override` so the decision survives. The fields an override+ can set are the ones the script writes: `skill`, `proposes_skill` and+ `target_file` (lists of strings); `title`, `status`, `type`, `area`,+ `date`, `session_context`, `resolved`, `resolution`, `status_note`,+ `reference`, `siblings_checked`, `parked_until` and+ `commands_verified` (strings); and `skill_qualifiers` (an object). Any+ other key, or a value of the wrong shape, stops the run with exit 2+ before a file is written, naming the entry and the key: an override+ that is accepted and never reaches the file is the one outcome the+ check exists to rule out.5. **Convert the live log:**```bashpython3 "<skill directory>/scripts/migrate-log.py" --convert skill-observations/log.md \--out skill-observations/observation-log \--id-floor-from skill-observations/archive \+ --known-skills "<skills directory>" \--overrides overrides.json```+ `<skills directory>` is the directory holding the installed skills,+ one folder each. Without it the script cannot tell a skill name from+ other words, so it can neither flag an unknown `skill:` entry nor a+ second skill named inside a qualifier; pass it to the step 3 check of+ the live log too.+6. **Verify twice: source fidelity, then target conformance.** Thereport's file count must equal the number of `### Observation` headersin `log.md`:@@ -124,13 +142,17 @@ it can be the Microsoft Store alias), use `py -3`.```Spot-check three files against their originals, including one that was- resolved and one that carried a qualifier. Then read the report's+ resolved and one that carried a qualifier, and compare every converted+ `skill:` line with its legacy `**Skill:**` header: a skill named only+ inside a qualifier is a target the scans, review buckets and family+ checks cannot see. Then read the report's`target conformance` block, and confirm it from the files: a convertedset is faithful to a source that never had `siblings_checked`, so every- file lacks it, and nothing but the next review's sibling backfill will- add it. Enumerate the fields from the target's own definition (SKILL.md,- File format), never from the mapping table above — a field absent from- the table is indistinguishable from one absent from the schema:+ file lacks it unless an override set it, and nothing but the next+ review's sibling backfill will add it. Enumerate the fields from the+ target's own definition (SKILL.md, File format), never from the mapping+ table above — a field absent from the table is indistinguishable from+ one absent from the schema:```basho="skill-observations/observation-log"diff --git a/scripts/migrate-log.py b/scripts/migrate-log.pyindex 23aeb60..7dab833 100644--- a/scripts/migrate-log.py+++ b/scripts/migrate-log.py@@ -14,7 +14,11 @@ Usage# convert an active log into a target directorypython3 migrate-log.py --convert log.md --out observation-log/ \- [--id-floor-from archive/]+ [--id-floor-from archive/] [--known-skills <skills dir>] [--overrides ov.json]++Exit status: 0 on success; 2 when the overrides file sets a key the output+cannot carry (OVERRIDE_KEYS) or a value of the wrong shape, or when+--known-skills is not a directory — named, and before any file is written.Design notes------------@@ -62,8 +66,20 @@ REVIEW_FLAGS = {"duplicate-id","body-empty","date-not-iso",+ "skill-in-qualifier",}+# Keys an overrides file may set: exactly the fields render() writes. Any+# other key used to be stored on the record and silently dropped at write+# time, so an adopter's fix was in the input, absent from the output, and+# nothing in between said so. Value shapes are checked too: a string where+# a list belongs was rendered one character per entry.+OVERRIDE_LIST_KEYS = {"skill", "proposes_skill", "target_file"}+OVERRIDE_TEXT_KEYS = {"title", "status", "type", "area", "date", "session_context",+ "resolved", "resolution", "status_note", "reference",+ "siblings_checked", "parked_until", "commands_verified"}+OVERRIDE_KEYS = OVERRIDE_LIST_KEYS | OVERRIDE_TEXT_KEYS | {"skill_qualifiers"}+# Fields the target format requires on every file (SKILL.md, File format).# Reported, never fabricated: a placeholder would hide the missing judgement# the field exists to make visible.@@ -219,6 +235,18 @@ ABSORB_RE = re.compile(r"([a-z0-9][a-z0-9._-]*)", re.I)+def skills_in_text(text, known_skills, exclude=()):+ """Known skill names that appear as whole tokens in free text."""+ if not known_skills or not text:+ return []+ found = []+ for tok in re.findall(r"[A-Za-z0-9][A-Za-z0-9._:-]*[A-Za-z0-9]|[A-Za-z0-9]", text):+ for cand in (tok, tok.rsplit(":", 1)[-1]):+ if cand in known_skills and cand not in exclude and cand not in found:+ found.append(cand)+ return found++def parse_skill(raw, area, known_skills, flags):"""Return (skill_list, proposes_skill_list, area, qualifiers).@@ -246,6 +274,8 @@ def parse_skill(raw, area, known_skills, flags):absorbs = [am.group(1)]qual = Nonequals = {cand: qual} if qual else {}+ if qual and skills_in_text(qual, known_skills, exclude=absorbs + [cand]):+ flags.append("skill-in-qualifier")if not SKILL_NAME_RE.match(cand):flags.append("candidate-name-unparseable")return absorbs, [], area, {"_unparsed": [rest]}@@ -283,8 +313,16 @@ def parse_skill(raw, area, known_skills, flags):if gqual and len(subnames) > 1:quals.setdefault("_group", []).append(f"{body} -> ({gqual})")+ # A qualifier that names another known skill holds a target the `skill:`+ # list lacks — the field every scan, review bucket and family check+ # filters on. That needs a decision, so it is a review flag and the text+ # is never promoted into `area`, where it would vanish from every report.+ qual_text = " ".join(v if isinstance(v, str) else " ".join(v)+ for k, v in quals.items() if k != "_unparsed")+ if skills_in_text(qual_text, known_skills, exclude=names):+ flags.append("skill-in-qualifier")# clean single-skill case: promote the qualifier into an empty area field- if len(names) == 1 and not area and len(quals) == 1 and names[0] in quals:+ elif len(names) == 1 and not area and len(quals) == 1 and names[0] in quals:return names, [], quals[names[0]], {}# An unparseable name is already flagged above; the qualifier flag is# for genuine qualifiers, so do not raise it a second time for the same@@ -353,6 +391,10 @@ def render(rec):fm.append("skill: [" + ", ".join(y(s) for s in rec["skill"]) + "]")if rec["proposes_skill"]:fm.append("proposes_skill: [" + ", ".join(y(c) for c in rec["proposes_skill"]) + "]")+ if rec.get("target_file"):+ fm.append("target_file: [" + ", ".join(y(t) for t in rec["target_file"]) + "]")+ if rec.get("siblings_checked"):+ fm.append(f"siblings_checked: {y(rec['siblings_checked'])}")if rec["area"]:fm.append(f"area: {y(rec['area'])}")if rec["date"]:@@ -363,12 +405,16 @@ def render(rec):fm.append(f"resolved: {rec['resolved']}")elif rec["resolved_hint"]:fm.append(f"resolved: null # candidate from body text: {rec['resolved_hint']} — unconfirmed")+ if rec.get("parked_until"):+ fm.append(f"parked_until: {y(rec['parked_until'])}")if rec["resolution"]:fm.append(f"resolution: {y(rec['resolution'])}")if rec.get("status_note"):fm.append(f"status_note: {y(rec['status_note'])}")if rec["reference"]:fm.append(f"reference: {y(rec['reference'])}")+ if rec.get("commands_verified"):+ fm.append(f"commands_verified: {y(rec['commands_verified'])}")if rec["skill_qualifiers"]:fm.append("skill_qualifiers:")for k, v in rec["skill_qualifiers"].items():@@ -424,14 +470,44 @@ def main():args = ap.parse_args()known = set()- if args.known_skills and os.path.isdir(args.known_skills):+ if args.known_skills:+ # A mistyped directory used to be ignored, which silently switched+ # off every check the option exists for.+ if not os.path.isdir(args.known_skills):+ print(f"--known-skills: not a directory: {args.known_skills}", file=sys.stderr)+ sys.exit(2)known = {d for d in os.listdir(args.known_skills)if os.path.isdir(os.path.join(args.known_skills, d))}+ for p in args.id_floor_from:+ if not os.path.isdir(p):+ print(f"note: --id-floor-from {p} does not exist; the id floor comes from the "+ f"other sources only")overrides = {}if args.overrides:with open(args.overrides, encoding="utf-8") as fh:overrides = {k: v for k, v in json.load(fh).items() if not k.startswith("_")}+ bad = []+ for oid, ov in overrides.items():+ for k, v in ov.items():+ if k in ("_resolves", "_reason"):+ continue+ if k not in OVERRIDE_KEYS:+ bad.append(f"#{oid}: key {k!r} is not written to the file "+ f"(settable: {', '.join(sorted(OVERRIDE_KEYS))})")+ elif k in OVERRIDE_LIST_KEYS and not (+ isinstance(v, list) and all(isinstance(x, str) for x in v)):+ bad.append(f"#{oid}: {k!r} must be a list of strings, got {v!r}")+ elif k in OVERRIDE_TEXT_KEYS and not (v is None or isinstance(v, str)):+ bad.append(f"#{oid}: {k!r} must be a string or null, got {v!r}")+ elif k == "skill_qualifiers" and not (v is None or isinstance(v, dict)):+ bad.append(f"#{oid}: 'skill_qualifiers' must be an object or null, got {v!r}")+ if bad:+ print("overrides rejected — nothing written; an accepted key that never reaches "+ "the file is the outcome this refuses:", file=sys.stderr)+ for b in bad:+ print(f" {b}", file=sys.stderr)+ sys.exit(2)records, seen = [], {}for path in args.logs:@@ -509,7 +585,8 @@ def main():for r in flagged:why = ", ".join(sorted(set(r["flags"]) & REVIEW_FLAGS))print(f" #{r['id']:<5} {why:<42} {r['title'][:56]}")- info = [r for r in records if set(r["flags"]) - REVIEW_FLAGS]+ info = [r for r in records if set(r["flags"]) - REVIEW_FLAGS+ and not set(r["flags"]) & REVIEW_FLAGS]if info:print(f"\n{len(info)} file(s) recorded extra detail (no action needed): "f"skill qualifiers preserved in `skill_qualifiers`")diff --git a/scripts/validate-skill-bundle.py b/scripts/validate-skill-bundle.pyindex 49715c2..9f60461 100644--- a/scripts/validate-skill-bundle.py+++ b/scripts/validate-skill-bundle.py@@ -1015,6 +1015,50 @@ def load_case(skill, absolute):return r.returncode, r.stdout, len(ck.read_text(encoding="utf-8").splitlines())+# scripts/migrate-log.py, the pre-3.0 log converter: (name, legacy entry's+# **Skill:** line, overrides for entry 88 or None, exit status, substring the+# written file 0088-*.md must hold, substring it must NOT hold). The known+# skills are companion-a and companion-b.+MIGRATE_SCRIPT = pathlib.Path(__file__).resolve().parent / "migrate-log.py"+MIGRATE_FIXTURES = [+ ("override siblings_checked and target_file reach the file", "???",+ {"_resolves": ["skill-name-unparseable"], "_reason": "t", "skill": ["companion-a"],+ "siblings_checked": "PLANTED", "target_file": ["PLANTED/T.md"]}, 0,+ 'target_file: ["PLANTED/T.md"]\nsiblings_checked: "PLANTED"', None),+ ("an override key the file cannot carry stops the run", "companion-a",+ {"sibling_checked": "typo"}, 2, None, None),+ ("a string where a list belongs stops the run", "companion-a",+ {"skill": "companion-a"}, 2, None, None),+ ("a known skill inside a qualifier is a review flag, not area", "companion-a (also touches companion-b A9)",+ None, 0, "needs review: skill-in-qualifier", "area:"),+ ("a plain qualifier is still promoted to area", "companion-a (section 3)",+ None, 0, 'area: "section 3"', "migration_note"),+ ("a --known-skills path that is not a directory stops the run", "companion-a",+ "BAD-SKILLS-DIR", 2, None, None),+]+++def migrate_case(skill_line, ov):+ """Convert a one-entry legacy log; return (status, text of 0088-*.md or None)."""+ import json+ import subprocess+ with tempfile.TemporaryDirectory() as tmp:+ t = pathlib.Path(tmp)+ for k in ("companion-a", "companion-b"):+ (t / "skills" / k).mkdir(parents=True)+ (t / "log.md").write_text("### Observation 88: T\n**Date:** 2026-05-02\n**Status:** OPEN\n"+ f"**Skill:** {skill_line}\n\n**Issue:** x\n", encoding="utf-8")+ args = [sys.executable, str(MIGRATE_SCRIPT), "--convert", str(t / "log.md"),+ "--out", str(t / "out"), "--known-skills",+ str(t / ("missing" if ov == "BAD-SKILLS-DIR" else "skills"))]+ if isinstance(ov, dict):+ (t / "ov.json").write_text(json.dumps({"88": ov}), encoding="utf-8")+ args += ["--overrides", str(t / "ov.json")]+ r = subprocess.run(args, capture_output=True, text=True, encoding="utf-8", errors="replace")+ files = sorted((t / "out").glob("0088-*.md")) if (t / "out").is_dir() else []+ return r.returncode, files[0].read_text(encoding="utf-8") if files else None++def selftest():bad = total = 0for name, text, must_fail in RESIDUE_FIXTURES:@@ -1114,6 +1158,16 @@ def selftest():elif shutil.which("bash"):bad += 1; total += 1print(f"FAIL skill-load script: {LOAD_SCRIPT.name} missing beside this file")+ if MIGRATE_SCRIPT.is_file():+ for name, skill_line, ov, want_rc, has, lacks in MIGRATE_FIXTURES:+ rc, text = migrate_case(skill_line, ov)+ ok = rc == want_rc and (text is None if want_rc else text is not None) \+ and (has is None or has in (text or "")) and (lacks is None or lacks not in (text or ""))+ bad += not ok; total += 1+ print(f"{'ok ' if ok else 'FAIL'} migrate-log: {name}" + ("" if ok else f" (exit {rc})"))+ else:+ bad += 1; total += 1+ print(f"FAIL migrate-log: {MIGRATE_SCRIPT.name} missing beside this file")print(f"selftest: {total - bad}/{total} passed")return 1 if bad else 0