Skip to content

PulseHealth audit: a template heading with a dash inside its trailing parenthetical can never match (HEALTH/METRICS.md always reports 3 sections missing) #2786

Open

Description

@cristbc

Version

LifeOS 8.761.0 · attestation: not run

What is broken

PulseHealth.ts audit reports a section as missing forever when the template's heading ends in a parenthetical that contains a dash.

headingKey drops the dash suffix first and the trailing parenthetical second. For a shipped template heading such as ## Key Numbers (Sample Panel — 2026-01-01) the dash inside the brackets cuts the string to Key Numbers (Sample Panel, the parenthetical pattern then has no closing bracket to match, and the key becomes key numbers (sample panel. A user's real heading ## Key Numbers keys as key number, so the two can never be equal.

Effect: HEALTH/METRICS.md in the release template has three such headings (Key Numbers (Sample Panel — 2026-01-01), Trends (Sample — Two Panels Compared), Daily Metrics (Sample — Wearable/App Snapshot)). Any user file with real data under plain Key Numbers, Trends and Daily Metrics headings is reported as missing all three, and the only way to clear the check is to copy the template's literal "Sample" headings into a real file. The same cut happens to any heading whose trailing parenthetical holds a hyphen, a date for example.

Where (file:line)

skills/LifeOS/Tools/PulseHealth.ts:72

Repro on a clean tree

bun -e 'const s=require("fs").readFileSync(process.argv[1],"utf8");const m=s.match(/headingKey = \(h: string\): string =>\s*([\s\S]*?);\n/);const n=Function("h","return "+m[1]);const a=n("Key Numbers (Sample Panel — 2026-01-01)"),b=n("Key Numbers");console.log("template heading normalizes to "+JSON.stringify(a)+", user heading to "+JSON.stringify(b));if(a!==b){console.log("SECTION MISMATCH: the template heading can never match");process.exit(1)}console.log("headings match")' skills/LifeOS/Tools/PulseHealth.ts
# expected: headings match, exit 0
# actual on 8.761.0: template heading normalizes to "key numbers (sample panel", user heading to "key number"; SECTION MISMATCH; exit 1
#
# end to end: give LIFEOS/USER/HEALTH/METRICS.md a '## Key Numbers' section, then
bun skills/LifeOS/Tools/PulseHealth.ts audit
# the sections check still lists 'Key Numbers (Sample Panel — 2026-01-01)' as missing

Negative control

Probe: bun -e 'const s=require("fs").readFileSync(process.argv[1],"utf8");const m=s.match(/headingKey = \(h: string\): string =>\s*([\s\S]*?);\n/);const n=Function("h","return "+m[1]);const a=n("Key Numbers (Sample Panel — 2026-01-01)"),b=n("Key Numbers");console.log("template heading normalizes to "+JSON.stringify(a)+", user heading to "+JSON.stringify(b));if(a!==b){console.log("SECTION MISMATCH: the template heading can never match");process.exit(1)}console.log("headings match")' skills/LifeOS/install/skills/LifeOS/Tools/PulseHealth.ts · exit 1 · captured 2026-11-12T20:51:38.469Z

Red looks like: SECTION MISMATCH

template heading normalizes to "key numbers (sample panel", user heading to "key number"
SECTION MISMATCH: the template heading can never match

Suggested fix

Drop the trailing parenthetical before the dash suffix, and once more after it so a heading like Foo (a) — bar keeps the key it has today:

export const headingKey = (h: string): string =>
  h.replace(/\s*\(.*\)\s*$/, "").replace(/\s*[—–-].*$/, "").replace(/\s*\(.*\)\s*$/, "").trim().toLowerCase().replace(/s$/, "");

Checked on one install: over 2,720 H2 headings in the template tree and a populated USER tree, 43 keys change, every one a heading whose trailing parenthetical held a dash or hyphen; the audit's output on the live tree is byte-identical before and after; the three METRICS headings above go from missing to matched. LIFEOS/TOOLS/GenerateTelosSummary.ts line 100 uses the same two-step order for titles and may want the same change; it was not touched or tested here.

Environment

  • OS: macOS 27.2.1 (arm64)
  • Harness: claude-code
  • bun: 1.4.4 · git: 2.54.0
  • Doctor broken: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions