test(yardstick): use counts new work from the loesningsvalg marker, from 2026-09-28 (red)

The use number read `work-class` from the order frontmatter; 0 of 690 orders
carry it, so the denominator was always empty. PM rule 02.10: the order
marker `<!-- loesningsvalg: plan|prove -->` is new work, `ikke-nytt` is not,
counted from 2026-09-28 (enforced by pre-order-loesningsvalg.sh since then).
Unmarked orders and orders before the start are "not measured", never a no.

Red against today's code: MARKER_SINCE is not exported, and with it stubbed in
a scratch copy all five new use tests fail on behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-10-03 18:19:20 +02:00
commit e2186bf64f
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q

View file

@ -18,6 +18,7 @@ import { join, dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import {
DEFAULT_CUTOFF,
MARKER_SINCE,
loadStats,
readOrders,
measureUse,
@ -49,11 +50,15 @@ const cleanup = (...dirs) => { for (const d of dirs) rmSync(d, { recursive: true
const jsonl = (...rows) => `${rows.map((r) => (typeof r === 'string' ? r : JSON.stringify(r))).join('\n')}\n`;
function order({ id, date, workClass, slug, extra = '' }) {
// `marker` writes the order's solution-choice marker the way dispatch does: an
// HTML comment on its own line in the body, `<!-- loesningsvalg: <value>; grunn=... -->`.
function order({ id, date, workClass, slug, marker, extra = '' }) {
const lines = ['---', 'from: .claude', 'to: some-repo', `order-id: ${id}`, `subject: order ${id}`, `date: ${date}`];
if (workClass !== undefined) lines.push(`work-class: ${workClass}`);
if (slug !== undefined) lines.push(`slug: ${slug}`);
lines.push('---', '', `# ORDER ${id}`, extra, '');
lines.push('---');
if (marker !== undefined) lines.push(`<!-- loesningsvalg: ${marker}; grunn=fixture -->`);
lines.push('', `# ORDER ${id}`, extra, '');
return lines.join('\n');
}
@ -178,10 +183,14 @@ test('use: a dot-mailbox is a mailbox - its orders count, and the detail names i
} finally { cleanup(coord); }
});
test('use: no order carrying work-class means NOT COUNTABLE, not 0 %', () => {
test('use: the marker is counted from 2026-09-28, the day pre-order-loesningsvalg.sh began enforcing it', () => {
assert.equal(MARKER_SINCE, '2026-09-28');
});
test('use: no order carrying a loesningsvalg marker means NOT COUNTABLE, not 0 %', () => {
const coord = fixture({
'r/orders/o1.md': order({ id: 'o1', date: '2026-09-22T10:00:00Z' }),
'r/orders/o2.md': order({ id: 'o2', date: '2026-09-23T10:00:00Z' }),
'r/orders/o1.md': order({ id: 'o1', date: '2026-09-29T10:00:00Z' }),
'r/orders/o2.md': order({ id: 'o2', date: '2026-09-30T10:00:00Z' }),
});
try {
const row = measureUse({ queue: readOrders(coord), slugs: new Set(), cutoff: DEFAULT_CUTOFF });
@ -189,25 +198,74 @@ test('use: no order carrying work-class means NOT COUNTABLE, not 0 %', () => {
assert.equal(row.value, null);
assert.equal(row.denominator, 0);
assert.equal(row.facts.scanned, 2);
assert.equal(row.facts.withWorkClass, 0);
assert.match(row.detail, /0 of 2 orders carry work-class/);
assert.equal(row.facts.withMarker, 0);
assert.equal(row.facts.notMeasured, 2, 'an unmarked order is not measured - never a no');
assert.match(row.detail, /0 of 2 orders carry a loesningsvalg marker/);
assert.match(row.detail, /2 not measured/);
} finally { cleanup(coord); }
});
test('use: the denominator is new-work orders dated on or after the cutoff; the numerator is those with a Voyage run', () => {
test('use: plan and prove are NEW work, ikke-nytt is not; unmarked and pre-2026-09-28 orders are not measured', () => {
const coord = fixture({
'r/orders/a.md': order({ id: 'a', date: '2026-09-21T00:00:00Z', workClass: 'new', slug: 'feat-a' }),
'r/orders/archive/b.md': order({ id: 'b', date: '2026-09-25T00:00:00Z', workClass: 'new', slug: 'feat-b' }),
'r/orders/c.md': order({ id: 'c', date: '2026-09-25T00:00:00Z', workClass: 'new' }),
'r/orders/d.md': order({ id: 'd', date: '2026-09-20T23:59:59Z', workClass: 'new', slug: 'feat-a' }),
'r/orders/e.md': order({ id: 'e', date: '2026-09-25T00:00:00Z', workClass: 'maintenance', slug: 'feat-a' }),
'r/orders/plan.md': order({ id: 'plan', date: '2026-09-28T00:00:00Z', marker: 'plan', slug: 'feat-a' }),
'r/orders/archive/prove.md': order({ id: 'prove', date: '2026-10-01T00:00:00Z', marker: 'prove', slug: 'feat-b' }),
'r/orders/claimed/ikke.md': order({ id: 'ikke', date: '2026-10-01T00:00:00Z', marker: 'ikke-nytt', slug: 'feat-a' }),
'r/orders/none.md': order({ id: 'none', date: '2026-10-01T00:00:00Z', slug: 'feat-a' }),
'r/orders/early.md': order({ id: 'early', date: '2026-09-27T23:59:59Z', marker: 'plan', slug: 'feat-a' }),
});
try {
const row = measureUse({ queue: readOrders(coord), slugs: new Set(['feat-a']), cutoff: '2026-09-21' });
const row = measureUse({ queue: readOrders(coord), slugs: new Set(['feat-a']), cutoff: DEFAULT_CUTOFF });
assert.equal(row.countable, true);
assert.equal(row.denominator, 3, 'a, b and c - d is before the cutoff, e is maintenance');
assert.equal(row.value, 1, 'only a has a Voyage run with the same slug; c has no slug to match');
assert.equal(row.facts.withWorkClass, 5);
assert.equal(row.denominator, 2, 'plan and prove - ikke-nytt is not new work, none and early are not measured');
assert.equal(row.value, 1, 'only plan has a Voyage run with the same slug');
assert.equal(row.facts.newWork, 2);
assert.equal(row.facts.notNew, 1);
assert.equal(row.facts.notMeasured, 2, 'the unmarked order and the one before 2026-09-28');
assert.equal(row.facts.beforeMarker, 1);
assert.equal(row.facts.unmarked, 1);
assert.match(row.detail, /1 of 2 new-work orders/);
assert.match(row.detail, /2 not measured/);
} finally { cleanup(coord); }
});
test('use: work-class in the frontmatter no longer decides anything - only the marker does', () => {
const coord = fixture({
'r/orders/a.md': order({ id: 'a', date: '2026-09-29T00:00:00Z', workClass: 'new', slug: 'feat-a' }),
'r/orders/b.md': order({ id: 'b', date: '2026-09-29T00:00:00Z', workClass: 'maintenance', marker: 'prove', slug: 'feat-a' }),
});
try {
const row = measureUse({ queue: readOrders(coord), slugs: new Set(['feat-a']), cutoff: DEFAULT_CUTOFF });
assert.equal(row.denominator, 1, 'b is new by its marker; a has no marker and is not measured');
assert.equal(row.value, 1);
assert.equal(row.facts.notMeasured, 1);
} finally { cleanup(coord); }
});
test('use: only a marker on its own line counts - a mention in prose or an unknown value is not measured', () => {
const coord = fixture({
'r/orders/prose.md': order({ id: 'prose', date: '2026-09-29T00:00:00Z', extra: 'Count from the marker `<!-- loesningsvalg: plan -->` in the body.' }),
'r/orders/odd.md': order({ id: 'odd', date: '2026-09-29T00:00:00Z', marker: 'kanskje' }),
'r/orders/both.md': order({ id: 'both', date: '2026-09-29T00:00:00Z', marker: 'ikke-nytt', extra: 'Prose names `<!-- loesningsvalg: plan -->` too.' }),
});
try {
const row = measureUse({ queue: readOrders(coord), slugs: new Set(), cutoff: DEFAULT_CUTOFF });
assert.equal(row.denominator, 0);
assert.equal(row.facts.notNew, 1, 'both: the line marker wins over the prose mention');
assert.equal(row.facts.notMeasured, 2, 'prose has no marker; kanskje is no known value');
assert.equal(row.countable, false);
} finally { cleanup(coord); }
});
test('use: a cutoff later than 2026-09-28 moves the start of the count', () => {
const coord = fixture({
'r/orders/a.md': order({ id: 'a', date: '2026-09-29T00:00:00Z', marker: 'plan' }),
'r/orders/b.md': order({ id: 'b', date: '2026-10-02T00:00:00Z', marker: 'plan' }),
});
try {
const row = measureUse({ queue: readOrders(coord), slugs: new Set(), cutoff: '2026-10-01' });
assert.equal(row.denominator, 1);
assert.equal(row.facts.beforeMarker, 1);
assert.match(row.source, /from 2026-10-01/);
} finally { cleanup(coord); }
});
@ -385,7 +443,7 @@ test('measureAll + main: RED with exit 1 while any number is not countable', ()
test('measureAll: all three countable and the mutant felled is still RED until the verdict can be judged', () => {
const { coord, data } = world({
orders: { 'r/orders/o.md': order({ id: 'o', date: '2026-09-22T00:00:00Z', workClass: 'new', slug: 'a' }) },
orders: { 'r/orders/o.md': order({ id: 'o', date: '2026-09-29T00:00:00Z', marker: 'plan', slug: 'a' }) },
stats: {
'trekreview-stats.jsonl': jsonl(review('2026-09-01T00:00:00Z', 'ALLOW', 'a')),
'trekexecute-stats.jsonl': jsonl({ ts: 't', event: 'user_input', payload: { slug: 'a' } }),