[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M72SDVHDZY5XB3TRAESJHC4M":3,"skill-same:01M72SDVHDZY5XB3TRAESJHC4M":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":6,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":33,"install":34,"resources":47},"01M72SDVHDZY5XB3TRAESJHC4M","fsharp-parsing",null,"Parse governance inputs (YAML, tasks.md line grammar, audit-status regions, JSON) in compiled F#.","EHotwagner\u002FFS-Skia-UI","EHotwagner","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1645484?v=4","01M72S7CTBDPQDQHQJKKHY87K9","01M72S7CVFD0JN82RVX21NFEVC",2,"MIT","https:\u002F\u002Fgithub.com\u002FEHotwagner\u002FFS-Skia-UI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ffsharp-parsing\u002FSKILL.md",[],[],"2026-11-10 22:39:42",false,"---\nname: fsharp-parsing\ndescription: Parse governance inputs (YAML, tasks.md line grammar, audit-status regions, JSON) in compiled F#.\ncompatibility: F# governance library (build\u002FGovernance) under net10.0; build-tooling scope only.\nmetadata:\n  author: fs-skia-ui\n  source: docs\u002Freports\u002F2026-05-31-1714-foundations-fsharp-capabilities-and-libraries.md\n---\n\n# fsharp-parsing\n\nCookbook for porting the Bash\u002FPython parsers into typed, compiled F# in the governance library,\nreplacing the two hand-rolled YAML parsers (Python + `build.fsx`) and the regex scanners. Owns **C1**\n(YAML), **C2** (`tasks.md` line grammar), **C3** (`audit-status` regions), **C4** (JSON read), **C5**\n(JSON write), **C16** (regex over a diff), **C21** (general regex). Verdicts from the capability report\n(`metadata.source`) §3, not re-opened here.\n\n## When to use\n\n- Reading `tasks.deps.yml`, `capabilities.yml`, `validation.contract.yml`, `audit-patterns.yml`.\n- Parsing `tasks.md` task lines, annotations (`[P]`\u002F`[US\\d+]`\u002F`[T[12]]`\u002F`[SEH]`\u002F`[skillist: …]`),\n  phase\u002Fcheckpoint headers, and Synthetic-Evidence Inventory tables.\n- Scanning ` ```audit-status ` fenced regions (key=value, first-region-wins, dup-key = hard error).\n- Reading `.specify\u002Ffeature.json`; emitting `task-graph.json` (schema 1.0).\n- Applying `audit-patterns.yml` regexes to a unified diff (C16) and the misc package\u002Fversion\u002Ffence\n  regexes (C21).\n\n## Library verdicts\n\n- **YAML (C1) → YamlDotNet 17.1.0** (already pinned). Deserialize into immutable F# records\u002FDUs behind\n  the API; retire both bespoke parsers. **Legivel rejected** — YamlDotNet is present and the inputs\n  don't need YAML-1.2 conformance.\n- **JSON read\u002Fwrite (C4, C5) → System.Text.Json + FSharp.SystemTextJson 1.4.36** for DU\u002Frecord\n  round-trip. **Thoth.Json \u002F Newtonsoft rejected** — STJ is in the BCL; FSharp.SystemTextJson adds the\n  F# union\u002Frecord support.\n- **Line\u002Fregion\u002Fdiff grammar (C2, C3, C16) → regex port FIRST, then XParsec 1.0.0.** A faithful\n  `System.Text.RegularExpressions` port clears the byte-parity gate against the Stage-0 golden fixtures;\n  migrate to **XParsec** (pure F#, MIT, Fable-capable) once parity is signed off. **Full Markdown AST\n  (FSharp.Formatting\u002FMarkdig) rejected** — these are a constrained line grammar, not arbitrary Markdown.\n- **General regex (C21) → `System.Text.RegularExpressions`** (BCL). No library.\n\n## Exact grammars to reproduce (parity-critical)\n\nReproduce exactly; gate on the Stage-0 golden fixtures (Invariant 6) **before** deleting any Python\u002FBash.\n\nTask line (`compute-task-graph.py`):\n`^\\s*-\\s*\\[(?\u003Cbox>[ X\\-FS*])\\]\\s+(?\u003Cid>T\\d{3,4})\\b(?\u003Crest>.*)$`\nBoxes: `[ ]` pending · `[X]` done · `[S]` synthetic · `[F]` failed · `[-]` skipped · `[*]` computed-only.\nAnnotations (order varies): `[P]` parallel · `[US\\d+]` user story · `[T[12]]` tier · `[SEH]` +\n`synthetic-error-handling-approved` label · `[skillist: [...]]` (empty brackets = no skills).\n\n`tasks.deps.yml` accepts **two shapes** — object `{deps, skillist}` and legacy bare-list. Accept\nboth; fixture-test both before deleting the Python.\n\n`audit-status` region semantics (`audit-status-scan.py`): first region wins · detect unclosed ·\n`#` comments and blank lines ignored · `key=value` · **duplicate key = hard error** (never\nlast-wins) · key normalize `.lower().Trim()`.\n\n## API walkthrough + runnable examples\n\n### C1 — YAML into a typed model (YamlDotNet)\n\n`DeserializerBuilder().Build()` gives an `IDeserializer`. Deserialize to the loose node model\n(`Dictionary\u003Cstring,obj>`; nested mappings `Dictionary\u003Cobj,obj>`, sequences `List\u003Cobj>`), then project\ninto immutable F# values — where you absorb the two `tasks.deps.yml` shapes.\n\n```fsharp\nopen System.Collections.Generic\nopen YamlDotNet.Serialization\n\nlet deserializer = DeserializerBuilder().Build()\n\n\u002F\u002F\u002F tasks.deps.yml tolerates TWO shapes the typed reader must accept:\n\u002F\u002F\u002F   object  ->  T001: { deps: [T000], skillist: [speckit-evidence-graph] }\n\u002F\u002F\u002F   legacy  ->  T001: [T000]            (the value IS the deps list)\nlet normaliseEntry (value: obj) : string list * string list =\n    let toStrings (xs: List\u003Cobj>) = [ for x in xs -> string x ]\n\n    match value with\n    | :? Dictionary\u003Cobj, obj> as object ->\n        let listAt (key: string) =\n            match object.TryGetValue(box key) with\n            | true, (:? List\u003Cobj> as xs) -> toStrings xs\n            | _ -> []\n\n        listAt \"deps\", listAt \"skillist\"\n    | :? List\u003Cobj> as bare -> toStrings bare, []\n    | _ -> [], []\n\nlet parseDepsRoot (yaml: string) =\n    let root = deserializer.Deserialize\u003CDictionary\u003Cstring, obj>>(yaml)\n\n    match root.TryGetValue \"tasks\" with\n    | true, (:? Dictionary\u003Cobj, obj> as tasks) ->\n        [ for kv in tasks -> string kv.Key, normaliseEntry kv.Value ]\n    | _ -> []\n```\n\n### C2 — task-line grammar (regex port first)\n\nThe parity-first path: port the Python regex verbatim into a compiled `Regex` with named groups, then\nproject the match into a typed row.\n\n```fsharp\nopen System.Text.RegularExpressions\n\ntype TaskBox =\n    | Pending\n    | Done\n    | Synthetic\n    | Failed\n    | Skipped\n    | Computed\n\nlet taskLine =\n    Regex(@\"^\\s*-\\s*\\[(?\u003Cbox>[ X\\-FS*])\\]\\s+(?\u003Cid>T\\d{3,4})\\b(?\u003Crest>.*)$\", RegexOptions.Compiled)\n\nlet boxOf (token: string) =\n    match token with\n    | \"X\" -> Done\n    | \"S\" -> Synthetic\n    | \"F\" -> Failed\n    | \"-\" -> Skipped\n    | \"*\" -> Computed\n    | _ -> Pending\n\nlet parseTaskLine (line: string) =\n    let m = taskLine.Match line\n\n    if m.Success then\n        Some(m.Groups.[\"id\"].Value, boxOf (m.Groups.[\"box\"].Value), m.Groups.[\"rest\"].Value.Trim())\n    else\n        None\n```\n\n### C2 — annotations and the skillist mirror\n\nAnnotations appear in any order; pull each out independently. `[skillist: []]` means no skills.\n\n```fsharp\nopen System.Text.RegularExpressions\n\nlet private skillistRx = Regex(@\"\\[skillist:\\s*\\[(?\u003Citems>[^\\]]*)\\]\\]\", RegexOptions.Compiled)\nlet private userStoryRx = Regex(@\"\\[US(?\u003Cn>\\d+)\\]\", RegexOptions.Compiled)\n\nlet skillistOf (rest: string) =\n    let m = skillistRx.Match rest\n\n    if not m.Success then\n        []\n    else\n        m.Groups.[\"items\"].Value.Split(',')\n        |> Array.map (fun s -> s.Trim())\n        |> Array.filter (fun s -> s \u003C> \"\")\n        |> Array.toList\n\nlet userStoryOf (rest: string) =\n    let m = userStoryRx.Match rest\n    if m.Success then Some(int m.Groups.[\"n\"].Value) else None\n```\n\n### C3 — `audit-status` fenced region (hand parser, dup-key = error)\n\nFirst region wins; `#` comments and blanks ignored; `key=value`; keys normalise to lower+trim; a\n**duplicate key is a hard error** (never last-wins).\n\n```fsharp\nopen System\n\ntype AuditRegion =\n    | Parsed of Map\u003Cstring, string>\n    | DuplicateKey of string\n    | Unclosed\n\nlet parseAuditStatus (text: string) : AuditRegion option =\n    let lines = text.Replace(\"\\r\\n\", \"\\n\").Split('\\n')\n    let openIdx = lines |> Array.tryFindIndex (fun l -> l.Trim() = \"```audit-status\")\n\n    match openIdx with\n    | None -> None\n    | Some start ->\n        let rest = lines.[start + 1 ..]\n        let closeRel = rest |> Array.tryFindIndex (fun l -> l.Trim() = \"```\")\n\n        match closeRel with\n        | None -> Some Unclosed\n        | Some stop ->\n            let mutable acc = Map.empty\n            let mutable result = None\n\n            for raw in rest.[.. stop - 1] do\n                let line = raw.Trim()\n\n                if line \u003C> \"\" && not (line.StartsWith \"#\") && result.IsNone then\n                    let eq = line.IndexOf '='\n\n                    if eq > 0 then\n                        let key = line.Substring(0, eq).Trim().ToLowerInvariant()\n                        let value = line.Substring(eq + 1).Trim()\n\n                        if Map.containsKey key acc then\n                            result \u003C- Some(DuplicateKey key)\n                        else\n                            acc \u003C- Map.add key value acc\n\n            Some(defaultArg result (Parsed acc))\n```\n\n### C4 \u002F C5 — JSON read & write (FSharp.SystemTextJson)\n\n`JsonFSharpOptions.Default().ToJsonSerializerOptions()` produces options that round-trip F# records and\nunions; reuse one value (the difference between STJ choking on an F# record and handling it cleanly).\n\n```fsharp\nopen System.Text.Json\nopen System.Text.Json.Serialization\n\nlet jsonOptions = JsonFSharpOptions.Default().ToJsonSerializerOptions()\n\ntype FeatureFile = { feature_directory: string }\n\n\u002F\u002F\u002F C4 — read .specify\u002Ffeature.json into a typed record.\nlet readFeature (json: string) : FeatureFile =\n    JsonSerializer.Deserialize\u003CFeatureFile>(json, jsonOptions)\n\n\u002F\u002F\u002F C5 — emit a typed record back as canonical JSON.\nlet writeFeature (feature: FeatureFile) : string =\n    JsonSerializer.Serialize(feature, jsonOptions)\n```\n\nFor hand-built artifacts where you want byte-stable layout (e.g. `task-graph.json` schema 1.0),\n`Utf8JsonWriter` over a `MemoryStream` gives explicit control of ordering and indentation:\n\n```fsharp\nopen System.IO\nopen System.Text\nopen System.Text.Json\n\nlet renderTaskGraphJson (tasks: (string * string) list) : string =\n    use stream = new MemoryStream()\n    use writer = new Utf8JsonWriter(stream, JsonWriterOptions(Indented = true))\n    writer.WriteStartObject()\n    writer.WriteString(\"schema_version\", \"1.0\")\n    writer.WriteStartArray(\"tasks\")\n\n    for id, effective in tasks do\n        writer.WriteStartObject()\n        writer.WriteString(\"id\", id)\n        writer.WriteString(\"effective_status\", effective)\n        writer.WriteEndObject()\n\n    writer.WriteEndArray()\n    writer.WriteEndObject()\n    writer.Flush()\n    Encoding.UTF8.GetString(stream.ToArray())\n```\n\n### C16 \u002F C21 — regex over a diff and general rewrites\n\nC16 applies the `audit-patterns.yml` regexes to added\u002Fremoved diff lines; C21 covers the misc\npackage-version rewrite and fence detection. Both plain BCL regex.\n\n```fsharp\nopen System.Text.RegularExpressions\n\n\u002F\u002F\u002F C16 — scan only the added lines of a unified diff for a forbidden pattern.\nlet addedLineHits (pattern: Regex) (diff: string) =\n    diff.Replace(\"\\r\\n\", \"\\n\").Split('\\n')\n    |> Array.filter (fun l -> l.StartsWith \"+\" && not (l.StartsWith \"+++\"))\n    |> Array.filter (fun l -> pattern.IsMatch l)\n    |> Array.toList\n\n\u002F\u002F\u002F C21 — rewrite a central package version pin.\nlet bumpPackageVersion (packageId: string) (newVersion: string) (props: string) =\n    let rx = Regex($\"\"\"(Include=\"{Regex.Escape packageId}\"\\s+Version=\")[^\"]*(\")\"\"\")\n    rx.Replace(props, (fun m -> m.Groups.[1].Value + newVersion + m.Groups.[2].Value))\n```\n\n### C2 \u002F C3 — the XParsec migration target (post-parity)\n\nOnce the regex port has cleared the golden gate, the grammar's long-term home is **XParsec**:\ncombinators over a `Reader` returning `Ok`\u002F`Error`, the parsed value straight out of the `Ok` case.\n\n```fsharp\nopen XParsec\nopen XParsec.Parsers\nopen XParsec.CharParsers\n\n\u002F\u002F\u002F A task id like `T024` as an XParsec combinator: 'T' then 3-4 digits.\nlet taskId =\n    parser {\n        let! _ = pchar 'T'\n        let! digits = many1Chars (satisfy System.Char.IsDigit)\n        return \"T\" + digits\n    }\n\nlet parseTaskId (input: string) =\n    let reader = Reader.ofString input ()\n\n    match taskId reader with\n    | Ok success -> Some success\n    | Error _ -> None\n```\n\n## Library API + runnable example\n\nThese parsers now ship as the real `Parsing` module in the **`FS.Skia.UI.SkillSupport`** package —\nits `.fsi` surface lives at `src\u002FSkillSupport\u002FParsing.fsi`. `FS.Skia.UI.Build` consumes the same code\nvia ProjectReference, so the governance build parses through exactly these functions:\n\n- `Parsing.readYaml\u003C'T>` — deserialize YAML into a typed F# record\u002FDU.\n- `Parsing.readJson\u003C'T>` — deserialize JSON into a typed F# record\u002FDU (F# union\u002Frecord aware).\n- `Parsing.matchLines: string -> string seq -> (int * Match) seq` — apply a regex pattern across an\n  enumerable of lines, yielding the 1-based line index and the `System.Text.RegularExpressions.Match`.\n\n```fsharp\nopen FS.Skia.UI.SkillSupport\n\ntype FeatureFile = { feature_directory: string }\n\n\u002F\u002F Typed JSON read (C4) through the shipped module.\nlet feature = Parsing.readJson\u003CFeatureFile> \"\"\"{ \"feature_directory\": \"specs\u002F058\" }\"\"\"\n\n\u002F\u002F Typed YAML read (C1).\ntype DepsRoot = { tasks: Map\u003Cstring, string list> }\nlet deps = Parsing.readYaml\u003CDepsRoot> \"tasks:\\n  T001: [T000]\\n\"\n\n\u002F\u002F Regex over lines (C2\u002FC16): pull task ids with their line numbers.\nlet hits =\n    [ \"- [X] T001 do it\"; \"noise\"; \"- [ ] T002 next\" ]\n    |> Parsing.matchLines @\"T\\d{3,4}\"\n    |> Seq.map (fun (lineNo, m) -> lineNo, m.Value)\n    |> Seq.toList                               \u002F\u002F [ (1, \"T001\"); (3, \"T002\") ]\n```\n\n## Cautions\n\n- **Two `tasks.deps.yml` shapes** (object `{deps, skillist}` + legacy bare-list) — one of the two most\n  likely silent divergences in the port (the other is .NET-glob vs `fnmatch`, see [[fsharp-io-globbing]]).\n- **Parity over elegance.** Match the Python's exact tie-breaks\u002Fordering; golden-gate (Invariant 6)\n  before deleting any script.\n- **`audit-status` duplicate key is a hard error**, never last-wins — keep it.\n- **Determinism.** Parsers must be pure over their input — no env\u002Fclock reads at parse time.\n- **Build-tooling scope only.** Lives under `build\u002FGovernance`; ships nowhere; no `FSharp.Compiler.*`.\n\n## Consuming stages\n\nStage 3.3 (YAML→typed model migration), Stage 4 (Python parser port: task-graph + audit-status),\nStage 5 (compiled build front-end reading `feature.json` \u002F emitting `task-graph.json`). See the plan in\n`metadata.source`.\n\n## Persistent problems\n\nWhen a problem outlasts reasonable in-repo attempts, extensive external research is\n**mandatory** — consult **official online docs first** (the F#\u002F.NET docs and the driven\nlibrary's own documentation\u002FAPI reference), then community sources (forums, Reddit, Q&A\nsites, issue trackers and changelogs). Record the findings and resolving links in the\nfeature's `specs\u002F\u003Cfeature>\u002Ffeedback\u002F` folder and, for durable lessons, in this skill's\n**Sources** line. Offline, the mandate degrades to recording \"research blocked — \u003Cwhy>\"\nrather than hard-failing the phase.\n\n## Sources \u002F links\n\n- YamlDotNet: \u003Chttps:\u002F\u002Fgithub.com\u002Faaubry\u002FYamlDotNet\u002Fwiki>\n- System.Text.Json: \u003Chttps:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fstandard\u002Fserialization\u002Fsystem-text-json\u002F>\n- FSharp.SystemTextJson: \u003Chttps:\u002F\u002Fgithub.com\u002FTarmil\u002FFSharp.SystemTextJson>\n- XParsec: \u003Chttps:\u002F\u002Fgithub.com\u002Froboz0r\u002FXParsec>\n- .NET regex: \u003Chttps:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fstandard\u002Fbase-types\u002Fregular-expressions>\n- Capability report: `docs\u002Freports\u002F2026-05-31-1714-foundations-fsharp-capabilities-and-libraries.md` §3.\n\n## Related\n\n[[fsharp-graph-algorithms]] (consumes the parsed model), [[fsharp-code-generation]] (emits\nJSON\u002FMarkdown), [[fsharp-io-globbing]] (discovers the files to parse), [[fsharp-shell-process]]\n(produces the diff scanned in C16).\n","# fsharp-parsing\n\nCookbook for porting the Bash\u002FPython parsers into typed, compiled F# in the governance library,\nreplacing the two hand-rolled YAML parsers (Python + `build.fsx`) and the regex scanners. Owns **C1**\n(YAML), **C2** (`tasks.md` line grammar), **C3** (`audit-status` regions), **C4** (JSON read), **C5**\n(JSON write), **C16** (regex over a diff), **C21** (general regex). Verdicts from the capability report\n(`metadata.source`) §3, not re-opened here.\n\n## When to use\n\n- Reading `tasks.deps.yml`, `capabilities.yml`, `validation.contract.yml`, `audit-patterns.yml`.\n- Parsing `tasks.md` task lines, annotations (`[P]`\u002F`[US\\d+]`\u002F`[T[12]]`\u002F`[SEH]`\u002F`[skillist: …]`),\n  phase\u002Fcheckpoint headers, and Synthetic-Evidence Inventory tables.\n- Scanning ` ```audit-status ` fenced regions (key=value, first-region-wins, dup-key = hard error).\n- Reading `.specify\u002Ffeature.json`; emitting `task-graph.json` (schema 1.0).\n- Applying `audit-patterns.yml` regexes to a unified diff (C16) and the misc package\u002Fversion\u002Ffence\n  regexes (C21).\n\n## Library verdicts\n\n- **YAML (C1) → YamlDotNet 17.1.0** (already pinned). Deserialize into immutable F# records\u002FDUs behind\n  the API; retire both bespoke parsers. **Legivel rejected** — YamlDotNet is present and the inputs\n  don't need YAML-1.2 conformance.\n- **JSON read\u002Fwrite (C4, C5) → System.Text.Json + FSharp.SystemTextJson 1.4.36** for DU\u002Frecord\n  round-trip. **Thoth.Json \u002F Newtonsoft rejected** — STJ is in the BCL; FSharp.SystemTextJson adds the\n  F# union\u002Frecord support.\n- **Line\u002Fregion\u002Fdiff grammar (C2, C3, C16) → regex port FIRST, then XParsec 1.0.0.** A faithful\n  `System.Text.RegularExpressions` port clears the byte-parity gate against the Stage-0 golden fixtures;\n  migrate to **XParsec** (pure F#, MIT, Fable-capable) once parity is signed off. **Full Markdown AST\n  (FSharp.Formatting\u002FMarkdig) rejected** — these are a constrained line grammar, not arbitrary Markdown.\n- **General regex (C21) → `System.Text.RegularExpressions`** (BCL). No library.\n\n## Exact grammars to reproduce (parity-critical)\n\nReproduce exactly; gate on the Stage-0 golden fixtures (Invariant 6) **before** deleting any Python\u002FBash.\n\nTask line (`compute-task-graph.py`):\n`^\\s*-\\s*\\[(?\u003Cbox>[ X\\-FS*])\\]\\s+(?\u003Cid>T\\d{3,4})\\b(?\u003Crest>.*)$`\nBoxes: `[ ]` pending · `[X]` done · `[S]` synthetic · `[F]` failed · `[-]` skipped · `[*]` computed-only.\nAnnotations (order varies): `[P]` parallel · `[US\\d+]` user story · `[T[12]]` tier · `[SEH]` +\n`synthetic-error-handling-approved` label · `[skillist: [...]]` (empty brackets = no skills).\n\n`tasks.deps.yml` accepts **two shapes** — object `{deps, skillist}` and legacy bare-list. Accept\nboth; fixture-test both before deleting the Python.\n\n`audit-status` region semantics (`audit-status-scan.py`): first region wins · detect unclosed ·\n`#` comments and blank lines ignored · `key=value` · **duplicate key = hard error** (never\nlast-wins) · key normalize `.lower().Trim()`.\n\n## API walkthrough + runnable examples\n\n### C1 — YAML into a typed model (YamlDotNet)\n\n`DeserializerBuilder().Build()` gives an `IDeserializer`. Deserialize to the loose node model\n(`Dictionary\u003Cstring,obj>`; nested mappings `Dictionary\u003Cobj,obj>`, sequences `List\u003Cobj>`), then project\ninto immutable F# values — where you absorb the two `tasks.deps.yml` shapes.\n\n```fsharp\nopen System.Collections.Generic\nopen YamlDotNet.Serialization\n\nlet deserializer = DeserializerBuilder().Build()\n\n\u002F\u002F\u002F tasks.deps.yml tolerates TWO shapes the typed reader must accept:\n\u002F\u002F\u002F   object  ->  T001: { deps: [T000], skillist: [speckit-evidence-graph] }\n\u002F\u002F\u002F   legacy  ->  T001: [T000]            (the value IS the deps list)\nlet normaliseEntry (value: obj) : string list * string list =\n    let toStrings (xs: List\u003Cobj>) = [ for x in xs -> string x ]\n\n    match value with\n    | :? Dictionary\u003Cobj, obj> as object ->\n        let listAt (key: string) =\n            match object.TryGetValue(box key) with\n            | true, (:? List\u003Cobj> as xs) -> toStrings xs\n            | _ -> []\n\n        listAt \"deps\", listAt \"skillist\"\n    | :? List\u003Cobj> as bare -> toStrings bare, []\n    | _ -> [], []\n\nlet parseDepsRoot (yaml: string) =\n    let root = deserializer.Deserialize\u003CDictionary\u003Cstring, obj>>(yaml)\n\n    match root.TryGetValue \"tasks\" with\n    | true, (:? Dictionary\u003Cobj, obj> as tasks) ->\n        [ for kv in tasks -> string kv.Key, normaliseEntry kv.Value ]\n    | _ -> []\n```\n\n### C2 — task-line grammar (regex port first)\n\nThe parity-first path: port the Python regex verbatim into a compiled `Regex` with named groups, then\nproject the match into a typed row.\n\n```fsharp\nopen System.Text.RegularExpressions\n\ntype TaskBox =\n    | Pending\n    | Done\n    | Synthetic\n    | Failed\n    | Skipped\n    | Computed\n\nlet taskLine =\n    Regex(@\"^\\s*-\\s*\\[(?\u003Cbox>[ X\\-FS*])\\]\\s+(?\u003Cid>T\\d{3,4})\\b(?\u003Crest>.*)$\", RegexOptions.Compiled)\n\nlet boxOf (token: string) =\n    match token with\n    | \"X\" -> Done\n    | \"S\" -> Synthetic\n    | \"F\" -> Failed\n    | \"-\" -> Skipped\n    | \"*\" -> Computed\n    | _ -> Pending\n\nlet parseTaskLine (line: string) =\n    let m = taskLine.Match line\n\n    if m.Success then\n        Some(m.Groups.[\"id\"].Value, boxOf (m.Groups.[\"box\"].Value), m.Groups.[\"rest\"].Value.Trim())\n    else\n        None\n```\n\n### C2 — annotations and the skillist mirror\n\nAnnotations appear in any order; pull each out independently. `[skillist: []]` means no skills.\n\n```fsharp\nopen System.Text.RegularExpressions\n\nlet private skillistRx = Regex(@\"\\[skillist:\\s*\\[(?\u003Citems>[^\\]]*)\\]\\]\", RegexOptions.Compiled)\nlet private userStoryRx = Regex(@\"\\[US(?\u003Cn>\\d+)\\]\", RegexOptions.Compiled)\n\nlet skillistOf (rest: string) =\n    let m = skillistRx.Match rest\n\n    if not m.Success then\n        []\n    else\n        m.Groups.[\"items\"].Value.Split(',')\n        |> Array.map (fun s -> s.Trim())\n        |> Array.filter (fun s -> s \u003C> \"\")\n        |> Array.toList\n\nlet userStoryOf (rest: string) =\n    let m = userStoryRx.Match rest\n    if m.Success then Some(int m.Groups.[\"n\"].Value) else None\n```\n\n### C3 — `audit-status` fenced region (hand parser, dup-key = error)\n\nFirst region wins; `#` comments and blanks ignored; `key=value`; keys normalise to lower+trim; a\n**duplicate key is a hard error** (never last-wins).\n\n```fsharp\nopen System\n\ntype AuditRegion =\n    | Parsed of Map\u003Cstring, string>\n    | DuplicateKey of string\n    | Unclosed\n\nlet parseAuditStatus (text: string) : AuditRegion option =\n    let lines = text.Replace(\"\\r\\n\", \"\\n\").Split('\\n')\n    let openIdx = lines |> Array.tryFindIndex (fun l -> l.Trim() = \"```audit-status\")\n\n    match openIdx with\n    | None -> None\n    | Some start ->\n        let rest = lines.[start + 1 ..]\n        let closeRel = rest |> Array.tryFindIndex (fun l -> l.Trim() = \"```\")\n\n        match closeRel with\n        | None -> Some Unclosed\n        | Some stop ->\n            let mutable acc = Map.empty\n            let mutable result = None\n\n            for raw in rest.[.. stop - 1] do\n                let line = raw.Trim()\n\n                if line \u003C> \"\" && not (line.StartsWith \"#\") && result.IsNone then\n                    let eq = line.IndexOf '='\n\n                    if eq > 0 then\n                        let key = line.Substring(0, eq).Trim().ToLowerInvariant()\n                        let value = line.Substring(eq + 1).Trim()\n\n                        if Map.containsKey key acc then\n                            result \u003C- Some(DuplicateKey key)\n                        else\n                            acc \u003C- Map.add key value acc\n\n            Some(defaultArg result (Parsed acc))\n```\n\n### C4 \u002F C5 — JSON read & write (FSharp.SystemTextJson)\n\n`JsonFSharpOptions.Default().ToJsonSerializerOptions()` produces options that round-trip F# records and\nunions; reuse one value (the difference between STJ choking on an F# record and handling it cleanly).\n\n```fsharp\nopen System.Text.Json\nopen System.Text.Json.Serialization\n\nlet jsonOptions = JsonFSharpOptions.Default().ToJsonSerializerOptions()\n\ntype FeatureFile = { feature_directory: string }\n\n\u002F\u002F\u002F C4 — read .specify\u002Ffeature.json into a typed record.\nlet readFeature (json: string) : FeatureFile =\n    JsonSerializer.Deserialize\u003CFeatureFile>(json, jsonOptions)\n\n\u002F\u002F\u002F C5 — emit a typed record back as canonical JSON.\nlet writeFeature (feature: FeatureFile) : string =\n    JsonSerializer.Serialize(feature, jsonOptions)\n```\n\nFor hand-built artifacts where you want byte-stable layout (e.g. `task-graph.json` schema 1.0),\n`Utf8JsonWriter` over a `MemoryStream` gives explicit control of ordering and indentation:\n\n```fsharp\nopen System.IO\nopen System.Text\nopen System.Text.Json\n\nlet renderTaskGraphJson (tasks: (string * string) list) : string =\n    use stream = new MemoryStream()\n    use writer = new Utf8JsonWriter(stream, JsonWriterOptions(Indented = true))\n    writer.WriteStartObject()\n    writer.WriteString(\"schema_version\", \"1.0\")\n    writer.WriteStartArray(\"tasks\")\n\n    for id, effective in tasks do\n        writer.WriteStartObject()\n        writer.WriteString(\"id\", id)\n        writer.WriteString(\"effective_status\", effective)\n        writer.WriteEndObject()\n\n    writer.WriteEndArray()\n    writer.WriteEndObject()\n    writer.Flush()\n    Encoding.UTF8.GetString(stream.ToArray())\n```\n\n### C16 \u002F C21 — regex over a diff and general rewrites\n\nC16 applies the `audit-patterns.yml` regexes to added\u002Fremoved diff lines; C21 covers the misc\npackage-version rewrite and fence detection. Both plain BCL regex.\n\n```fsharp\nopen System.Text.RegularExpressions\n\n\u002F\u002F\u002F C16 — scan only the added lines of a unified diff for a forbidden pattern.\nlet addedLineHits (pattern: Regex) (diff: string) =\n    diff.Replace(\"\\r\\n\", \"\\n\").Split('\\n')\n    |> Array.filter (fun l -> l.StartsWith \"+\" && not (l.StartsWith \"+++\"))\n    |> Array.filter (fun l -> pattern.IsMatch l)\n    |> Array.toList\n\n\u002F\u002F\u002F C21 — rewrite a central package version pin.\nlet bumpPackageVersion (packageId: string) (newVersion: string) (props: string) =\n    let rx = Regex($\"\"\"(Include=\"{Regex.Escape packageId}\"\\s+Version=\")[^\"]*(\")\"\"\")\n    rx.Replace(props, (fun m -> m.Groups.[1].Value + newVersion + m.Groups.[2].Value))\n```\n\n### C2 \u002F C3 — the XParsec migration target (post-parity)\n\nOnce the regex port has cleared the golden gate, the grammar's long-term home is **XParsec**:\ncombinators over a `Reader` returning `Ok`\u002F`Error`, the parsed value straight out of the `Ok` case.\n\n```fsharp\nopen XParsec\nopen XParsec.Parsers\nopen XParsec.CharParsers\n\n\u002F\u002F\u002F A task id like `T024` as an XParsec combinator: 'T' then 3-4 digits.\nlet taskId =\n    parser {\n        let! _ = pchar 'T'\n        let! digits = many1Chars (satisfy System.Char.IsDigit)\n        return \"T\" + digits\n    }\n\nlet parseTaskId (input: string) =\n    let reader = Reader.ofString input ()\n\n    match taskId reader with\n    | Ok success -> Some success\n    | Error _ -> None\n```\n\n## Library API + runnable example\n\nThese parsers now ship as the real `Parsing` module in the **`FS.Skia.UI.SkillSupport`** package —\nits `.fsi` surface lives at `src\u002FSkillSupport\u002FParsing.fsi`. `FS.Skia.UI.Build` consumes the same code\nvia ProjectReference, so the governance build parses through exactly these functions:\n\n- `Parsing.readYaml\u003C'T>` — deserialize YAML into a typed F# record\u002FDU.\n- `Parsing.readJson\u003C'T>` — deserialize JSON into a typed F# record\u002FDU (F# union\u002Frecord aware).\n- `Parsing.matchLines: string -> string seq -> (int * Match) seq` — apply a regex pattern across an\n  enumerable of lines, yielding the 1-based line index and the `System.Text.RegularExpressions.Match`.\n\n```fsharp\nopen FS.Skia.UI.SkillSupport\n\ntype FeatureFile = { feature_directory: string }\n\n\u002F\u002F Typed JSON read (C4) through the shipped module.\nlet feature = Parsing.readJson\u003CFeatureFile> \"\"\"{ \"feature_directory\": \"specs\u002F058\" }\"\"\"\n\n\u002F\u002F Typed YAML read (C1).\ntype DepsRoot = { tasks: Map\u003Cstring, string list> }\nlet deps = Parsing.readYaml\u003CDepsRoot> \"tasks:\\n  T001: [T000]\\n\"\n\n\u002F\u002F Regex over lines (C2\u002FC16): pull task ids with their line numbers.\nlet hits =\n    [ \"- [X] T001 do it\"; \"noise\"; \"- [ ] T002 next\" ]\n    |> Parsing.matchLines @\"T\\d{3,4}\"\n    |> Seq.map (fun (lineNo, m) -> lineNo, m.Value)\n    |> Seq.toList                               \u002F\u002F [ (1, \"T001\"); (3, \"T002\") ]\n```\n\n## Cautions\n\n- **Two `tasks.deps.yml` shapes** (object `{deps, skillist}` + legacy bare-list) — one of the two most\n  likely silent divergences in the port (the other is .NET-glob vs `fnmatch`, see [[fsharp-io-globbing]]).\n- **Parity over elegance.** Match the Python's exact tie-breaks\u002Fordering; golden-gate (Invariant 6)\n  before deleting any script.\n- **`audit-status` duplicate key is a hard error**, never last-wins — keep it.\n- **Determinism.** Parsers must be pure over their input — no env\u002Fclock reads at parse time.\n- **Build-tooling scope only.** Lives under `build\u002FGovernance`; ships nowhere; no `FSharp.Compiler.*`.\n\n## Consuming stages\n\nStage 3.3 (YAML→typed model migration), Stage 4 (Python parser port: task-graph + audit-status),\nStage 5 (compiled build front-end reading `feature.json` \u002F emitting `task-graph.json`). See the plan in\n`metadata.source`.\n\n## Persistent problems\n\nWhen a problem outlasts reasonable in-repo attempts, extensive external research is\n**mandatory** — consult **official online docs first** (the F#\u002F.NET docs and the driven\nlibrary's own documentation\u002FAPI reference), then community sources (forums, Reddit, Q&A\nsites, issue trackers and changelogs). Record the findings and resolving links in the\nfeature's `specs\u002F\u003Cfeature>\u002Ffeedback\u002F` folder and, for durable lessons, in this skill's\n**Sources** line. Offline, the mandate degrades to recording \"research blocked — \u003Cwhy>\"\nrather than hard-failing the phase.\n\n## Sources \u002F links\n\n- YamlDotNet: \u003Chttps:\u002F\u002Fgithub.com\u002Faaubry\u002FYamlDotNet\u002Fwiki>\n- System.Text.Json: \u003Chttps:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fstandard\u002Fserialization\u002Fsystem-text-json\u002F>\n- FSharp.SystemTextJson: \u003Chttps:\u002F\u002Fgithub.com\u002FTarmil\u002FFSharp.SystemTextJson>\n- XParsec: \u003Chttps:\u002F\u002Fgithub.com\u002Froboz0r\u002FXParsec>\n- .NET regex: \u003Chttps:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fstandard\u002Fbase-types\u002Fregular-expressions>\n- Capability report: `docs\u002Freports\u002F2026-05-31-1714-foundations-fsharp-capabilities-and-libraries.md` §3.\n\n## Related\n\n[[fsharp-graph-algorithms]] (consumes the parsed model), [[fsharp-code-generation]] (emits\nJSON\u002FMarkdown), [[fsharp-io-globbing]] (discovers the files to parse), [[fsharp-shell-process]]\n(produces the diff scanned in C16).\n",{"name":5,"metadata":23,"description":7,"compatibility":26},{"author":24,"source":25},"fs-skia-ui","docs\u002Freports\u002F2026-05-31-1714-foundations-fsharp-capabilities-and-libraries.md","F# governance library (build\u002FGovernance) under net10.0; build-tooling scope only.","main","f943406829a9218b2882e09eb88d4ddb539c5e72",".claude\u002Fskills\u002Ffsharp-parsing",0,"https:\u002F\u002Fgithub.com\u002FEHotwagner\u002FFS-Skia-UI","https:\u002F\u002Fgithub.com\u002FEHotwagner","2026-06-16 16:16:52",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add EHotwagner\u002FFS-Skia-UI --skill fsharp-parsing",{"tool":40,"command":41},"bunx","bunx skills add EHotwagner\u002FFS-Skia-UI --skill fsharp-parsing",{"tool":43,"command":44},"pnpm","pnpm dlx skills add EHotwagner\u002FFS-Skia-UI --skill fsharp-parsing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FEHotwagner\u002FFS-Skia-UI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ffsharp-parsing\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":18},"01M72SGYR4T02T1HTS175E0V86","fs-skia-ui-widgets","Generated product guidance for Skia-rendered FS.Skia.UI Controls, rich text, chart controls, graph controls, DataGrid, and custom wrappers.","https:\u002F\u002Fgithub.com\u002FEHotwagner\u002FFS-Skia-UI\u002Fblob\u002Fmain\u002Ftemplate\u002Fproduct-skills\u002Ffs-skia-ui-widgets\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":18},"01M72SGVZJR1B117QK7TCC6E0J","fs-skia-testing","Assert generated-product expectations and evidence in a governed FS.Skia.UI product.","https:\u002F\u002Fgithub.com\u002FEHotwagner\u002FFS-Skia-UI\u002Fblob\u002Fmain\u002Ftemplate\u002Fproduct-skills\u002Ffs-skia-testing\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":18},"01M72SGTC5HZYEVVVZT4X51AZ3","fs-skia-skiaviewer","Wire a generated FS.Skia.UI product to the desktop viewer host.","https:\u002F\u002Fgithub.com\u002FEHotwagner\u002FFS-Skia-UI\u002Fblob\u002Fmain\u002Ftemplate\u002Fproduct-skills\u002Ffs-skia-skiaviewer\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":18},"01M72SGS47RPYPC9JTC39CC6EF","fs-skia-scene","Build pure scene descriptions in a generated FS.Skia.UI product.","https:\u002F\u002Fgithub.com\u002FEHotwagner\u002FFS-Skia-UI\u002Fblob\u002Fmain\u002Ftemplate\u002Fproduct-skills\u002Ffs-skia-scene\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":18},"01M72SGQF4G76C4NGSF69KZRRF","fs-skia-keyboard-input","Map keyboard input to product commands in a generated FS.Skia.UI product.","https:\u002F\u002Fgithub.com\u002FEHotwagner\u002FFS-Skia-UI\u002Fblob\u002Fmain\u002Ftemplate\u002Fproduct-skills\u002Ffs-skia-keyboard-input\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":18},"01M72SGNJP3PMSS2VRP98G7Z42","fs-skia-elmish","Drive a generated FS.Skia.UI product through the pure Elmish adapter.","https:\u002F\u002Fgithub.com\u002FEHotwagner\u002FFS-Skia-UI\u002Fblob\u002Fmain\u002Ftemplate\u002Fproduct-skills\u002Ffs-skia-elmish\u002FSKILL.md",[],[]]