fix(validators): the progress validator knows stopped and blocked
/trekexecute writes run status stopped (dirty-tree stop, entry-condition stop, escalation) and step status blocked (Step 0 sandbox sentinel); the validator rejected the first and warned on the second. Both are real states lib/util/session-orders.mjs already reads (ENDED_BAD), so the validator learns them. The step-status list is exported as PROGRESS_STEP_STATUSES (was an inline literal) so tests check prose against it instead of keeping a copy. docs/HANDOVER-CONTRACTS.md Handover 5 rows updated. Red: 3 of 4 new tests fail on the pre-fix code (stopped run status, PROGRESS_STEP_STATUSES export, blocked step status). Regression guard (green on arrival): every run status but completed stays resumable. progress-validator 16/16. Suite 1368 (1366/0/2). Voyage order 20261005T104513Z-1250514346, plan step 1/5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5680591ddf
commit
8a56187341
3 changed files with 58 additions and 5 deletions
|
|
@ -1,6 +1,8 @@
|
|||
import { test } from 'node:test';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import { validateProgressObject, checkResumeReadiness } from '../../lib/validators/progress-validator.mjs';
|
||||
import * as progressValidator from '../../lib/validators/progress-validator.mjs';
|
||||
|
||||
const { validateProgressObject, checkResumeReadiness } = progressValidator;
|
||||
|
||||
function goodProgress() {
|
||||
return {
|
||||
|
|
@ -107,3 +109,50 @@ test('checkResumeReadiness — in-progress is resumable', () => {
|
|||
const r = checkResumeReadiness(goodProgress());
|
||||
assert.equal(r.valid, true);
|
||||
});
|
||||
|
||||
// /trekexecute writes run status `stopped` (dirty-tree stop, entry-condition stop,
|
||||
// escalation) and step status `blocked` (Step 0 sandbox sentinel). Both are real
|
||||
// states other readers already know (lib/util/session-orders.mjs ENDED_BAD), so the
|
||||
// validator learns them rather than the prose mapping them away.
|
||||
test('validateProgress — stopped is a valid run status', () => {
|
||||
const p = goodProgress();
|
||||
p.status = 'stopped';
|
||||
const r = validateProgressObject(p);
|
||||
assert.deepEqual(r.errors, [], 'a stopped run (escalation, dirty tree, entry condition) must validate');
|
||||
});
|
||||
|
||||
test('PROGRESS_STEP_STATUSES is exported and is the list the validator accepts', () => {
|
||||
const { PROGRESS_STEP_STATUSES } = progressValidator;
|
||||
assert.ok(Array.isArray(PROGRESS_STEP_STATUSES), 'the step-status list must be exported, not an inline literal');
|
||||
for (const status of PROGRESS_STEP_STATUSES) {
|
||||
const p = goodProgress();
|
||||
p.steps['1'].status = status;
|
||||
const r = validateProgressObject(p);
|
||||
assert.equal(r.warnings.find((w) => w.code === 'PROGRESS_STEP_BAD_STATUS'), undefined, `step status ${status}`);
|
||||
}
|
||||
for (const status of ['passed', 'running']) {
|
||||
const p = goodProgress();
|
||||
p.steps['1'].status = status;
|
||||
const r = validateProgressObject(p);
|
||||
assert.ok(r.warnings.find((w) => w.code === 'PROGRESS_STEP_BAD_STATUS'), `${status} is not a stored step status`);
|
||||
}
|
||||
});
|
||||
|
||||
test('validateProgress — blocked is a valid step status (Step 0 sandbox sentinel)', () => {
|
||||
const p = goodProgress();
|
||||
p.steps['1'].status = 'blocked';
|
||||
const r = validateProgressObject(p);
|
||||
assert.deepEqual(r.warnings, [], 'the sandbox sentinel writes step status blocked');
|
||||
});
|
||||
|
||||
// Regression guard (passes before this change): only `completed` refuses a resume.
|
||||
test('checkResumeReadiness — every run status but completed is resumable', () => {
|
||||
for (const status of ['stopped', 'failed', 'partial', 'in_progress']) {
|
||||
const p = goodProgress();
|
||||
p.status = status;
|
||||
assert.equal(checkResumeReadiness(p).valid, true, `${status} must stay resumable`);
|
||||
}
|
||||
const done = goodProgress();
|
||||
done.status = 'completed';
|
||||
assert.equal(checkResumeReadiness(done).valid, false);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue