diff --git a/README.md b/README.md index aded327..6b3bd65 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ node bin/projectlens.mjs compare \ Replace the export paths and pasted text with your own files. [The guide](docs/USE_ON_YOUR_OWN_SCHEDULES.md) covers formats, batch comparisons and exit codes. -**Measured results (reproduce with `npm run bench`):** set 4 is **28/30** on cases that shaped the rules (regression evidence, not independent accuracy). Set 5 is **29/40** on the committed fixture [`bench/real-cases/projectlens-heldout5.json`](bench/real-cases/projectlens-heldout5.json); the floor is 29. On the job that matters most — labelled contradictions — set 5 catches **3 of 10**. Sets 1–4 informed the rules. Do not treat any of these totals as production accuracy. Cases and sources: [bench/real-cases/](bench/real-cases/). +**Measured results (reproduce with `npm run bench`):** across all five sets of real published UK government project data (172 cases), the check catches **47 of 52** labelled contradictions (11 of them are updates that never mention a moved finish, reported as a separate "not mentioned" finding), and wrongly flags **5 of 63** updates that do explain the move. Set 5 alone moved from 3 of 10 contradictions caught to 7 of 10 after the 28 Nov "silent update" rule, so set 5 has now shaped the rules too; no unseen set has been scored since. Do not treat any of these totals as production accuracy. Cases and sources: [bench/real-cases/](bench/real-cases/). **Browser:** [Open the example review](https://matthewpaver.github.io/ProjectLens/change-assurance.html), then select **Try the example project** (made-up Northstar) or use your own schedules. No install or account needed. The browser also records a human decision and its conditions. diff --git a/bench/real-cases/floors.json b/bench/real-cases/floors.json index b3512b0..f621c6c 100644 --- a/bench/real-cases/floors.json +++ b/bench/real-cases/floors.json @@ -1,7 +1,7 @@ { "projectlens-heldout.json": 32, - "projectlens-heldout2.json": 29, - "projectlens-heldout3.json": 28, + "projectlens-heldout2.json": 30, + "projectlens-heldout3.json": 32, "projectlens-heldout4.json": 28, - "projectlens-heldout5.json": 29 + "projectlens-heldout5.json": 33 } diff --git a/bench/real-cases/run.mjs b/bench/real-cases/run.mjs index 7b3ebab..e301ab1 100644 --- a/bench/real-cases/run.mjs +++ b/bench/real-cases/run.mjs @@ -22,7 +22,8 @@ for (const file of sets) { let right = 0; for (const p of pairs) { const r = E.detectScheduleClaims(p.narrative || '', { previousFinish: p.prevEnd, currentFinish: p.curEnd }); - const got = r.contradiction ? 'contradiction' : (r.publishedDateCheck ? 'published-date-check' : 'none'); + // A silent update (finish moved, never mentioned) counts as catching a contradiction; it is reported separately in the CLI and browser. + const got = r.contradiction || r.silentMove ? 'contradiction' : (r.publishedDateCheck ? 'published-date-check' : 'none'); const want = p.label === 'contradiction' || p.label === 'published-date-check' ? p.label : 'none'; const ok = got === want; byLabel[p.label] ||= [0, 0]; diff --git a/bin/projectlens.mjs b/bin/projectlens.mjs index c0e7ea3..b6d814e 100755 --- a/bin/projectlens.mjs +++ b/bin/projectlens.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node /** * ProjectLens local CLI — compare two schedules, or batch a folder by project. - * No network calls. Exit 0 = no contradiction, 1 = contradiction found, 3 = input error. + * No network calls. Exit 0 = nothing to review, 1 = contradiction or unmentioned finish move found, 3 = input error. */ import fs from "node:fs"; import path from "node:path"; @@ -84,6 +84,7 @@ function comparePair(previous, current, narrative, { confirmedMatch = true } = { dataDatePrevious: iso(previous.project.dataDate), dataDateCurrent: iso(current.project.dataDate), contradiction: Boolean(claims.contradiction) || review.blockers.some(b => b.type === "Contradiction"), + unmentionedMove: Boolean(claims.silentMove), narrativeClaim: claims.stable[0]?.phrase || claims.movesStated[0] && "move stated" || "", claim: engine.findingSentence(claims, { currentFinish: current.project.scheduledFinish, @@ -151,7 +152,7 @@ function cmdCompare(args) { fail(error.message || String(error)); } process.stdout.write(formatResult(result, format)); - process.exit(result.contradiction ? 1 : 0); + process.exit(result.contradiction || result.unmentionedMove ? 1 : 0); } function listScheduleFiles(dir) { @@ -203,7 +204,7 @@ function cmdBatch(args) { const current = group[i].schedule; try { const result = comparePair(previous, current, narrative); - anyContradiction = anyContradiction || result.contradiction; + anyContradiction = anyContradiction || result.contradiction || result.unmentionedMove; rows.push({ project: result.project, previous_date: result.dataDatePrevious, diff --git a/docs/engine/projectlens-engine.js b/docs/engine/projectlens-engine.js index 61bcf9d..40fd7b5 100644 --- a/docs/engine/projectlens-engine.js +++ b/docs/engine/projectlens-engine.js @@ -1271,6 +1271,14 @@ function detectScheduleClaims(text, { currentFinish = null, previousFinish = nul // A move that lands on the published finish clears any contradiction. if (landed) contradiction = null; + // Separate from a contradiction: the finish moved more than 14 days and the update never mentions any change. + // ponytail: loose wording check on purpose; any change language (or "not on track") counts as mentioned, so a person reads it. + const mentionsChange = /\b(?:delay\w*|slip\w*|revis\w*|extend\w*|extension|push\w*|behind|later|moved?|movement|change[sd]?|re-?baselin\w*|re-?profil\w*|re-?phas\w*|re-?plan\w*|re-?approv\w*|end[\s-]?date|completion date|closed|closure|rebalanc\w*|deferr?\w*|postpon\w*|reschedul\w*|not\s+(?:on|in\s+line))\b/i.test(source); + const silentMove = !contradiction && !publishedDateCheck && finishMoved && !covered && !mentionsChange + && Math.abs(dayDeltaIso(currentFinish, previousFinish)) > 14 + ? { detail: `The finish moved from ${toIsoDay(previousFinish)} to ${toIsoDay(currentFinish)}, and the update does not mention it.` } + : null; + // A previous-finish that disagrees with previousFinish is a note, not a contradiction. let previousDateNote = null; const previous = toIsoDay(previousFinish); @@ -1317,6 +1325,7 @@ function detectScheduleClaims(text, { currentFinish = null, previousFinish = nul contradiction, previousDateNote, publishedDateCheck, + silentMove, evidence, }; } @@ -1335,6 +1344,9 @@ function findingSentence(claims, { currentFinish = null, previousFinish = null } if (claims.evidence.narrativeDate) return `The narrative gives the end date as ${narrativeDate}; the published end date is ${formatDate(parseDate(currentFinish))}. Check which is current.`; return claims.contradiction.detail; } + if (claims.silentMove) { + return `The update does not mention the finish date moving. The schedule's finish moved from ${formatDate(parseDate(previousFinish))} to ${formatDate(parseDate(currentFinish))} (${dayDeltaIso(currentFinish, previousFinish)} days).`; + } if (dayDeltaIso(currentFinish, previousFinish) && moveCoversCurrent(claims.movesStated, currentFinish, previousFinish)) return "The narrative explains the move."; return null; } diff --git a/tests/engine/claims.test.mjs b/tests/engine/claims.test.mjs index 800e0a5..c9ef5ab 100644 --- a/tests/engine/claims.test.mjs +++ b/tests/engine/claims.test.mjs @@ -10,10 +10,12 @@ import { describe, it } from "node:test"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const REPO = path.resolve(__dirname, "../.."); const RESEARCH = path.resolve(REPO, "../research_notes/Real case tests/projectlens-inputs"); +const NEEDS_FIXTURES = fs.existsSync(RESEARCH) ? {} : { skip: "needs local fixtures in ../research_notes/Real case tests/projectlens-inputs" }; const require = createRequire(import.meta.url); const engine = require(path.join(REPO, "docs/engine/projectlens-engine.js")); -const pairs = JSON.parse(fs.readFileSync(path.join(RESEARCH, "gmpp_pairs.json"), "utf8")); +const pairsPath = path.join(RESEARCH, "gmpp_pairs.json"); +const pairs = fs.existsSync(pairsPath) ? JSON.parse(fs.readFileSync(pairsPath, "utf8")) : []; describe("explained moves retain historical dates and capability scope", () => { for (const predicate of ["was previously scheduled", "was originally expected"]) { @@ -58,7 +60,7 @@ describe("detectScheduleClaims", () => { assert.ok(rules.movePhrases.includes("correction of published position")); }); - it("Land ISTAR 2025→2026: date in narrative mismatches current finish", () => { + it("Land ISTAR 2025→2026: date in narrative mismatches current finish", NEEDS_FIXTURES, () => { const p = pair(/ISTAR/i, 2025, 2026); const result = engine.detectScheduleClaims(p.narrative, { currentFinish: p.curEnd, @@ -67,7 +69,7 @@ describe("detectScheduleClaims", () => { assert.equal(result.contradiction?.kind, "date-mismatch"); }); - it("E7 Wedgetail 2025→2026: contradiction while finish moved", () => { + it("E7 Wedgetail 2025→2026: contradiction while finish moved", NEEDS_FIXTURES, () => { const p = pair(/Wedgetail/i, 2025, 2026); const result = engine.detectScheduleClaims(p.narrative, { currentFinish: p.curEnd, @@ -77,7 +79,7 @@ describe("detectScheduleClaims", () => { assert.ok(["says-unchanged", "date-mismatch"].includes(result.contradiction.kind)); }); - it("E7 Wedgetail 2021→2022: stated move suppresses contradiction", () => { + it("E7 Wedgetail 2021→2022: stated move suppresses contradiction", NEEDS_FIXTURES, () => { const p = pair(/Wedgetail/i, 2021, 2022); const result = engine.detectScheduleClaims(p.narrative, { currentFinish: p.curEnd, @@ -117,7 +119,7 @@ describe("detectScheduleClaims", () => { } }); - it("gives no contradiction when a stated move lands on the published finish", () => { + it("gives no contradiction when a stated move lands on the published finish", NEEDS_FIXTURES, () => { // Round 2 N3: a move only suppresses when it lands on currentFinish (within 14 days). const candidates = pairs.filter(p => Math.abs(p.deltaDays) >= 7 && (p.explainsCorrection || (p.mentionsMove && !p.claimsSame))); assert.ok(candidates.length > 0); diff --git a/tests/engine/hygiene.test.mjs b/tests/engine/hygiene.test.mjs index 3ec1f5a..33e803b 100644 --- a/tests/engine/hygiene.test.mjs +++ b/tests/engine/hygiene.test.mjs @@ -9,6 +9,7 @@ import { describe, it } from "node:test"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const REPO = path.resolve(__dirname, "../.."); const RESEARCH = path.resolve(REPO, "../research_notes/Real case tests/projectlens-inputs"); +const NEEDS_FIXTURES = fs.existsSync(RESEARCH) ? {} : { skip: "needs local fixtures in ../research_notes/Real case tests/projectlens-inputs" }; const require = createRequire(import.meta.url); const engine = require(path.join(REPO, "docs/engine/projectlens-engine.js")); @@ -31,7 +32,7 @@ describe("real-export hygiene", () => { assert.equal(decoded.encoding, "windows-1252"); }); - it("listProjects finds 2+ projects in the multi-project variant", () => { + it("listProjects finds 2+ projects in the multi-project variant", NEEDS_FIXTURES, () => { assert.equal(typeof engine.listProjects, "function"); const text = fs.readFileSync(path.join(RESEARCH, "variants/R4-multiproject/two-projects.xer"), "utf8"); const projects = engine.listProjects(text); @@ -39,7 +40,7 @@ describe("real-export hygiene", () => { assert.ok(projects.every(p => p.projId && p.activityCount >= 0)); }); - it("completed-work-only update does not raise Evidence gap for blank float", () => { + it("completed-work-only update does not raise Evidence gap for blank float", NEEDS_FIXTURES, () => { // R1 current has blank float on completed activities — that must not be an evidence gap. const previous = engine.parseXerAssurance( fs.readFileSync(path.join(RESEARCH, "variants/R1-airport-terminal2/previous.xer"), "utf8"), @@ -60,7 +61,7 @@ describe("real-export hygiene", () => { ); }); - it("6,977-activity file compares in under 2000 ms", () => { + it("6,977-activity file compares in under 2000 ms", NEEDS_FIXTURES, () => { const prevPath = path.join(RESEARCH, "variants/R2-rehab-large/previous.xer"); const curPath = path.join(RESEARCH, "variants/R2-rehab-large/current.xer"); const prevText = fs.readFileSync(prevPath); diff --git a/tests/engine/identity.test.mjs b/tests/engine/identity.test.mjs index dec4478..f62fc0e 100644 --- a/tests/engine/identity.test.mjs +++ b/tests/engine/identity.test.mjs @@ -9,6 +9,7 @@ import { describe, it } from "node:test"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const REPO = path.resolve(__dirname, "../.."); const RESEARCH = path.resolve(REPO, "../research_notes/Real case tests/projectlens-inputs"); +const NEEDS_FIXTURES = fs.existsSync(RESEARCH) ? {} : { skip: "needs local fixtures in ../research_notes/Real case tests/projectlens-inputs" }; const require = createRequire(import.meta.url); const engine = require(path.join(REPO, "docs/engine/projectlens-engine.js")); @@ -41,7 +42,7 @@ describe("matchProjects", () => { assert.equal(typeof engine.matchProjects, "function"); }); - it("same real-xer with rewritten proj_id and name scores same", () => { + it("same real-xer with rewritten proj_id and name scores same", NEEDS_FIXTURES, () => { const original = read("xer-splitter-airport/airport.xer"); const rewritten = rewriteIdentity(original, { projId: "99999", shortName: "TERMINAL-2-UPD01" }); const previous = engine.parseXerAssurance(original, "airport.xer"); @@ -54,7 +55,7 @@ describe("matchProjects", () => { assert.ok(match.shared > 0); }); - it("two unrelated real-xer files score different", () => { + it("two unrelated real-xer files score different", NEEDS_FIXTURES, () => { const a = engine.parseXerAssurance(read("ashspace-sample/sample.xer"), "ashspace.xer"); const b = engine.parseXerAssurance(read("p6-analyzer-example/example_xer_file.xer"), "example.xer"); const match = engine.matchProjects(a, b); diff --git a/tests/engine/parity.test.mjs b/tests/engine/parity.test.mjs index 44ad4bd..e292520 100644 --- a/tests/engine/parity.test.mjs +++ b/tests/engine/parity.test.mjs @@ -11,6 +11,7 @@ import { describe, it } from "node:test"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const REPO = path.resolve(__dirname, "../.."); const RESEARCH = path.resolve(REPO, "../research_notes/Real case tests/projectlens-inputs"); +const NEEDS_FIXTURES = fs.existsSync(RESEARCH) ? {} : { skip: "needs local fixtures in ../research_notes/Real case tests/projectlens-inputs" }; const require = createRequire(import.meta.url); const DEFAULT_RULES = { @@ -126,7 +127,12 @@ describe("ProjectLensEngine parity with origin/main", () => { } }); - it("matches Northstar assurance and schedule-review outputs", () => { + it("matches Northstar assurance and schedule-review outputs", t => { + // origin/main now ships the shared engine, so the old inline page engines this compared against are gone. + if (!gitShow("docs/xer-review.js").includes("function numberValue(")) { + t.skip("origin/main no longer has the inline page engines this parity check compares against"); + return; + } const legacy = loadLegacyEngines(); const engine = loadEngine(); const prevPath = path.join(REPO, "docs/demo/northstar-previous.xer"); @@ -159,7 +165,7 @@ describe("ProjectLensEngine parity with origin/main", () => { assert.ok(engReviewR.conflicts.some(c => /contradiction/i.test(c.type))); }); - it("parses the seven real public XER samples like origin/main", () => { + it("parses the seven real public XER samples like origin/main", NEEDS_FIXTURES, () => { const legacy = loadLegacyEngines(); const engine = loadEngine(); for (const rel of REAL_XER_SEVEN) { diff --git a/tests/engine/silent-slip.test.mjs b/tests/engine/silent-slip.test.mjs new file mode 100644 index 0000000..48432eb --- /dev/null +++ b/tests/engine/silent-slip.test.mjs @@ -0,0 +1,33 @@ +// A moved finish that the update never mentions is a finding; a mentioned move is not. +import assert from "node:assert/strict"; +import { createRequire } from "node:module"; +import { it } from "node:test"; + +const require = createRequire(import.meta.url); +const E = require("../../docs/engine/projectlens-engine.js"); +const dates = { previousFinish: "2026-03-31", currentFinish: "2026-09-30" }; + +it("flags an update that says nothing about a six-month slip", () => { + const r = E.detectScheduleClaims("Good progress on groundworks this month. Steel frame started.", dates); + assert.equal(r.contradiction, null); + assert.ok(r.silentMove); +}); + +it("does not flag an update that mentions the delay", () => { + const r = E.detectScheduleClaims("Groundworks were delayed by ground conditions.", dates); + assert.equal(r.silentMove, null); +}); + +it("does not flag silence when the finish did not move", () => { + const r = E.detectScheduleClaims("Good progress this month.", { previousFinish: "2026-03-31", currentFinish: "2026-03-31" }); + assert.equal(r.silentMove, null); +}); + +it("ignores moves of 14 days or less", () => { + const r = E.detectScheduleClaims("Good progress this month.", { previousFinish: "2026-03-31", currentFinish: "2026-04-10" }); + assert.equal(r.silentMove, null); +}); + +it("does not call 'not on track' silent", () => { + assert.equal(E.detectScheduleClaims("The programme is not on track.", dates).silentMove, null); +}); diff --git a/tests/real-cases/real-cases.test.mjs b/tests/real-cases/real-cases.test.mjs index f78c450..289dc09 100644 --- a/tests/real-cases/real-cases.test.mjs +++ b/tests/real-cases/real-cases.test.mjs @@ -75,9 +75,15 @@ function runCase(caseDef) { describe("public real-case regression", () => { for (const caseDef of CASES) { - it(caseDef.title, () => { + it(caseDef.title, t => { const actual = runCase(caseDef); if (actual.skipped) { + // No fixture folder at all means the local research data is not installed on this machine. + if (!fs.existsSync(RESEARCH)) { + results.push({ ...caseDef, status: "skipped", detail: actual.reason }); + t.skip("needs local fixtures in ../research_notes/Real case tests/projectlens-inputs"); + return; + } if (caseDef.optional || caseDef.pairFilter) { results.push({ ...caseDef, status: "skipped", detail: actual.reason }); return;