Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .harness/scripts/knowledge-okf-standard-watch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function staleness(lock, now, staleDays = STALE_DAYS) {
/**
* Núcleo del vigía (puro: fetch inyectado). Devuelve { status, nextLock, exitCode, ... }.
* status: 'initialized' | 'ok' | 'changed' | 'error'.
* accepted: true cuando ESTA ejecución reconoció un cambio upstream (--accept sobre 'changed').
*/
export async function runWatch({ lock, fetchText, url = SPEC_URL, now, accept = false, init = false }) {
let text;
Expand Down Expand Up @@ -87,6 +88,12 @@ export async function runWatch({ lock, fetchText, url = SPEC_URL, now, accept =
upstream,
lockedHash: lock.sha256,
nextLock,
// `status` describe el ESTADO DEL UPSTREAM (cambió o no) y se mantiene
// 'changed' aunque se acepte, porque es lo que ocurrió. `accepted` describe
// lo que hizo ESTA ejecución. Sin distinguirlos, `--accept` reconocía el hash
// y acto seguido imprimía "NO ha sido reconocido... confirma con --accept",
// que se lee como que el reconocimiento falló.
accepted: changed && accept,
// 'changed' sin --accept es advisory (10); aceptado o al día = 0.
exitCode: changed && !accept ? 10 : 0,
};
Expand Down Expand Up @@ -122,11 +129,15 @@ function report(result, lock, now) {
console.error(`error: ${result.message} — lock intacto, frescura sin cambio.`);
return;
}
console.log(`locked: ${short(result.lockedHash ?? result.upstream)}`);
console.log(`locked: ${short(result.nextLock?.sha256 ?? result.lockedHash ?? result.upstream)}`);
console.log(`upstream: ${short(result.upstream)}`);
console.log(`checkedAt: ${result.nextLock.checkedAt} reviewedAt: ${result.nextLock.reviewedAt}`);
console.log(`freshness: ${s.stale ? 'STALE' : 'fresh'} (${s.daysSinceChecked ?? 'never'} d; umbral ${s.staleDays} d)`);
if (result.status === 'changed') {
if (result.accepted) {
console.log('');
console.log('✅ Cambio upstream RECONOCIDO: sha256 y reviewedAt actualizados.');
console.log(' Commitea el lockfile (es metadato canónico, no derivado).');
} else if (result.status === 'changed') {
console.log('');
console.log('⚠️ El estándar OKF cambió upstream y NO ha sido reconocido.');
console.log(' Acción de Winston: revisa el SPEC + [ADR-0105], ajusta knowledge-okf-project.mjs');
Expand Down
12 changes: 12 additions & 0 deletions .harness/scripts/knowledge-okf-standard-watch.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ test('runWatch --accept reconoce el nuevo hash y baja a exit 0', async () => {
assert.equal(r.exitCode, 0); // aceptado
assert.equal(r.nextLock.sha256, sha256(SPEC + '\n## New section\n'));
assert.equal(r.nextLock.reviewedAt, '2026-07-07');
// `accepted` distingue "el upstream cambió" de "esta corrida lo reconoció":
// sin él, --accept imprimía el aviso de "NO ha sido reconocido" tras reconocerlo.
assert.equal(r.accepted, true);
});

test('runWatch sin --accept deja accepted=false sobre un cambio upstream', async () => {
const lock = { sha256: sha256(SPEC), checkedAt: '2026-06-01', reviewedAt: '2026-06-01' };
const r = await runWatch({ lock, fetchText: fetchChanged, now: '2026-07-07' });
assert.equal(r.status, 'changed');
assert.equal(r.accepted, false);
assert.equal(r.exitCode, 10);
assert.equal(r.nextLock.sha256, sha256(SPEC)); // el hash NO se mueve sin reconocer
});

test('runWatch falla cerrado en error de red sin tocar el lock', async () => {
Expand Down
4 changes: 2 additions & 2 deletions reference/knowledge/canonical/okf-spec.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"spec": "OKF",
"version": "0.1",
"sourceUrl": "https://raw.githubusercontent.com/GoogleCloudPlatform/knowledge-catalog/main/okf/SPEC.md",
"sha256": "b9655e607346dbbdc6de21190e9a953313eda6a7eba68d4d272a65975940ad6e",
"sha256": "26aa5da029278939f914e578107242d9607d4f2dc5fe153272b82f9ed1030101",
"checkedAt": "2026-08-23",
"reviewedAt": "2026-07-08",
"reviewedAt": "2026-08-23",
"adr": "ADR-0105"
}
Loading