feat(okf): enforce §3 okf_version shape, bump convention 0.1 -> 0.2
The 2026-07-23 reservation said enforcement waits until "the emitters have
migrated". Measured rather than assumed, and the emitter set turned out to be
TWO, not three:
okr @0059da7 okf_version: 0.1 + okf_layout: kb-layout-2026-06. Migrated.
linkedin-studio scaffold.ts:38 -> okf_version: 0.1. Never carried a layout
string; has no okf_layout and needs none.
ms-ai-architect NOT an emitter. Zero index.md in the repo; okf_version
appears in one planning doc. The status table already said
"designed, not built" -- only the word "emitters" implied it.
Swept the whole marketplace plus the sibling consumer repos: every live
okf_version value is 0.1. The flip is a no-op today and locks the invariant.
The gate checks SHAPE (/^\d+(\.\d+)*$/), never membership: the upstream value
set is Google's (spec §12), so a bundle targeting a newer version passes. A
membership check would be the convention claiming a set it says it does not own
-- the over-reach class this round has corrected three times. Presence stays
unenforced (reported, not failed) as a separate §3 MUST.
Convention bumped 0.1 -> 0.2 by this log's own criterion: the set of conforming
bundles changed (the spec explicitly said a layout string "conforms today", and
rollout rule 6 defines conformance as gate output). The §12 per-plugin re-check
is pre-measured as finding zero violations.
Also closes a parity blind spot found while landing this: check-okf-parity
compared the okf_version VALUE, which is identical exactly when two impls
disagree about whether it is acceptable -- a false "agree" on the axis the gate
exists to watch. The signature now carries a boolean shape verdict, with
red-marker-layout as the committed red proof. Its "diverge" expectation encodes
okr's lag (they still pure-echo) and flips to "agree" when they mirror it.
And a correction the round earned: portfolio-optimiser enumerated their own
bundle surface and it is four, not three. The dormant fourth
(reference_domain.py:49 -> package data at :70) has no flag form at all, so our
published claim that the re-measurement surfaced "one" unreported entry was
itself one-of-two. Sharpens the standing rule: a search shaped like one entry
type cannot see another; install-vs-fixture is one instance, not the class.
Suite 73 -> 78. coord: PO replied, okr + llm-ingestion-okf notified (the latter
under the standing promise to flag any okf-check.mjs change).
This commit is contained in:
parent
3dad1f51ce
commit
6a72b26985
9 changed files with 227 additions and 11 deletions
|
|
@ -16,7 +16,8 @@
|
|||
//
|
||||
// CONTRACT: comparison unit is the PER-FILE outcome, not the bundle verdict — two
|
||||
// checkers can both say "OK" while disagreeing on what IS a concept file. Each impl's
|
||||
// existing checkBundle(root) return is normalized to { conceptCount, untyped[], okfVersion };
|
||||
// existing checkBundle(root) return is normalized to
|
||||
// { conceptCount, untyped[], okfVersion, okfVersionAccepted };
|
||||
// the gate diverges iff those normalized outcomes are not identical across the
|
||||
// available impls. Defined over DEFAULT read-mode (strictIngest OFF, not files-scoped).
|
||||
//
|
||||
|
|
@ -59,12 +60,19 @@ export async function normalizedOutcome(impl, root) {
|
|||
conceptCount: r.scanned,
|
||||
untyped: [...(r.missingType ?? [])].sort(),
|
||||
okfVersion: r.okfVersion ?? null,
|
||||
// spec §3 marker axis. Normalized to a BOOLEAN verdict, not the message: two impls that
|
||||
// both enforce must agree even if they word the rejection differently. An impl that does
|
||||
// not check at all reports no error, i.e. "accepts" — which is exactly the signal we want
|
||||
// when one enforces and another still pure-echoes.
|
||||
okfVersionAccepted: !(r.okfVersionError ?? null),
|
||||
};
|
||||
}
|
||||
|
||||
// Signature over the fields that define per-file parity. Distinct signatures => divergence.
|
||||
// The okf_version VALUE alone could not carry the marker axis: when impls disagree about
|
||||
// whether a value is acceptable, the value itself is identical, so the axis read as "agree".
|
||||
function signature(o) {
|
||||
return `${o.conceptCount}|${o.untyped.join(',')}|${o.okfVersion}`;
|
||||
return `${o.conceptCount}|${o.untyped.join(',')}|${o.okfVersion}|${o.okfVersionAccepted}`;
|
||||
}
|
||||
|
||||
// Run all impls on one bundle root; decide agree vs diverge among the comparable ones.
|
||||
|
|
@ -145,7 +153,10 @@ if (isMain) {
|
|||
r.status === 'PASS' && r.expected === 'diverge' ? 'PASS (red-proof)' : r.status;
|
||||
out.push(`${r.fixture.padEnd(22)} [${(r.axis || '').padEnd(16)}] expect=${(r.expected || '').padEnd(8)} ${tag}`);
|
||||
for (const o of r.outcomes ?? []) {
|
||||
out.push(` ${o.name.padEnd(10)} count=${o.conceptCount} untyped=[${o.untyped.join(', ')}] okf=${o.okfVersion}`);
|
||||
// The shape verdict is printed because the value alone cannot show this axis: on a
|
||||
// marker divergence both impls print the SAME okf= value and only the verdict differs.
|
||||
const verdict = o.okfVersionAccepted ? 'accepted' : 'REJECTED';
|
||||
out.push(` ${o.name.padEnd(10)} count=${o.conceptCount} untyped=[${o.untyped.join(', ')}] okf=${o.okfVersion} (${verdict})`);
|
||||
}
|
||||
if (r.skipped?.length) out.push(` (skipped, unavailable: ${r.skipped.join(', ')})`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,6 +93,31 @@ test('red-proof: BOM+CRLF typed concept diverges; the same file as UTF-8/LF agre
|
|||
}
|
||||
});
|
||||
|
||||
// --- marker axis: §3 okf_version shape enforcement (catalog enforces, okr echoes) ---
|
||||
// This axis was invisible to the gate until the signature carried the shape verdict: the
|
||||
// signature compared the okf_version VALUE, which is identical across impls precisely when
|
||||
// they disagree about whether it is acceptable. A false "agree" on the one axis the gate
|
||||
// exists to watch.
|
||||
test('marker axis: a layout string in okf_version diverges; a version-shaped one agrees', async () => {
|
||||
const impls = [CATALOG, OKR];
|
||||
const layout = tmpRoot();
|
||||
const versioned = tmpRoot();
|
||||
try {
|
||||
writeFileSync(join(layout, 'index.md'), 'okf_version: kb-layout-2026-06\n\n# Bundle\n');
|
||||
writeFileSync(join(layout, 'c.md'), TYPED);
|
||||
const evLayout = await evaluateBundle(layout, impls);
|
||||
assert.equal(evLayout.diverges, true, 'catalog enforces the shape, okr still pure-echoes -> diverge');
|
||||
|
||||
writeFileSync(join(versioned, 'index.md'), ROOTINDEX);
|
||||
writeFileSync(join(versioned, 'c.md'), TYPED);
|
||||
const evVersioned = await evaluateBundle(versioned, impls);
|
||||
assert.equal(evVersioned.diverges, false, 'a version-shaped value is accepted by both -> agree');
|
||||
} finally {
|
||||
rmSync(layout, { recursive: true, force: true });
|
||||
rmSync(versioned, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
// --- Layer 2b: symlink axis (runtime-materialized; must not hang/crash) ---
|
||||
test('symlink axis: symlinked file + dir + loop are skipped by both, no hang, agree', async () => {
|
||||
const dir = tmpRoot();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@
|
|||
// >= 1 file without type -> exit 1, count + names the files; 0 -> exit 0.
|
||||
// - recommended fields (resource/title/description/timestamp) -> WARNING, not error.
|
||||
// - the bundle-root index.md's `okf_version` is echoed for human comparison
|
||||
// (no auto-fetch — offline by design).
|
||||
// (no auto-fetch — offline by design), and its VALUE must be version-shaped:
|
||||
// a plugin's own layout revision belongs in `okf_layout` (§12). Shape only —
|
||||
// the upstream value set is Google's, not this convention's. Absence is still
|
||||
// echoed, not failed.
|
||||
//
|
||||
// Provenance: lifted from okr/scripts/okf-check.mjs (the de-facto reference
|
||||
// implementation; spec §7) at c06e4d7 (2026-06-29), with English output + a vendored
|
||||
|
|
@ -48,6 +51,18 @@ function rootOkfVersion(root) {
|
|||
return m ? m[1].trim() : null;
|
||||
}
|
||||
|
||||
// spec §3: the value is the upstream OKF version ALONE; a plugin's own layout revision
|
||||
// belongs in `okf_layout` (§12). This checks only that the value is version-SHAPED — it is
|
||||
// deliberately NOT a claim about which upstream versions exist, because that value set is
|
||||
// owned by Google (§12), not by this convention. Absence is a separate §3 MUST and stays
|
||||
// unenforced here (echoed as MISSING). null when there is nothing to complain about.
|
||||
const UPSTREAM_VERSION_SHAPE = /^\d+(\.\d+)*$/;
|
||||
function okfVersionShapeError(value) {
|
||||
if (value === null || UPSTREAM_VERSION_SHAPE.test(value)) return null;
|
||||
return `root index.md: okf_version "${value}" is not upstream-version-shaped; `
|
||||
+ "a plugin's own layout revision belongs in okf_layout (spec §12)";
|
||||
}
|
||||
|
||||
export function checkBundle(root) {
|
||||
const concepts = walkConcepts(root);
|
||||
const missingType = [];
|
||||
|
|
@ -63,11 +78,13 @@ export function checkBundle(root) {
|
|||
if (!get(field)) warnings.push(`${rel}: missing recommended field "${field}"`);
|
||||
}
|
||||
}
|
||||
const okfVersion = rootOkfVersion(root);
|
||||
return {
|
||||
scanned: concepts.length,
|
||||
missingType,
|
||||
warnings,
|
||||
okfVersion: rootOkfVersion(root),
|
||||
okfVersion,
|
||||
okfVersionError: okfVersionShapeError(okfVersion),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -91,9 +108,13 @@ if (isMain) {
|
|||
out.push(` ${r.missingType.length} files without type:`);
|
||||
for (const f of r.missingType) out.push(` - ${f}`);
|
||||
out.push(` okf_version: ${r.okfVersion || 'MISSING (root index without okf_version)'}`);
|
||||
if (r.okfVersionError) out.push(` - ${r.okfVersionError}`);
|
||||
out.push(` Warnings (recommended fields): ${r.warnings.length}`);
|
||||
for (const w of r.warnings) out.push(` ! ${w}`);
|
||||
out.push(r.missingType.length === 0 ? 'OK: valid OKF bundle' : `FAIL: ${r.missingType.length} file(s) missing type:`);
|
||||
const failures = [];
|
||||
if (r.missingType.length > 0) failures.push(`${r.missingType.length} file(s) missing type:`);
|
||||
if (r.okfVersionError) failures.push('okf_version is not upstream-version-shaped');
|
||||
out.push(failures.length === 0 ? 'OK: valid OKF bundle' : `FAIL: ${failures.join('; ')}`);
|
||||
process.stdout.write(`${out.join('\n')}\n`);
|
||||
process.exit(r.missingType.length === 0 ? 0 : 1);
|
||||
process.exit(failures.length === 0 ? 0 : 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,3 +102,66 @@ test('checkBundle(): recommended-field gaps are warnings, not failures', () => {
|
|||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
// --- spec §3 okf_version shape enforcement (the reservation lifted 2026-07-25) ---
|
||||
// The catalog owns the SEPARATION of the two markers (§12), not the upstream value set
|
||||
// (owned by Google). So the gate checks that the value is version-SHAPED — never that it
|
||||
// is a version that exists upstream.
|
||||
|
||||
test('okf_version carrying a layout string -> exit != 0 and points at okf_layout', () => {
|
||||
const dir = tmpRoot();
|
||||
try {
|
||||
writeValidBundle(dir);
|
||||
writeFileSync(join(dir, 'index.md'), 'okf_version: kb-layout-2026-06\n\n# Bundle\n');
|
||||
const { status, stdout } = runCheck(dir);
|
||||
assert.notEqual(status, 0, 'a layout snapshot in okf_version must fail the gate');
|
||||
assert.match(stdout, /okf_layout/, 'the failure must name the marker it belongs in');
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('a version-shaped okf_version passes, including multi-component', () => {
|
||||
for (const value of ['0.1', '1.0', '0.1.2', '12']) {
|
||||
const dir = tmpRoot();
|
||||
try {
|
||||
writeValidBundle(dir);
|
||||
writeFileSync(join(dir, 'index.md'), `okf_version: ${value}\n\n# Bundle\n`);
|
||||
const { status } = runCheck(dir);
|
||||
assert.equal(status, 0, `"${value}" is upstream-version-shaped and must pass`);
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Scope guard: the reservation covered the value's SHAPE. Presence is a separate §3 MUST
|
||||
// that this gate still does not enforce — absent stays a non-failing echo, as before.
|
||||
test('absent okf_version is unchanged by shape enforcement (still exit 0 + MISSING echo)', () => {
|
||||
const dir = tmpRoot();
|
||||
try {
|
||||
writeValidBundle(dir);
|
||||
writeFileSync(join(dir, 'index.md'), '# Bundle\n'); // no marker at all
|
||||
const { status, stdout } = runCheck(dir);
|
||||
assert.equal(status, 0, 'absence must not become an error in this step');
|
||||
assert.match(stdout, /MISSING/);
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('checkBundle(): the shape verdict is on the return object', () => {
|
||||
const bad = tmpRoot();
|
||||
const good = tmpRoot();
|
||||
try {
|
||||
writeValidBundle(bad);
|
||||
writeFileSync(join(bad, 'index.md'), 'okf_version: kb-layout-2026-06\n');
|
||||
assert.ok(checkBundle(bad).okfVersionError, 'layout string -> an error string');
|
||||
|
||||
writeValidBundle(good);
|
||||
assert.equal(checkBundle(good).okfVersionError, null, '0.1 -> no error');
|
||||
} finally {
|
||||
rmSync(bad, { recursive: true, force: true });
|
||||
rmSync(good, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue