Skip to content

code-yeongyu/oh-my-openagent / packages/shared-skills/skills/ulw-research

ulw-research

Unverified

Runs maximum-saturation research with a cooperating team, claim-graph gating, and a cited, QA'd deliverable. Use when the user explicitly asks for research or a deep investigation, including any 'ulw' research wording.

FileKindSize
AGENTS.mdmarkdown9.2 KB
ATTRIBUTION.mdmarkdown2.4 KB
SKILL.mdskill md42.2 KB
references/deliverable-phase.mdmarkdown49.1 KB
references/fact-ledger-grammar.mdmarkdown6.8 KB
references/fact-ledger.mdmarkdown24.4 KB
references/fidelity-claim-kinds.mdmarkdown5.2 KB
references/markdown-blocks.mdmarkdown721 B
references/report-gates.mdmarkdown32.0 KB
references/report-visualization.mdmarkdown15.4 KB
references/research-collection.mdmarkdown26.8 KB
references/research-delivery.mdmarkdown14.3 KB
references/unit-rules.mdmarkdown16.3 KB
scripts/claim-kinds.mjsscript11.2 KB
scripts/claim-kinds.test.tsscript13.5 KB
scripts/claim-prefix.test.tsscript4.9 KB
scripts/claims-index.mjsscript5.3 KB
scripts/claims-index.test.tsscript5.7 KB
scripts/cli-support.mjsscript4.1 KB
scripts/cli-support.test.tsscript4.3 KB
scripts/contracts-validation.test.tsscript3.3 KB
scripts/contracts.mjsscript26.1 KB
scripts/contracts.test.tsscript7.9 KB
scripts/conversion-altered.test.tsscript11.0 KB
scripts/conversion-originals.test.tsscript22.7 KB
scripts/conversion-probe-classes.test.tsscript45.2 KB
scripts/conversion-probe.mjsscript13.5 KB
scripts/conversion-probe.test.tsscript11.6 KB
scripts/copy-returns-fidelity-policy.test.tsscript10.4 KB
scripts/copy-returns-polish.test.tsscript12.1 KB
scripts/copy-returns.test.tsscript10.6 KB
scripts/css-hiding.mjsscript9.1 KB
scripts/css-lite.mjsscript7.6 KB
scripts/css-lite.test.tsscript6.4 KB
scripts/delivery-barrier-meaning.test.tsscript12.3 KB
scripts/delivery-barrier.test.tsscript11.4 KB
scripts/design-spec.mjsscript7.2 KB
scripts/design-spec.test.tsscript6.7 KB
scripts/entities.mjsscript2.5 KB
scripts/entry-guard.mjsscript794 B
scripts/fact-commands-fill.mjsscript6.6 KB
scripts/fact-commands-meaning.mjsscript12.6 KB
scripts/fact-commands-polish.mjsscript10.3 KB
scripts/fact-commands-verify.mjsscript12.6 KB
scripts/fact-commands.mjsscript13.8 KB
scripts/fact-derive-2.test.tsscript7.2 KB
scripts/fact-derive.mjsscript4.9 KB
scripts/fact-derive.test.tsscript10.8 KB
scripts/fact-expr.mjsscript4.5 KB
scripts/fact-fill.mjsscript11.7 KB
scripts/fact-fill.test.tsscript10.7 KB
scripts/fact-ledger-grammar.test.tsscript11.8 KB
scripts/fact-ledger-kinds.mjsscript16.5 KB
scripts/fact-ledger-kinds.test.tsscript9.3 KB
scripts/fact-ledger-legacy.test.tsscript8.9 KB
scripts/fact-ledger-schema.mjsscript11.9 KB
scripts/fact-ledger-schema.test.tsscript1.5 KB
scripts/fact-ledger.mjsscript5.5 KB
scripts/fact-ledger.test.tsscript9.7 KB
scripts/fact-locate.mjsscript12.1 KB
scripts/fact-locate.test.tsscript7.2 KB
scripts/fact-pairs.mjsscript8.3 KB
scripts/fact-pairs.test.tsscript6.6 KB
scripts/fact-recompute.mjsscript4.8 KB
scripts/fact-unit-dimensions-2.test.tsscript8.4 KB
scripts/fact-unit-dimensions.test.tsscript11.9 KB
scripts/fact-unit-rules.test.tsscript8.9 KB
scripts/fidelity-binding.mjsscript6.7 KB
scripts/fidelity-binding.test.tsscript4.0 KB
scripts/fidelity-brief.mjsscript6.4 KB
scripts/fidelity-brief.test.tsscript7.8 KB
scripts/fidelity-claims.mjsscript5.1 KB
scripts/fidelity-csv.mjsscript1.1 KB
scripts/fidelity-lexicon.mjsscript8.1 KB
scripts/fidelity-lexicon.test.tsscript6.0 KB
scripts/fidelity-originals.mjsscript9.9 KB
scripts/fidelity-policy.mjsscript10.1 KB
scripts/fidelity-records.mjsscript13.4 KB
scripts/fidelity-snapshot-readability.mjsscript2.2 KB
scripts/fidelity-sources.mjsscript4.3 KB
scripts/fidelity-state.mjsscript2.1 KB
scripts/fidelity-state.test.tsscript1.7 KB
scripts/fidelity-trace.mjsscript6.1 KB
scripts/fidelity-trace.test.tsscript3.3 KB
scripts/fidelity-value-unit.mjsscript13.3 KB
scripts/fidelity-values.mjsscript16.1 KB
scripts/fidelity-values.test.tsscript15.8 KB
scripts/format-extract-css.mjsscript5.1 KB
scripts/format-extract.mjsscript10.3 KB
scripts/format-extract.test.tsscript11.2 KB
scripts/gates-context.test.tsscript2.6 KB
scripts/gates-fidelity.mjsscript6.3 KB
scripts/gates-fidelity.test.tsscript3.3 KB
scripts/gates-figures.mjsscript9.9 KB
scripts/gates-layout.mjsscript6.6 KB
scripts/gates-layout.test.tsscript12.4 KB
scripts/gates-static-headings.test.tsscript961 B
scripts/gates-static.mjsscript8.1 KB
scripts/gates-static.test.tsscript14.9 KB
scripts/gates-structure.mjsscript4.7 KB
scripts/gates-text.mjsscript7.2 KB
scripts/glossary-vocabulary.test.tsscript1.7 KB
scripts/html-foreign-object.mjsscript2.8 KB
scripts/html-lite.mjsscript9.7 KB
scripts/html-lite.test.tsscript7.9 KB
scripts/html-markup.mjsscript7.0 KB
scripts/html-text-map.mjsscript4.8 KB
scripts/html-text-map.test.tsscript15.2 KB
scripts/layout-probe.mjsscript4.6 KB
scripts/layout-probe.test.tsscript4.2 KB
scripts/lexicon.mjsscript2.6 KB
scripts/lexicon.test.tsscript3.2 KB
scripts/markdown-closers.mjsscript4.9 KB
scripts/md-lite-boundaries.test.tsscript2.2 KB
scripts/md-lite.mjsscript7.8 KB
scripts/md-lite.test.tsscript10.3 KB
scripts/meaning-check.mjsscript9.7 KB
scripts/meaning-check.test.tsscript12.0 KB
scripts/number-grammar.mjsscript2.1 KB
scripts/number-grammar.test.tsscript1.8 KB
scripts/numerals.mjsscript12.0 KB
scripts/numerals.test.tsscript6.1 KB
scripts/outcome-start.mjsscript3.8 KB
scripts/outcome-start.test.tsscript5.0 KB
scripts/outcome.mjsscript10.5 KB
scripts/outcome.test.tsscript12.8 KB
scripts/page-source-locator.test.tsscript11.7 KB
scripts/particles-ko.mjsscript4.8 KB
scripts/particles-ko.test.tsscript4.3 KB
scripts/placeholder.mjsscript9.3 KB
scripts/placeholder.test.tsscript3.8 KB
scripts/polish-apply.mjsscript6.8 KB
scripts/polish-apply.test.tsscript19.7 KB
scripts/polish-diff.mjsscript1.7 KB
scripts/polish-diff.test.tsscript10.1 KB
scripts/polish-markup.test.tsscript14.0 KB
scripts/polish-partial.test.tsscript2.5 KB
scripts/polish-project.mjsscript5.8 KB
scripts/polish-rules.mjsscript9.8 KB
scripts/rational.mjsscript5.2 KB
scripts/rational.test.tsscript1.9 KB
scripts/raw-decode.mjsscript4.5 KB
scripts/raw-locator.mjsscript2.4 KB
scripts/raw-snapshot.test.tsscript7.3 KB
scripts/references-fences.test.tsscript1.2 KB
scripts/repair-tracker.mjsscript7.5 KB
scripts/repair-tracker.test.tsscript10.8 KB
scripts/report-tools-2.test.tsscript16.1 KB
scripts/report-tools-3.test.tsscript9.3 KB
scripts/report-tools-4.test.tsscript10.1 KB
scripts/report-tools-5.test.tsscript14.6 KB
scripts/report-tools-commands.mjsscript12.9 KB
scripts/report-tools.mjsscript2.6 KB
scripts/report-tools.test.tsscript12.1 KB
scripts/sentence-split.mjsscript3.0 KB
scripts/sentence-split.test.tsscript4.5 KB
scripts/snapshot-readability.test.tsscript7.0 KB
scripts/source-commands.mjsscript12.4 KB
scripts/source-integrity.test.tsscript18.1 KB
scripts/source-refresh.mjsscript5.2 KB
scripts/source-snapshot.mjsscript9.9 KB
scripts/source-snapshot.test.tsscript6.3 KB
scripts/source-view.mjsscript5.0 KB
scripts/sources-citation.mjsscript12.1 KB
scripts/sources-citation.test.tsscript14.8 KB
scripts/tests/contracts-support.tsscript3.5 KB
scripts/tests/delivery-barrier-session.tsscript3.3 KB
scripts/tests/derive-clock.tsscript341 B
scripts/tests/fact-derive-support.tsscript1.9 KB
scripts/tests/fact-unit-dimensions-support.tsscript1.5 KB
scripts/tests/fact-unit-rules-support.tsscript16.8 KB
scripts/tests/fidelity-values-support.tsscript1.6 KB
scripts/tests/fixtures/assets/figure-1.svgother141 B
scripts/tests/fixtures/bad-report.htmlother2.1 KB
scripts/tests/fixtures/boxes.jsonconfig3.2 KB
scripts/tests/fixtures/conversion-probe.htmlother485 B
scripts/tests/fixtures/design-spec.mdmarkdown458 B
scripts/tests/fixtures/fidelity-brief-locked.mdmarkdown571 B
scripts/tests/fixtures/fidelity-brief-pending.mdmarkdown574 B
scripts/tests/fixtures/fidelity/assets/share.csvother40 B
scripts/tests/fixtures/fidelity/claim-graph.mdmarkdown449 B
scripts/tests/fixtures/fidelity/gen-legacy-dev.mjsscript5.0 KB
scripts/tests/fixtures/fidelity/ledger-basic.jsonconfig5.1 KB
scripts/tests/fixtures/fidelity/ledger-legacy-dev.jsonconfig18.3 KB
scripts/tests/fixtures/fidelity/ledger-verify.jsonconfig9.1 KB
scripts/tests/fixtures/fidelity/polish-edits.jsonconfig303 B
scripts/tests/fixtures/fidelity/report-bad.htmlother821 B
scripts/tests/fixtures/fidelity/report-good.htmlother2.4 KB
scripts/tests/fixtures/fidelity/sources/S4.htmlother680 B
scripts/tests/fixtures/fidelity/sources/S4/acronyms.jsonconfig36 B
scripts/tests/fixtures/fidelity/sources/S4/meta.jsonconfig256 B
scripts/tests/fixtures/fidelity/sources/S4/sentences.jsonlother623 B
scripts/tests/fixtures/fidelity/sources/S4/text.txtmarkdown300 B
scripts/tests/fixtures/fidelity/sources/S5/acronyms.jsonconfig3 B
scripts/tests/fixtures/fidelity/sources/S5/meta.jsonconfig235 B
scripts/tests/fixtures/fidelity/sources/S5/sentences.jsonlother53 B
scripts/tests/fixtures/fidelity/sources/S5/text.txtmarkdown10 B
scripts/tests/fixtures/fidelity/sources/S9.txtmarkdown128 B
scripts/tests/fixtures/good-report.htmlother2.7 KB
scripts/tests/fixtures/reference-report.htmlother2.5 KB

scripts/report-tools-5.test.ts

View on GitHub
import { describe, expect, onTestFinished, test } from "bun:test"
import { createHash } from "node:crypto"
import { copyFileSync, existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os"
import { delimiter, join } from "node:path"
import { PROMOTION } from "./fact-commands-meaning.mjs"
import { writeFidelityRecord } from "./fidelity-records.mjs"
import { PAIR_KINDS } from "./fact-pairs.mjs"
import { VERDICT_SCHEMA } from "./meaning-check.mjs"
import { POLISH_MARKUP_REASON } from "./polish-apply.mjs"
import { COMMANDS, run } from "./report-tools.mjs"
import {
  SCRIPT,
  FIXTURES,
  NOW,
  sessionDir,
  nodeWithoutBun,
  defectsFile,
  FIDELITY,
  sha256,
  CliRow,
  CliJson,
  nodeJson,
  fidelitySession,
  verify,
  codesOf,
  Pair,
  pairedSession,
  verdicts,
  calibrationRows,
  runLines,
  PolishJson,
  polishSession,
  polishApply,
  setField,
  fillTemplate,
  textSource,
  ledgerRow,
} from "./tests/report-tools-support"

describe("fidelity brief lock and policy under node", () => {
  test("#given a filled session whose brief turns pending #when each reader-facing command runs #then all six exit 1 with only fidelity_interview_incomplete and write nothing", () => {
    // given
    const { dir, s } = pairedSession()
    copyFileSync(join(FIXTURES, "fidelity-brief-pending.md"), join(dir, "brief.md"))
    for (const name of ["fidelity-defects.json", "pairs.json"]) rmSync(join(dir, name), { force: true })
    const drift = verdicts(dir, "cheap.json", "cheap", [])
    writeFileSync(join(dir, "edits.json"), "[]")
    // when
    const runs = {
      fill: nodeJson(["fact", "fill", join(dir, "report.src.html"), "--out", join(dir, "again.html"), ...s]),
      verify: verify(dir, "report.html"),
      pairs: nodeJson(["fact", "pairs", join(dir, "report.html"), "--out", join(dir, "pairs.json"), ...s]),
      meaning: nodeJson([
        "fact",
        "meaning-check",
        "--pairs",
        join(dir, "absent-pairs.json"),
        "--verdicts",
        drift,
        ...s,
      ]),
      polishApply: nodeJson([
        "fact",
        "polish-apply",
        join(dir, "report.html"),
        "--edits",
        join(dir, "edits.json"),
        "--out",
        join(dir, "polished.html"),
        ...s,
      ]),
      polishDiff: nodeJson([
        "fact",
        "polish-diff",
        "--before",
        join(dir, "report.html"),
        "--after",
        join(dir, "report.html"),
        "--out",
        join(dir, "polish.json"),
        ...s,
      ]),
    }
    // then
    for (const [name, result] of Object.entries(runs)) {
      expect({ name, code: result.code, codes: codesOf(result.json) }).toEqual({
        name,
        code: 1,
        codes: ["fidelity_interview_incomplete"],
      })
    }
    for (const name of [
      "again.html",
      "fidelity-defects.json",
      "pairs.json",
      "polished.html",
      "polish.json",
      "fidelity-meaning-defects.json",
    ])
      expect({ name, exists: existsSync(join(dir, name)) }).toEqual({ name, exists: false })
  })

  test("#given derived numbers none #when a derived or a converted placeholder is filled #then derived_not_allowed, and allowed renders both", () => {
    // given
    const { dir, s, mm } = fidelitySession()
    const expr = nodeJson([
      "fact",
      "derive",
      "--op",
      "expr",
      "F1 * 2",
      "--unit",
      "m",
      "--rationale",
      "two spans",
      "--label",
      "two_spans",
      "--now",
      NOW,
      "--json",
      ...s,
    ])
    const twice = expr.json.data.row.fact_id
    setField(dir, "derived numbers", "none")
    // when
    const derived = fillTemplate(dir, `<p>Two spans are {{${twice}:two_spans}} [S4].</p>`)
    const converted = fillTemplate(dir, `<p>The span is {{${mm}:span_mm}} [S4].</p>`)
    setField(dir, "derived numbers", "allowed")
    const allowed = fillTemplate(
      dir,
      `<p>Two spans are {{${twice}:two_spans}} [S4]. The span is {{${mm}:span_mm}} [S4].</p>`,
    )
    // then
    expect(expr.code).toBe(0)
    expect([derived.code, codesOf(derived.json)]).toEqual([1, ["derived_not_allowed"]])
    expect([converted.code, codesOf(converted.json)]).toEqual([1, ["derived_not_allowed"]])
    expect(allowed.code).toBe(0)
    expect(readFileSync(join(dir, "t.html"), "utf8")).toContain("320,000 mm")
  })

  test("#given source floor primary only #when rows from secondary, unknown, and primary sources are filled #then only the primary row renders", () => {
    // given
    const { dir } = fidelitySession()
    const secondary = textSource(dir, "S7", "secondary")
    const unknown = textSource(dir, "S8")
    const primary = textSource(dir, "S6", "primary")
    setField(dir, "source floor", "primary only")
    // when
    const fills = [secondary, unknown, primary].map(({ row }) =>
      fillTemplate(dir, `<p>The span is {{${row.fact_id}:${row.label}}} [S4].</p>`),
    )
    // then
    expect(
      [secondary.snap.json, unknown.snap.json, primary.snap.json].map(
        (json) => (json as unknown as { data: { provenance: string } }).data.provenance,
      ),
    ).toEqual(["secondary", "unknown", "primary"])
    expect(fills.map((f) => [f.code, codesOf(f.json)])).toEqual([
      [1, ["source_outside_floor"]],
      [1, ["source_outside_floor"]],
      [0, []],
    ])
  })

  test("#given a row registered while source floor is pending #when the floor locks to pointed only S4, then standard #then fill refuses, then renders, and outside_floor caches each result", () => {
    // given
    const { dir } = fidelitySession()
    setField(dir, "source floor", "pending", "pending")
    const { snap, row } = textSource(dir, "S9")
    const body = `<p>The span is {{${row.fact_id}:${row.label}}} [S9].</p>`
    // when
    setField(dir, "source floor", "pointed only: S4")
    const refused = fillTemplate(dir, body)
    const cachedRefused = ledgerRow(dir, row.fact_id).outside_floor
    setField(dir, "source floor", "standard")
    const rendered = fillTemplate(dir, body)
    // then
    expect(snap.code).toBe(0)
    expect(row.outside_floor).toBe(false)
    expect([refused.code, codesOf(refused.json)]).toEqual([1, ["source_outside_floor"]])
    expect(cachedRefused).toBe(true)
    expect(rendered.code).toBe(0)
    expect(ledgerRow(dir, row.fact_id).outside_floor).toBe(false)
  })

  test("#given a markdown translation comment after a quote #when languages is translation beside, then quotes original #then fact pairs emits a translation pair only for the first", () => {
    // given
    const { dir, s } = fidelitySession()
    const md = [
      "# T",
      "",
      "## Findings",
      "",
      "The operator wrote {{Q1:completion}} <!-- translates: Q1 --> completion comes in 2027 at the earliest [S4].",
      "",
    ].join("\n")
    writeFileSync(join(dir, "t.src.md"), md)
    const kinds = () => {
      const filled = nodeJson([
        "fact",
        "fill",
        join(dir, "t.src.md"),
        "--format",
        "md",
        "--out",
        join(dir, "t.md"),
        ...s,
      ])
      const pairs = nodeJson(["fact", "pairs", join(dir, "t.md"), "--out", join(dir, "pairs.json"), ...s])
      return {
        fill: filled.code,
        pairs: pairs.code,
        kinds: JSON.parse(readFileSync(join(dir, "pairs.json"), "utf8")).pairs.map((p: Pair) => p.kind),
      }
    }
    // when
    const beside = kinds()
    setField(dir, "languages", "report en; sources en; quotes original")
    const original = kinds()
    // then
    expect(beside).toEqual({ fill: 0, pairs: 0, kinds: ["quote", "translation"] })
    expect(original).toEqual({ fill: 0, pairs: 0, kinds: ["quote"] })
  })

  test("#given a sentence that failed twice #when filled with --replace-failed #then block-quote replaces it and fallback omit removes it", () => {
    // given
    const { dir } = fidelitySession()
    const state = { schemaVersion: 1, failures: { "findings#F1": 2 }, replaced: [] }
    const body = "<p>The span length is {{F1:span_len}} [S4]. The operator wrote {{Q1:completion}} [S4].</p>"
    // when
    writeFileSync(join(dir, "fidelity-state.json"), JSON.stringify(state))
    const quoted = fillTemplate(dir, body, ["--replace-failed"])
    const quotedHtml = readFileSync(join(dir, "t.html"), "utf8")
    setField(dir, "fallback", "omit")
    writeFileSync(join(dir, "fidelity-state.json"), JSON.stringify(state))
    const omitted = fillTemplate(dir, body, ["--replace-failed"])
    const omittedHtml = readFileSync(join(dir, "t.html"), "utf8")
    // then
    expect(quoted.code).toBe(0)
    expect(quotedHtml).toContain("<blockquote")
    expect(omitted.code).toBe(0)
    expect(omittedHtml).not.toContain("<blockquote")
    expect(omittedHtml).not.toContain("The span length is")
    expect(omittedHtml).toContain("The operator wrote")
  })

  test("#given --calibration #when meaning-check flags a pair #then the calibration line goes to that path, not the session default", () => {
    const { dir, s } = pairedSession()
    const drift = {
      pair_id: "P2",
      verdict: "drift",
      drift_kind: "hedge_dropped",
      fragment: "no earlier than 2027",
      source_fragment: "we estimate",
    }
    const log = join(dir, "custom-calibration.jsonl")
    const checked = nodeJson([
      "fact",
      "meaning-check",
      "--pairs",
      join(dir, "pairs.json"),
      "--verdicts",
      verdicts(dir, "cheap.json", "cheap", [drift, { pair_id: "P1", verdict: "ok" }]),
      "--calibration",
      log,
      ...s,
    ])
    const rows = readFileSync(log, "utf8")
      .trim()
      .split("\n")
      .map((line) => JSON.parse(line))
      .filter((row) => row.header !== true && row.run !== true)
    expect(checked.code).toBe(0)
    expect(rows).toHaveLength(1)
    expect(existsSync(join(dir, "fidelity-calibration.jsonl"))).toBe(false)
  })
})

describe("fidelity brief values, sourceless rows, and the brief binding under node", () => {
  test("#given derived numbers or fallback off its table #when fact fill runs #then a usage error names the field and value and nothing is written", () => {
    // given
    const { dir, s } = fidelitySession()
    const twice = nodeJson([
      "fact",
      "derive",
      "--op",
      "expr",
      "F1 * 2",
      "--unit",
      "m",
      "--rationale",
      "two spans",
      "--label",
      "two_spans",
      "--now",
      NOW,
      "--json",
      ...s,
    ]).json.data.row.fact_id
    // when
    setField(dir, "derived numbers", "nope")
    const derived = fillTemplate(dir, `<p>Two spans are {{${twice}:two_spans}} [S4].</p>`)
    setField(dir, "derived numbers", "allowed")
    setField(dir, "fallback", "drop")
    const fallback = fillTemplate(dir, "<p>The span length is {{F1:span_len}} [S4].</p>")
    // then
    expect({ code: derived.code, named: derived.stderr.includes('derived numbers "nope"') }).toEqual({
      code: 2,
      named: true,
    })
    expect({ code: fallback.code, named: fallback.stderr.includes('fallback "drop"') }).toEqual({
      code: 2,
      named: true,
    })
    expect(existsSync(join(dir, "t.html"))).toBe(false)
  })

  test("#given an assumed row #when filled under primary only, then standard #then the sourceless row is source_outside_floor, then renders", () => {
    // given
    const { dir, s } = fidelitySession()
    const assumed = nodeJson([
      "fact",
      "add",
      "--assumed",
      "12",
      "--unit",
      "%",
      "--rationale",
      "planning share chosen by the requester",
      "--label",
      "share_assumed",
      "--json",
      ...s,
    ]).json.data.row.fact_id
    const body = `<p>The planning share is {{${assumed}:share_assumed}}.</p>`
    // when
    setField(dir, "source floor", "primary only")
    const refused = fillTemplate(dir, body)
    setField(dir, "source floor", "standard")
    const rendered = fillTemplate(dir, body)
    // then
    expect([refused.code, codesOf(refused.json)]).toEqual([1, ["source_outside_floor"]])
    expect(JSON.stringify(refused.json)).toContain("no source")
    expect(rendered.code).toBe(0)
  })

  test("#given a derived row whose operand rests on a secondary source #when filled under primary only #then source_outside_floor names that source", () => {
    // given
    const { dir, s } = fidelitySession()
    const { row } = textSource(dir, "S7", "secondary")
    const twice = nodeJson([
      "fact",
      "derive",
      "--op",
      "expr",
      `${row.fact_id} * 2`,
      "--unit",
      "m",
      "--rationale",
      "two spans",
      "--label",
      "two_spans",
      "--now",
      NOW,
      "--json",
      ...s,
    ]).json.data.row.fact_id
    setField(dir, "source floor", "primary only")
    // when
    const refused = fillTemplate(dir, `<p>Two spans are {{${twice}:two_spans}} [S7].</p>`)
    // then
    expect([refused.code, codesOf(refused.json)]).toEqual([1, ["source_outside_floor"]])
    expect(JSON.stringify(refused.json)).toContain("rests on S7")
  })

  test("#given an edition filled under standard from a secondary source #when the brief tightens to primary only #then fact verify refuses with and without its fill map", () => {
    // given
    const { dir, s } = fidelitySession()
    const { row } = textSource(dir, "S7", "secondary")
    const src = readFileSync(join(dir, "report.src.html"), "utf8")
      .replace("<h2>How", `<p>A review gives the span as {{${row.fact_id}:${row.label}}} [S7].</p>\n<h2>How`)
      .replace("</ol>", '<li id="s7">[S7] Bridge review, retrieved 2026-10-01.</li></ol>')
    writeFileSync(join(dir, "report.src.html"), src)
    const filled = nodeJson(["fact", "fill", join(dir, "report.src.html"), "--out", join(dir, "report.html"), ...s])
    const map = join(dir, "report.html.fill-map.json")
    const before = verify(dir, "report.html")
    // when
    setField(dir, "source floor", "primary only")
    const bound = verify(dir, "report.html")
    const record = JSON.parse(readFileSync(join(dir, "fidelity-defects.json"), "utf8"))
    const kept = readFileSync(map, "utf8")
    rmSync(map)
    const unbound = verify(dir, "report.html")
    setField(dir, "source floor", "standard")
    const { brief_sha256: _dropped, ...legacy } = JSON.parse(kept)
    writeFileSync(map, JSON.stringify(legacy))
    const unstamped = verify(dir, "report.html")
    // then
    expect([filled.code, before.code, codesOf(before.json)]).toEqual([0, 0, []])
    expect(typeof JSON.parse(kept).brief_sha256).toBe("string")
    expect(bound.code).toBe(1)
    expect(codesOf(bound.json)).toContain("brief_changed")
    expect(codesOf(bound.json)).toContain("source_outside_floor")
    expect(record.status).toBe("fail")
    expect(unbound.code).toBe(1)
    expect(codesOf(unbound.json)).toContain("source_outside_floor")
    expect(codesOf(unbound.json)).toContain("brief_changed")
    expect([unstamped.code, codesOf(unstamped.json)]).toEqual([1, ["brief_changed"]])
  })
})
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