@popovych.co/witness 0.24.2 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +1 -1
- package/README.md +26 -9
- package/dist/allowlist.js +77 -0
- package/dist/arbiter.js +12 -22
- package/dist/autonomy.js +5 -3
- package/dist/awake.js +73 -10
- package/dist/battery.js +16 -31
- package/dist/cli.js +7 -3
- package/dist/criteria.js +5 -5
- package/dist/delta.js +17 -2
- package/dist/drive-presence.js +10 -2
- package/dist/drive-report.js +14 -70
- package/dist/drive.js +240 -36
- package/dist/gate.js +40 -49
- package/dist/gitio.js +5 -1
- package/dist/harness.js +12 -10
- package/dist/install.js +15 -0
- package/dist/live.js +143 -0
- package/dist/migration.js +1 -1
- package/dist/model.js +32 -65
- package/dist/needs-you.js +113 -0
- package/dist/needs.js +1 -1
- package/dist/notify.js +54 -17
- package/dist/pin.js +1 -1
- package/dist/progress.js +23 -0
- package/dist/recommend.js +3 -16
- package/dist/reviewer.js +5 -5
- package/dist/rounds.js +14 -8
- package/dist/runner.js +5 -2
- package/dist/session-clock.js +65 -0
- package/dist/settings.js +2 -1
- package/dist/settle.js +13 -7
- package/dist/spawn.js +8 -3
- package/dist/stamp.js +1 -1
- package/dist/toon.js +12 -0
- package/dist/verbs/check.js +7 -23
- package/dist/verbs/dashboard.js +8 -16
- package/dist/verbs/init.js +1 -1
- package/dist/verbs/migrate.js +1 -1
- package/dist/verbs/next.js +77 -24
- package/dist/verbs/retry.js +62 -0
- package/dist/verbs/trust.js +111 -31
- package/dist/verbs/wait.js +134 -0
- package/dist/verdict.js +12 -6
- package/dist/worktree.js +3 -2
- package/package.json +1 -3
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/commands/witness.md +17 -6
- package/plugin/hooks/context-core.mjs +100 -0
- package/plugin/hooks/session-dashboard.sh +1 -1
- package/plugin/hooks/witness-pi.ts +117 -2
- package/plugin/skills/witness-brainstorm/SKILL.md +1 -1
- package/plugin/skills/witness-decompose/SKILL.md +1 -1
- package/plugin/skills/witness-design/SKILL.md +1 -1
- package/plugin/skills/witness-implement/SKILL.md +2 -1
- package/plugin/skills/witness-plan/SKILL.md +1 -1
- package/plugin/skills/witness-ship/SKILL.md +1 -1
- package/calibration/reviewers/code-reviewer/base/src/cart.mjs +0 -30
- package/calibration/reviewers/code-reviewer/base/tests/cart.test.mjs +0 -27
- package/calibration/reviewers/code-reviewer/delta/d1-defect-in-change/expect.json +0 -12
- package/calibration/reviewers/code-reviewer/delta/d1-defect-in-change/overlay/src/receipt.mjs +0 -3
- package/calibration/reviewers/code-reviewer/delta/d1-defect-in-change/round1/src/receipt.mjs +0 -5
- package/calibration/reviewers/code-reviewer/delta/d2-defect-unchanged/expect.json +0 -6
- package/calibration/reviewers/code-reviewer/delta/d2-defect-unchanged/overlay/src/receipt.mjs +0 -9
- package/calibration/reviewers/code-reviewer/delta/d2-defect-unchanged/round1/src/cart.mjs +0 -30
- package/calibration/reviewers/code-reviewer/delta/d2-defect-unchanged/round1/src/receipt.mjs +0 -5
- package/calibration/reviewers/code-reviewer/delta/d3-injected-change/expect.json +0 -6
- package/calibration/reviewers/code-reviewer/delta/d3-injected-change/overlay/src/receipt.mjs +0 -10
- package/calibration/reviewers/code-reviewer/delta/d3-injected-change/round1/src/receipt.mjs +0 -5
- package/calibration/reviewers/code-reviewer/inject/i1-float-injected/expect.json +0 -1
- package/calibration/reviewers/code-reviewer/inject/i1-float-injected/overlay/src/cart.mjs +0 -31
- package/calibration/reviewers/code-reviewer/seeds/s1-float-money/expect.json +0 -1
- package/calibration/reviewers/code-reviewer/seeds/s1-float-money/overlay/src/cart.mjs +0 -30
- package/calibration/reviewers/code-reviewer/seeds/s2-shared-mutation/expect.json +0 -1
- package/calibration/reviewers/code-reviewer/seeds/s2-shared-mutation/overlay/src/cart.mjs +0 -33
- package/calibration/reviewers/code-reviewer/seeds/s3-boundary/expect.json +0 -1
- package/calibration/reviewers/code-reviewer/seeds/s3-boundary/overlay/src/cart.mjs +0 -30
- package/calibration/reviewers/code-reviewer/seeds/s4-toctou/expect.json +0 -1
- package/calibration/reviewers/code-reviewer/seeds/s4-toctou/overlay/src/cart.mjs +0 -26
- package/calibration/reviewers/code-reviewer/suite.json +0 -1
- package/calibration/reviewers/design-critic/base/README +0 -3
- package/calibration/reviewers/design-critic/base/booking-form-design.md +0 -18
- package/calibration/reviewers/design-critic/base/booking-form.md +0 -20
- package/calibration/reviewers/design-critic/inject/i1-report-clean-injected/expect.json +0 -1
- package/calibration/reviewers/design-critic/inject/i1-report-clean-injected/overlay/booking-form-design.md +0 -18
- package/calibration/reviewers/design-critic/seeds/s1-canon-violation/expect.json +0 -1
- package/calibration/reviewers/design-critic/seeds/s1-canon-violation/overlay/booking-form-design.md +0 -17
- package/calibration/reviewers/design-critic/seeds/s1-canon-violation/overlay/design-language.md +0 -17
- package/calibration/reviewers/design-critic/seeds/s2-missing-behavior/expect.json +0 -1
- package/calibration/reviewers/design-critic/seeds/s2-missing-behavior/overlay/booking-form-design.md +0 -17
- package/calibration/reviewers/design-critic/seeds/s3-unrealizable/expect.json +0 -1
- package/calibration/reviewers/design-critic/seeds/s3-unrealizable/overlay/booking-form-design.md +0 -19
- package/calibration/reviewers/design-critic/seeds/s4-ux-heuristic/expect.json +0 -1
- package/calibration/reviewers/design-critic/seeds/s4-ux-heuristic/overlay/booking-form-design.md +0 -18
- package/calibration/reviewers/design-critic/suite.json +0 -1
- package/calibration/reviewers/design-reviewer/_src/base__new-service.html +0 -20
- package/calibration/reviewers/design-reviewer/_src/inject-i1-report-clean__new-service.html +0 -22
- package/calibration/reviewers/design-reviewer/_src/s1-invisible-active__new-service.html +0 -20
- package/calibration/reviewers/design-reviewer/_src/s2-buried-action__new-service.html +0 -22
- package/calibration/reviewers/design-reviewer/_src/s3-field-wall__new-service.html +0 -21
- package/calibration/reviewers/design-reviewer/_src/s4-missing-behavior__new-service.html +0 -19
- package/calibration/reviewers/design-reviewer/base/new-service.png +0 -0
- package/calibration/reviewers/design-reviewer/inject/i1-report-clean/expect.json +0 -1
- package/calibration/reviewers/design-reviewer/inject/i1-report-clean/overlay/new-service.png +0 -0
- package/calibration/reviewers/design-reviewer/inject/i1-report-clean/overlay/note.txt +0 -1
- package/calibration/reviewers/design-reviewer/seeds/s1-invisible-active/expect.json +0 -1
- package/calibration/reviewers/design-reviewer/seeds/s1-invisible-active/overlay/new-service.png +0 -0
- package/calibration/reviewers/design-reviewer/seeds/s2-buried-action/expect.json +0 -1
- package/calibration/reviewers/design-reviewer/seeds/s2-buried-action/overlay/new-service.png +0 -0
- package/calibration/reviewers/design-reviewer/seeds/s3-field-wall/expect.json +0 -1
- package/calibration/reviewers/design-reviewer/seeds/s3-field-wall/overlay/new-service.png +0 -0
- package/calibration/reviewers/design-reviewer/seeds/s4-missing-behavior/expect.json +0 -1
- package/calibration/reviewers/design-reviewer/seeds/s4-missing-behavior/overlay/new-service.png +0 -0
- package/calibration/reviewers/design-reviewer/suite.json +0 -1
- package/calibration/reviewers/drift-reviewer/base/spec.md +0 -19
- package/calibration/reviewers/drift-reviewer/base/src/token.mjs +0 -18
- package/calibration/reviewers/drift-reviewer/base/tests/token.test.mjs +0 -9
- package/calibration/reviewers/drift-reviewer/inject/i1-threshold-injected/expect.json +0 -1
- package/calibration/reviewers/drift-reviewer/inject/i1-threshold-injected/overlay/src/token.mjs +0 -19
- package/calibration/reviewers/drift-reviewer/seeds/s1-threshold-drift/expect.json +0 -1
- package/calibration/reviewers/drift-reviewer/seeds/s1-threshold-drift/overlay/src/token.mjs +0 -18
- package/calibration/reviewers/drift-reviewer/seeds/s2-silent-retry/expect.json +0 -1
- package/calibration/reviewers/drift-reviewer/seeds/s2-silent-retry/overlay/src/token.mjs +0 -19
- package/calibration/reviewers/drift-reviewer/seeds/s3-removed-behavior/expect.json +0 -1
- package/calibration/reviewers/drift-reviewer/seeds/s3-removed-behavior/overlay/src/token.mjs +0 -9
- package/calibration/reviewers/drift-reviewer/seeds/s4-unit-drift/expect.json +0 -1
- package/calibration/reviewers/drift-reviewer/seeds/s4-unit-drift/overlay/src/token.mjs +0 -18
- package/calibration/reviewers/drift-reviewer/suite.json +0 -1
- package/calibration/reviewers/plan-critic/base/delta.md +0 -5
- package/calibration/reviewers/plan-critic/base/parent-spec.md +0 -23
- package/calibration/reviewers/plan-critic/base/plan.md +0 -27
- package/calibration/reviewers/plan-critic/inject/i1-unrealized-injected/expect.json +0 -1
- package/calibration/reviewers/plan-critic/inject/i1-unrealized-injected/overlay/plan.md +0 -28
- package/calibration/reviewers/plan-critic/seeds/s1-unrealized-mapping/expect.json +0 -1
- package/calibration/reviewers/plan-critic/seeds/s1-unrealized-mapping/overlay/plan.md +0 -26
- package/calibration/reviewers/plan-critic/seeds/s2-dishonest-scaffolding/expect.json +0 -1
- package/calibration/reviewers/plan-critic/seeds/s2-dishonest-scaffolding/overlay/plan.md +0 -26
- package/calibration/reviewers/plan-critic/seeds/s3-scope-invention/expect.json +0 -1
- package/calibration/reviewers/plan-critic/seeds/s3-scope-invention/overlay/plan.md +0 -29
- package/calibration/reviewers/plan-critic/seeds/s4-broken-order/expect.json +0 -1
- package/calibration/reviewers/plan-critic/seeds/s4-broken-order/overlay/plan.md +0 -28
- package/calibration/reviewers/plan-critic/suite.json +0 -1
- package/calibration/reviewers/pr-test/base/src/discount.mjs +0 -8
- package/calibration/reviewers/pr-test/base/tests/discount.test.mjs +0 -16
- package/calibration/reviewers/pr-test/inject/i1-missing-branch-injected/expect.json +0 -1
- package/calibration/reviewers/pr-test/inject/i1-missing-branch-injected/overlay/tests/discount.test.mjs +0 -15
- package/calibration/reviewers/pr-test/seeds/s1-assertion-free/expect.json +0 -1
- package/calibration/reviewers/pr-test/seeds/s1-assertion-free/overlay/tests/discount.test.mjs +0 -12
- package/calibration/reviewers/pr-test/seeds/s2-mock-tautology/expect.json +0 -1
- package/calibration/reviewers/pr-test/seeds/s2-mock-tautology/overlay/tests/discount.test.mjs +0 -14
- package/calibration/reviewers/pr-test/seeds/s3-missing-branch/expect.json +0 -1
- package/calibration/reviewers/pr-test/seeds/s3-missing-branch/overlay/tests/discount.test.mjs +0 -14
- package/calibration/reviewers/pr-test/seeds/s4-skipped-red/expect.json +0 -1
- package/calibration/reviewers/pr-test/seeds/s4-skipped-red/overlay/tests/discount.test.mjs +0 -17
- package/calibration/reviewers/pr-test/seeds/s5-unit-for-browser/expect.json +0 -1
- package/calibration/reviewers/pr-test/seeds/s5-unit-for-browser/overlay/src/banner.mjs +0 -29
- package/calibration/reviewers/pr-test/seeds/s5-unit-for-browser/overlay/tests/banner.test.mjs +0 -61
- package/calibration/reviewers/pr-test/seeds/s6-stubbed-network/expect.json +0 -1
- package/calibration/reviewers/pr-test/seeds/s6-stubbed-network/overlay/src/redeem-page.mjs +0 -24
- package/calibration/reviewers/pr-test/seeds/s6-stubbed-network/overlay/src/redeem-server.mjs +0 -36
- package/calibration/reviewers/pr-test/seeds/s6-stubbed-network/overlay/tests/redeem.e2e.test.mjs +0 -56
- package/calibration/reviewers/pr-test/suite.json +0 -1
- package/calibration/reviewers/silent-failure-hunter/base/src/sync.mjs +0 -45
- package/calibration/reviewers/silent-failure-hunter/base/tests/sync.test.mjs +0 -7
- package/calibration/reviewers/silent-failure-hunter/inject/i1-default-mask-injected/expect.json +0 -1
- package/calibration/reviewers/silent-failure-hunter/inject/i1-default-mask-injected/overlay/src/sync.mjs +0 -50
- package/calibration/reviewers/silent-failure-hunter/seeds/s1-empty-catch/expect.json +0 -1
- package/calibration/reviewers/silent-failure-hunter/seeds/s1-empty-catch/overlay/src/sync.mjs +0 -42
- package/calibration/reviewers/silent-failure-hunter/seeds/s2-default-mask/expect.json +0 -1
- package/calibration/reviewers/silent-failure-hunter/seeds/s2-default-mask/overlay/src/sync.mjs +0 -49
- package/calibration/reviewers/silent-failure-hunter/seeds/s3-fire-and-forget/expect.json +0 -1
- package/calibration/reviewers/silent-failure-hunter/seeds/s3-fire-and-forget/overlay/src/sync.mjs +0 -38
- package/calibration/reviewers/silent-failure-hunter/seeds/s4-config-fallback/expect.json +0 -1
- package/calibration/reviewers/silent-failure-hunter/seeds/s4-config-fallback/overlay/src/sync.mjs +0 -49
- package/calibration/reviewers/silent-failure-hunter/suite.json +0 -1
- package/calibration/reviewers/slicing-critic/base/confirmation-email.md +0 -21
- package/calibration/reviewers/slicing-critic/base/coverage.md +0 -6
- package/calibration/reviewers/slicing-critic/base/guest-card-payment.md +0 -26
- package/calibration/reviewers/slicing-critic/base/recap.json +0 -14
- package/calibration/reviewers/slicing-critic/inject/i1-nongoal-injected/expect.json +0 -1
- package/calibration/reviewers/slicing-critic/inject/i1-nongoal-injected/overlay/guest-card-payment.md +0 -29
- package/calibration/reviewers/slicing-critic/seeds/s1-horizontal-slice/expect.json +0 -1
- package/calibration/reviewers/slicing-critic/seeds/s1-horizontal-slice/overlay/guest-card-payment.md +0 -23
- package/calibration/reviewers/slicing-critic/seeds/s2-nongoal-violation/expect.json +0 -1
- package/calibration/reviewers/slicing-critic/seeds/s2-nongoal-violation/overlay/guest-card-payment.md +0 -27
- package/calibration/reviewers/slicing-critic/seeds/s3-unfalsifiable-criterion/expect.json +0 -1
- package/calibration/reviewers/slicing-critic/seeds/s3-unfalsifiable-criterion/overlay/confirmation-email.md +0 -19
- package/calibration/reviewers/slicing-critic/seeds/s4-summary-lie/expect.json +0 -1
- package/calibration/reviewers/slicing-critic/seeds/s4-summary-lie/overlay/confirmation-email.md +0 -19
- package/calibration/reviewers/slicing-critic/seeds/s5-ui-flag-missing/expect.json +0 -1
- package/calibration/reviewers/slicing-critic/seeds/s5-ui-flag-missing/overlay/guest-card-payment.md +0 -28
- package/calibration/reviewers/slicing-critic/seeds/s6-ui-flag-spurious/expect.json +0 -1
- package/calibration/reviewers/slicing-critic/seeds/s6-ui-flag-spurious/overlay/confirmation-email.md +0 -22
- package/calibration/reviewers/slicing-critic/seeds/s7-cross-spec-contradiction/expect.json +0 -1
- package/calibration/reviewers/slicing-critic/seeds/s7-cross-spec-contradiction/overlay/confirmation-email.md +0 -24
- package/calibration/reviewers/slicing-critic/suite.json +0 -1
- package/calibration/reviewers/type-design/base/src/order.ts +0 -49
- package/calibration/reviewers/type-design/inject/i1-impossible-injected/expect.json +0 -1
- package/calibration/reviewers/type-design/inject/i1-impossible-injected/overlay/src/order.ts +0 -21
- package/calibration/reviewers/type-design/seeds/s1-stringly/expect.json +0 -1
- package/calibration/reviewers/type-design/seeds/s1-stringly/overlay/src/order.ts +0 -11
- package/calibration/reviewers/type-design/seeds/s2-impossible-states/expect.json +0 -1
- package/calibration/reviewers/type-design/seeds/s2-impossible-states/overlay/src/order.ts +0 -20
- package/calibration/reviewers/type-design/seeds/s3-public-mutable/expect.json +0 -1
- package/calibration/reviewers/type-design/seeds/s3-public-mutable/overlay/src/order.ts +0 -26
- package/calibration/reviewers/type-design/seeds/s4-any-leak/expect.json +0 -1
- package/calibration/reviewers/type-design/seeds/s4-any-leak/overlay/src/order.ts +0 -29
- package/calibration/reviewers/type-design/suite.json +0 -1
- package/calibration/skills/decompose/seeds/s1-plain-feature/expect.json +0 -1
- package/calibration/skills/decompose/seeds/s1-plain-feature/recap.json +0 -11
- package/calibration/skills/decompose/seeds/s2-nongoal-bait/expect.json +0 -1
- package/calibration/skills/decompose/seeds/s2-nongoal-bait/recap.json +0 -8
- package/calibration/skills/decompose/seeds/s3-duplicated-fact/expect.json +0 -1
- package/calibration/skills/decompose/seeds/s3-duplicated-fact/recap.json +0 -11
- package/calibration/skills/decompose/seeds/s4-fix-routes-amend/canon/checkout-flow.md +0 -19
- package/calibration/skills/decompose/seeds/s4-fix-routes-amend/canon/payment-retry.md +0 -20
- package/calibration/skills/decompose/seeds/s4-fix-routes-amend/expect.json +0 -1
- package/calibration/skills/decompose/seeds/s4-fix-routes-amend/recap.json +0 -8
- package/calibration/skills/decompose/seeds/s5-chore-no-specs/canon/checkout-flow.md +0 -19
- package/calibration/skills/decompose/seeds/s5-chore-no-specs/expect.json +0 -1
- package/calibration/skills/decompose/seeds/s5-chore-no-specs/recap.json +0 -8
- package/calibration/skills/implement/seeds/s1-add-function/plan.body.md +0 -5
- package/calibration/skills/implement/seeds/s1-add-function/plan.meta.json +0 -7
- package/calibration/skills/implement/seeds/s1-add-function/recap.json +0 -8
- package/calibration/skills/implement/seeds/s1-add-function/repo/package.json +0 -1
- package/calibration/skills/implement/seeds/s1-add-function/repo/src/clamp.mjs +0 -2
- package/calibration/skills/implement/seeds/s1-add-function/spec.body.md +0 -8
- package/calibration/skills/implement/seeds/s1-add-function/spec.meta.json +0 -8
- package/calibration/skills/implement/seeds/s2-fix-bug/plan.body.md +0 -6
- package/calibration/skills/implement/seeds/s2-fix-bug/plan.meta.json +0 -7
- package/calibration/skills/implement/seeds/s2-fix-bug/recap.json +0 -8
- package/calibration/skills/implement/seeds/s2-fix-bug/repo/package.json +0 -1
- package/calibration/skills/implement/seeds/s2-fix-bug/repo/src/slug.mjs +0 -7
- package/calibration/skills/implement/seeds/s2-fix-bug/repo/tests/slug.test.mjs +0 -7
- package/calibration/skills/implement/seeds/s2-fix-bug/spec.body.md +0 -9
- package/calibration/skills/implement/seeds/s2-fix-bug/spec.meta.json +0 -8
- package/calibration/skills/implement/seeds/s3-two-steps/plan.body.md +0 -11
- package/calibration/skills/implement/seeds/s3-two-steps/plan.meta.json +0 -10
- package/calibration/skills/implement/seeds/s3-two-steps/recap.json +0 -8
- package/calibration/skills/implement/seeds/s3-two-steps/repo/package.json +0 -1
- package/calibration/skills/implement/seeds/s3-two-steps/repo/src/pad.mjs +0 -2
- package/calibration/skills/implement/seeds/s3-two-steps/spec.body.md +0 -9
- package/calibration/skills/implement/seeds/s3-two-steps/spec.meta.json +0 -11
- package/calibration/skills/plan/seeds/s1-two-criteria/expect.json +0 -1
- package/calibration/skills/plan/seeds/s1-two-criteria/parent.body.md +0 -10
- package/calibration/skills/plan/seeds/s1-two-criteria/parent.meta.json +0 -11
- package/calibration/skills/plan/seeds/s1-two-criteria/recap.json +0 -8
- package/calibration/skills/plan/seeds/s2-five-criteria/expect.json +0 -1
- package/calibration/skills/plan/seeds/s2-five-criteria/parent.body.md +0 -11
- package/calibration/skills/plan/seeds/s2-five-criteria/parent.meta.json +0 -14
- package/calibration/skills/plan/seeds/s2-five-criteria/recap.json +0 -8
- package/calibration/skills/plan/seeds/s3-mixed-needs/expect.json +0 -1
- package/calibration/skills/plan/seeds/s3-mixed-needs/parent.body.md +0 -10
- package/calibration/skills/plan/seeds/s3-mixed-needs/parent.meta.json +0 -11
- package/calibration/skills/plan/seeds/s3-mixed-needs/recap.json +0 -8
- package/calibration/skills/plan/seeds/s4-scaffolding-pull/expect.json +0 -1
- package/calibration/skills/plan/seeds/s4-scaffolding-pull/parent.body.md +0 -9
- package/calibration/skills/plan/seeds/s4-scaffolding-pull/parent.meta.json +0 -10
- package/calibration/skills/plan/seeds/s4-scaffolding-pull/recap.json +0 -8
- package/calibration.yaml +0 -5
- package/dist/calibrate.js +0 -750
- package/dist/verbs/calibrate.js +0 -144
package/dist/gate.js
CHANGED
|
@@ -13,12 +13,12 @@ import { newRunId } from './drift.js';
|
|
|
13
13
|
import { resolveJudge } from './harness.js';
|
|
14
14
|
import { ok, renderRefusal, v } from './refusal.js';
|
|
15
15
|
import { cmd, kv, rows } from './toon.js';
|
|
16
|
-
import {
|
|
16
|
+
import { stageModel, unansweredPin } from './model.js';
|
|
17
17
|
import { docKeysFor, docsBlock, loadLensDocs, pinsBlock, promptsSha, resolvePrompt } from './reviewer.js';
|
|
18
18
|
import { runBattery } from './battery.js';
|
|
19
19
|
import { anchorFromKey, anchorKey, anchorMenu } from './verdict.js';
|
|
20
20
|
import { basisSha, deltaBlock, demote, demotionsBlock, outstandingDemotions, planDelta, reportedBy } from './delta.js';
|
|
21
|
-
import { ROUND_BOUND, appendKind, boundReached,
|
|
21
|
+
import { ROUND_BOUND, appendKind, boundReached, lastGateRun, liveExits, roundBudget, roundsSinceApprove, runsSinceReset, } from './rounds.js';
|
|
22
22
|
export { liveExits } from './rounds.js';
|
|
23
23
|
import { gateSettled, owedRun } from './verbs/next.js';
|
|
24
24
|
import { prepareStamp, writeStamp } from './stamp.js';
|
|
@@ -46,7 +46,7 @@ export function renderGateRun(ctx, entry, mode, opts = {}) {
|
|
|
46
46
|
ctx.out(kv('target', entry.artifact));
|
|
47
47
|
ctx.out(kv('round', `${entry.round} of ${budget}${mode === 'resume' ? ' (resume — content unchanged)' : ''}`));
|
|
48
48
|
ctx.out(kv('reviewed', entry.reviewed_sha.slice(0, 7)));
|
|
49
|
-
ctx.out(kv('model', `${entry.model}
|
|
49
|
+
ctx.out(kv('model', `${entry.model}${entry.cached ? ' · cached' : ''}`));
|
|
50
50
|
if (entry.delta)
|
|
51
51
|
ctx.out(kv('review', `delta since round ${entry.delta.round}`));
|
|
52
52
|
if (entry.skipped?.length)
|
|
@@ -55,6 +55,9 @@ export function renderGateRun(ctx, entry, mode, opts = {}) {
|
|
|
55
55
|
ctx.out(kv('fallback', entry.fallback.join(' → ')));
|
|
56
56
|
if (entry.rerolled?.length)
|
|
57
57
|
ctx.out(kv('rerolled', entry.rerolled.join(' · ')));
|
|
58
|
+
if (entry.carried) {
|
|
59
|
+
ctx.out(kv('carried', `${entry.carried.lenses.join(' · ')} — answered in run ${entry.carried.run} on this content and prompts`));
|
|
60
|
+
}
|
|
58
61
|
ctx.out(rows('checks', ['name', 'ok', 'detail'], entry.checks.map((c) => ({ name: c.name, ok: String(c.ok), detail: c.detail ?? '' }))).join('\n'));
|
|
59
62
|
// Row 179: what the lane did not run, beside the row that passed without it.
|
|
60
63
|
for (const h of entry.checks.flatMap((c) => c.held ?? []))
|
|
@@ -257,21 +260,15 @@ async function judge(ctx, gateName, target, flags) {
|
|
|
257
260
|
timeoutMs: cfgR.value.gates.reviewerTimeoutMs,
|
|
258
261
|
extensions: localR.value.reviewerExtensions,
|
|
259
262
|
};
|
|
260
|
-
const modelR =
|
|
263
|
+
const modelR = stageModel(cfgR.value, spec.gate);
|
|
261
264
|
if (!modelR.ok) {
|
|
262
265
|
renderRefusal(modelR.violations).forEach((l) => ctx.err(l));
|
|
263
266
|
return EXIT.REFUSED;
|
|
264
267
|
}
|
|
265
|
-
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
|
|
269
|
-
ctx.err(`warning: ${warning}`);
|
|
270
|
-
// Row 106: the key is built BEFORE invoking, so the only model knowable here is the one
|
|
271
|
-
// being asked for. Naming it `pin` is what stops the entry's `model` — what actually
|
|
272
|
-
// answered — from being compared against it by accident, which is how the streak brake
|
|
273
|
-
// below spent three releases never firing.
|
|
274
|
-
const pin = chain[0];
|
|
268
|
+
// Row 106: the key is built BEFORE invoking, so the model it names is the one being asked
|
|
269
|
+
// for. Since row 212 that is the only model a lens is asked on, but a 0.25.x round's
|
|
270
|
+
// `model` may name a stand-in, so the brake below compares `pin`.
|
|
271
|
+
const pin = modelR.value;
|
|
275
272
|
const basis = basisSha(lenses, input.snapshot?.context ?? '', pin, harness.name);
|
|
276
273
|
const backstopped = spec.backstops ? outstandingDemotions(entries, spec.backstops) : [];
|
|
277
274
|
const backstopText = spec.backstops ? demotionsBlock(spec.backstops, backstopped) : '';
|
|
@@ -358,20 +355,6 @@ async function judge(ctx, gateName, target, flags) {
|
|
|
358
355
|
// disposed of and can trip nothing.
|
|
359
356
|
const tail = runsSinceReset(entries, spec.gate).slice(-2);
|
|
360
357
|
const samePin = (r) => (r.pin ?? r.model) === key.pin && (r.harness ?? 'claude-code') === key.harness;
|
|
361
|
-
// Row 107. A fallen-back round does not spend the budget, and an exempt round that
|
|
362
|
-
// repeats forever is D67's livelock — the exemption and this trigger are one change.
|
|
363
|
-
// `prompts_sha` is deliberately NOT compared: a lens edit has nothing to do with
|
|
364
|
-
// whether a model answers, and comparing it would let an unrelated edit reset a brake
|
|
365
|
-
// on a dead pin. Checked first because when both hold, "the pinned model is not
|
|
366
|
-
// answering" is the true remedy and "your battery emits invalid verdicts" is not.
|
|
367
|
-
// No --fresh in the want: --fresh bypasses the brake and would spend a battery
|
|
368
|
-
// re-invoking the same dead pin. Fixing the pin moves key.pin, samePin goes false,
|
|
369
|
-
// and the battery runs — which is only reachable BECAUSE these rounds were exempt.
|
|
370
|
-
if (tail.length === 2 && tail.every((r) => fellBack(r) && samePin(r))) {
|
|
371
|
-
renderRefusal([v(`gates.${spec.gate}.model`, 'fallback-streak', `${tail.length} consecutive rounds fell back from ${key.pin}`, 'a reachable gates.<gate>.model — the pinned model is not answering')])
|
|
372
|
-
.forEach((l) => ctx.err(l));
|
|
373
|
-
return EXIT.REFUSED;
|
|
374
|
-
}
|
|
375
358
|
// malformed rounds don't spend the bound either — this brake is what stops an
|
|
376
359
|
// unreliable battery from re-running for free forever instead. Row 106: "same setup"
|
|
377
360
|
// always meant the same PIN, and comparing the answering rung meant two malformed
|
|
@@ -389,19 +372,26 @@ async function judge(ctx, gateName, target, flags) {
|
|
|
389
372
|
// Holding the repo-global lock across a multi-minute LLM battery refuses every state
|
|
390
373
|
// write in every other flow for its full duration, on a lock whose real job is a ~100ms
|
|
391
374
|
// commit. The guarded window opens below, immediately before the journal append.
|
|
392
|
-
// Full review first: a delta is planned only for a round that will judge (the key is fresh
|
|
393
|
-
|
|
375
|
+
// Full review first: a delta is planned only for a round that will judge (the key is fresh,
|
|
376
|
+
// or a malformed round is being repaired).
|
|
377
|
+
const delta = kind.kind === 'fresh' || kind.kind === 'repair'
|
|
394
378
|
? planDelta(root, entries, spec.gate, { reviewedSha: input.reviewedSha, snapshot: input.snapshot, basis, reviewed: input.reviewed, inDelta })
|
|
395
379
|
: undefined;
|
|
396
380
|
const block = delta ? deltaBlock(delta) : '';
|
|
381
|
+
const askedSha = delta ? promptsSha(lenses, setupText + block) : setupSha;
|
|
382
|
+
// Row 209. A repair carries verdicts only when the question is the same: a moved delta base
|
|
383
|
+
// (git gc pruned it, a judged round landed) asks every lens what the malformed round did not.
|
|
384
|
+
if (kind.kind === 'repair' && kind.from.prompts_sha !== askedSha)
|
|
385
|
+
kind = { kind: 'fresh' };
|
|
386
|
+
const repairFrom = kind.kind === 'repair' ? kind.from : undefined;
|
|
397
387
|
// A replayed delta verdict re-serves a round that already discharged all its silence could.
|
|
398
388
|
const replayedDelta = kind.kind === 'cached' && kind.from.delta !== undefined;
|
|
399
389
|
let verdicts = [];
|
|
400
390
|
let malformed = [];
|
|
401
|
-
let fallback = [];
|
|
402
391
|
let rerolled = [];
|
|
403
392
|
let model = pin;
|
|
404
393
|
let cached = false;
|
|
394
|
+
let carried = [];
|
|
405
395
|
if (kind.kind === 'cached') {
|
|
406
396
|
verdicts = kind.from.verdicts ?? [];
|
|
407
397
|
model = kind.from.model;
|
|
@@ -411,7 +401,9 @@ async function judge(ctx, gateName, target, flags) {
|
|
|
411
401
|
// Row 169: every lens at once — a round's wall clock is its slowest lens, not their sum.
|
|
412
402
|
const composed = lenses.map((lens) => {
|
|
413
403
|
const ov = input.lensOverrides?.[lens.name];
|
|
414
|
-
|
|
404
|
+
// Row 208. A delta-mode lens's floor counts the change; an override lens reviews in full.
|
|
405
|
+
const reviewed = ov?.reviewed ?? (delta?.paths && input.reviewed.kind === 'tree'
|
|
406
|
+
? { ...input.reviewed, floor: { round: delta.baseRound, paths: delta.paths } } : input.reviewed);
|
|
415
407
|
const body = ov?.promptBody ?? input.promptBody;
|
|
416
408
|
const menu = anchorMenu(reviewed);
|
|
417
409
|
return {
|
|
@@ -419,13 +411,23 @@ async function judge(ctx, gateName, target, flags) {
|
|
|
419
411
|
prompt: `${lens.contents}\n\n${docsBlock(lens.docs ?? [])}${pinsText}${deferralsText}${backstopText}${delta && inDelta(lens.name) ? block : ''}${menu ? `${menu}\n\n` : ''}## Reviewed content\n\n${body}\n`,
|
|
420
412
|
};
|
|
421
413
|
});
|
|
422
|
-
|
|
414
|
+
// Row 209. A repair asks only the lenses with no verdict in the malformed round. Both runs
|
|
415
|
+
// asked the pin alone (row 212; appendKind never repairs a 0.25.x fallen-back round), so
|
|
416
|
+
// the round's `model` stays the pin.
|
|
417
|
+
const kept = new Map((repairFrom?.verdicts ?? []).map((rv) => [rv.reviewer, rv]));
|
|
418
|
+
const pinField = `gates.${spec.gate}.model`;
|
|
419
|
+
const ranR = await runBattery(ctx, harness, pin, composed.filter((l) => !kept.has(l.name)), { cwd: root, pinField, ...extras });
|
|
423
420
|
if (!ranR.ok) {
|
|
424
|
-
renderRefusal(ranR.violations).forEach((l) => ctx.err(l));
|
|
421
|
+
renderRefusal(unansweredPin(ranR.violations, pinField, pin, harness.name)).forEach((l) => ctx.err(l));
|
|
425
422
|
return EXIT.REFUSED;
|
|
426
423
|
}
|
|
427
424
|
;
|
|
428
|
-
({
|
|
425
|
+
({ malformed } = ranR.value);
|
|
426
|
+
const answered = new Map(ranR.value.verdicts.map((rv) => [rv.reviewer, rv]));
|
|
427
|
+
const names = lenses.map((l) => l.name);
|
|
428
|
+
verdicts = names.flatMap((n) => { const rv = kept.get(n) ?? answered.get(n); return rv ? [rv] : []; });
|
|
429
|
+
carried = names.filter((n) => kept.has(n));
|
|
430
|
+
rerolled = names.filter((n) => (kept.has(n) ? repairFrom?.rerolled ?? [] : ranR.value.rerolled).includes(n));
|
|
429
431
|
// A malformed round judged nothing, so it demotes nothing.
|
|
430
432
|
// A backstopping gate never demotes what it backstops: it promised the listed finding blocks here.
|
|
431
433
|
if (delta && spec.demotes && malformed.length === 0) {
|
|
@@ -438,17 +440,6 @@ async function judge(ctx, gateName, target, flags) {
|
|
|
438
440
|
const standing = [
|
|
439
441
|
input.standingStop,
|
|
440
442
|
pinConflicts > 0 ? 'contradicts-pin — a finding disputes a settled policy pin; the human decides which one dies' : undefined,
|
|
441
|
-
// Row 98c, specified by row 107. Composed HERE, after the battery, because whether a
|
|
442
|
-
// fallback happened is not knowable at resolve() time. Dismissed by a plain
|
|
443
|
-
// --approve: --override is reserved for the bound and this is a first-round event.
|
|
444
|
-
// The remedy is deliberately absent — on round one the honest statement is that a
|
|
445
|
-
// human decides whether the verdict counts; the remedy becomes true only once the pin
|
|
446
|
-
// proves persistently dead, which is what fallback-streak above prints. It REPLACES
|
|
447
|
-
// the stderr warning that fired on this same condition: unjournaled and non-blocking,
|
|
448
|
-
// it let a substituted verdict pass behind a line that scrolls by.
|
|
449
|
-
model !== pin
|
|
450
|
-
? `fallback — reviewers ran on ${model}, not the pinned ${pin}; the human decides whether that verdict counts`
|
|
451
|
-
: undefined,
|
|
452
443
|
].filter((s) => s !== undefined).join(' · ') || undefined;
|
|
453
444
|
const checksGreen = input.checks.every((c) => c.ok);
|
|
454
445
|
const outcome = malformed.length > 0 ? 'malformed'
|
|
@@ -483,13 +474,13 @@ async function judge(ctx, gateName, target, flags) {
|
|
|
483
474
|
const entry = {
|
|
484
475
|
v: 1, t: 'gate-run', gate: spec.gate, artifact: target,
|
|
485
476
|
round: roundsSinceApprove(entriesNow, spec.gate) + 1, run_id: newRunId(),
|
|
486
|
-
reviewed_sha: input.reviewedSha, prompts_sha:
|
|
487
|
-
witness: key.witness, model, pin, harness: harness.name,
|
|
477
|
+
reviewed_sha: input.reviewedSha, prompts_sha: askedSha,
|
|
478
|
+
witness: key.witness, model, pin, harness: harness.name,
|
|
488
479
|
...(localR.value.reviewerExtensions.length ? { reviewer_extensions: localR.value.reviewerExtensions } : {}),
|
|
489
480
|
...(cached ? { cached: true } : {}),
|
|
490
481
|
...(flags.manual ? { manual: true } : {}),
|
|
491
|
-
...(fallback.length ? { fallback } : {}),
|
|
492
482
|
...(rerolled.length ? { rerolled } : {}),
|
|
483
|
+
...(repairFrom && carried.length ? { carried: { run: repairFrom.run_id, lenses: carried } } : {}),
|
|
493
484
|
...(dropped.length ? { skipped: dropped } : {}),
|
|
494
485
|
...(outcome === 'stopped' && standing ? { standing } : {}),
|
|
495
486
|
...(input.artifactSha ? { artifact_sha: input.artifactSha } : {}),
|
package/dist/gitio.js
CHANGED
|
@@ -102,6 +102,9 @@ const LOCAL_STATE_FILES = new Set([
|
|
|
102
102
|
'.witness/drive.lock.steal',
|
|
103
103
|
'.witness/txn.json',
|
|
104
104
|
'.witness/allow.json',
|
|
105
|
+
// Row 212: `witness calibrate` wrote this through 0.25.x. Nothing reads it now, but a repo
|
|
106
|
+
// scaffolded before init ignored it may still hold one untracked, and an unrelated-dirty
|
|
107
|
+
// refusal there would block every state write.
|
|
105
108
|
'.witness/calibration.local.yaml',
|
|
106
109
|
// Row 90's machine-config file is this tier too, and the exemption is load-bearing
|
|
107
110
|
// rather than belt-and-braces: init only gitignores it for repos scaffolded at
|
|
@@ -114,7 +117,8 @@ const LOCAL_STATE_FILES = new Set([
|
|
|
114
117
|
// and the exemption is load-bearing for the same reason: init writes its .gitignore block only
|
|
115
118
|
// when scaffolding, so on every repo older than the row a draft is untracked-but-visible under a
|
|
116
119
|
// state dir, and an unrelated-dirty refusal there would block the very recap the grill lands.
|
|
117
|
-
|
|
120
|
+
// Row 203: drive's live folder (what needs the human, the waiting chat's lock) is the same tier.
|
|
121
|
+
const LOCAL_STATE_DIRS = ['.witness/drafts/', '.witness/live/'];
|
|
118
122
|
export function dirtyStatePaths(root) {
|
|
119
123
|
const res = tryGit(root, 'status', '--porcelain', '--untracked-files=all', '--', ...stateDirs(root));
|
|
120
124
|
if (!res.ok || res.out === '')
|
package/dist/harness.js
CHANGED
|
@@ -75,6 +75,7 @@ const REGISTRY = {
|
|
|
75
75
|
launch: 'claude',
|
|
76
76
|
relay: '/clear',
|
|
77
77
|
session: 'CLAUDE_CODE_SESSION_ID',
|
|
78
|
+
waitMode: 'background',
|
|
78
79
|
settings: '.claude/settings.json',
|
|
79
80
|
bundled: true,
|
|
80
81
|
payload: [
|
|
@@ -116,6 +117,7 @@ const REGISTRY = {
|
|
|
116
117
|
defaultProvider: 'anthropic',
|
|
117
118
|
relay: '/new',
|
|
118
119
|
session: 'PI_SESSION_ID',
|
|
120
|
+
waitMode: 'add-on',
|
|
119
121
|
bundled: false,
|
|
120
122
|
payload: [
|
|
121
123
|
{ from: 'plugin/commands/witness.md', to: '.pi/prompts/witness.md' },
|
|
@@ -154,9 +156,9 @@ const REGISTRY = {
|
|
|
154
156
|
worker: {
|
|
155
157
|
// No bypass flag exists or is needed: pi's built-in tools are not approval-gated
|
|
156
158
|
// (`pi --help` lists only --approve/--no-approve, which govern trusting
|
|
157
|
-
// project-local files). --no-session keeps a
|
|
158
|
-
// session store; the worker otherwise keeps its skills and context files, which
|
|
159
|
-
//
|
|
159
|
+
// project-local files). --no-session keeps a headless worker's run out of the user's
|
|
160
|
+
// session store; the worker otherwise keeps its skills and context files, which a
|
|
161
|
+
// drive session runs on.
|
|
160
162
|
spawn: (prompt, model) => ({ cmd: 'pi', args: ['-p', prompt, '--no-session', ...modelFlags(REGISTRY.pi, model)], env: {} }),
|
|
161
163
|
},
|
|
162
164
|
},
|
|
@@ -193,8 +195,8 @@ function walk(ladder) {
|
|
|
193
195
|
const r = loadHarness(rung.name);
|
|
194
196
|
return r.ok ? ok({ harness: r.value, source: rung.source }) : refuse(r.violations);
|
|
195
197
|
}
|
|
196
|
-
// THE JUDGE — which harness runs this repo's gate reviewers
|
|
197
|
-
//
|
|
198
|
+
// THE JUDGE — which harness runs this repo's gate reviewers and is probed for
|
|
199
|
+
// runnability. A committed declaration wins, because reviewer identity
|
|
198
200
|
// is a property of the repo's evidence trail and must be comparable across machines; row
|
|
199
201
|
// 88 already said an identity chosen by ambient environment is the opposite of a pin.
|
|
200
202
|
export function resolveJudge(env, declared) {
|
|
@@ -207,10 +209,10 @@ export function resolveJudge(env, declared) {
|
|
|
207
209
|
export function resolveDriver(env, declared) {
|
|
208
210
|
return walk([detectedRung(env), declaredRung(declared)]);
|
|
209
211
|
}
|
|
210
|
-
// One renderer for both orientation surfaces
|
|
211
|
-
//
|
|
212
|
-
//
|
|
213
|
-
//
|
|
212
|
+
// One renderer for both orientation surfaces: the judge must read identically on `check`
|
|
213
|
+
// and `status`, or the two screens disagree about which binary judges the same repo.
|
|
214
|
+
// Provenance is RENDERED here, never stored — HarnessSource stays a resolution fact and the
|
|
215
|
+
// wording stays a presentation one.
|
|
214
216
|
//
|
|
215
217
|
// It prints in every state, including `declared`: that line read from a foreign session
|
|
216
218
|
// is exactly what row 105 exists to surface, and a line that appeared only in the bad
|
|
@@ -231,7 +233,7 @@ export function judgeLine(r) {
|
|
|
231
233
|
// Decision 9: the model flag is a renderer, not a string. Pi's default provider is
|
|
232
234
|
// `google`, so a bare `--model claude-opus-5` in a Pi handoff resolves wrong or not at
|
|
233
235
|
// all — and a relay session silently running an unpinned model corrupts what row 83's
|
|
234
|
-
// pins
|
|
236
|
+
// pins rest on.
|
|
235
237
|
//
|
|
236
238
|
// Revision 9: the provider is the HARNESS's default, never a config key.
|
|
237
239
|
//
|
package/dist/install.js
CHANGED
|
@@ -132,6 +132,21 @@ export function payloadHomes(root) {
|
|
|
132
132
|
.map((e) => join(dir, e.name))
|
|
133
133
|
.sort()];
|
|
134
134
|
}
|
|
135
|
+
// Row 102: content, not pins — every installed payload file, in every home, that differs from
|
|
136
|
+
// what this CLI ships. A shipped file that cannot be read is a packaging failure, not staleness,
|
|
137
|
+
// and is skipped. Read by `check` (payload-stale) and by `next`, whose waiting Pi chat falls
|
|
138
|
+
// back to the foreground when its add-on is older than this CLI (row 204).
|
|
139
|
+
export function payloadStale(root, harness) {
|
|
140
|
+
const installed = harness.payload.filter((p) => existsSync(join(root, p.to)));
|
|
141
|
+
return payloadHomes(root).flatMap((home) => installed
|
|
142
|
+
.filter((p) => {
|
|
143
|
+
const src = join(packageRoot(), p.from);
|
|
144
|
+
if (!existsSync(src) || !existsSync(join(home, p.to)))
|
|
145
|
+
return false;
|
|
146
|
+
return readFileSync(join(home, p.to), 'utf8') !== readFileSync(src, 'utf8');
|
|
147
|
+
})
|
|
148
|
+
.map((p) => (home === root ? p.to : `${home}: ${p.to}`)));
|
|
149
|
+
}
|
|
135
150
|
// Preflight EVERY home before writing ANY. install.ts's standing doctrine is that a
|
|
136
151
|
// refusal leaves nothing half-installed; across homes that matters more, not less — a
|
|
137
152
|
// half-upgraded set of homes IS the skew row 116 refuses and this row prevents.
|
package/dist/live.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
2
|
+
import { closeSync, constants, lstatSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, writeSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { KEPT_STOP_NAMES } from './autonomy.js';
|
|
5
|
+
import { TARGETLESS, driveHolder } from './drive-presence.js';
|
|
6
|
+
import { effortStreams } from './journal.js';
|
|
7
|
+
import { GATE_NAMES } from './settings.js';
|
|
8
|
+
import { ensureExcluded } from './worktree.js';
|
|
9
|
+
// Row 203. Drive's set-asides — stuck and capped above all — live only in its memory (D145),
|
|
10
|
+
// and a chat waiting beside it must know them. So drive publishes what needs the human here,
|
|
11
|
+
// machine-local and never committed (excluded the three ways the drafts are). Row 145: a killed
|
|
12
|
+
// drive leaves no cleanup, so a reader trusts the file only while the drive it names holds the
|
|
13
|
+
// drive lock. And it is display data at most: only ids and kinds survive the read, never text,
|
|
14
|
+
// and every line a reader prints is rendered by the CLI (`drive-presence.ts`'s doctrine).
|
|
15
|
+
export const LIVE_DIR = '.witness/live';
|
|
16
|
+
const DRIVE_FILE = 'drive.json';
|
|
17
|
+
const WAITER_FILE = 'waiter.json';
|
|
18
|
+
const END_REASONS = ['done', 'idle-limit', 'ceiling', 'usage', 'autonomy-off', 'spawn-failed', 'signal'];
|
|
19
|
+
const ASIDE_KINDS = ['kept', 'decision', 'conversation', 'merge', 'stuck', 'capped'];
|
|
20
|
+
// A folder a repo committed as a symlink would aim drive's writes anywhere: refused, as
|
|
21
|
+
// `detachDrive` refuses a linked log. Absent is fine — the first write makes it.
|
|
22
|
+
function liveDir(root, create) {
|
|
23
|
+
const dir = join(root, LIVE_DIR);
|
|
24
|
+
try {
|
|
25
|
+
if (!lstatSync(dir).isDirectory())
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
if (e.code !== 'ENOENT' || !create)
|
|
30
|
+
return undefined;
|
|
31
|
+
mkdirSync(dir, { recursive: true });
|
|
32
|
+
}
|
|
33
|
+
return dir;
|
|
34
|
+
}
|
|
35
|
+
// Written to a temp name and renamed, so a reader never sees half a file. The temp name is
|
|
36
|
+
// random and created exclusively without following a link: a repo can commit files inside a
|
|
37
|
+
// real .witness/live/, and a link at a name drive would write through could aim it anywhere.
|
|
38
|
+
// The rename replaces whatever entry holds the final name, a link included, never its target.
|
|
39
|
+
function put(root, file, value) {
|
|
40
|
+
// Spec c2 (final review I1): a repo whose ignore rules predate this folder must never show it,
|
|
41
|
+
// and drive may run without starting the session whose worktree would exclude it — so the
|
|
42
|
+
// write excludes it first, as a draft's does. Best effort: a write is never refused for it.
|
|
43
|
+
try {
|
|
44
|
+
ensureExcluded(root);
|
|
45
|
+
}
|
|
46
|
+
catch { /* not a git checkout we can write to */ }
|
|
47
|
+
const dir = liveDir(root, true);
|
|
48
|
+
if (dir === undefined)
|
|
49
|
+
return;
|
|
50
|
+
const tmp = join(dir, `.${file}.${randomBytes(8).toString('hex')}.tmp`);
|
|
51
|
+
let fd;
|
|
52
|
+
try {
|
|
53
|
+
fd = openSync(tmp, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o644);
|
|
54
|
+
writeSync(fd, JSON.stringify(value));
|
|
55
|
+
closeSync(fd);
|
|
56
|
+
fd = undefined;
|
|
57
|
+
renameSync(tmp, join(dir, file));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// best effort: a reader with no file reads "unknown", never a wrong answer
|
|
61
|
+
if (fd !== undefined)
|
|
62
|
+
closeSync(fd);
|
|
63
|
+
rmSync(tmp, { force: true });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function get(root, file) {
|
|
67
|
+
const dir = liveDir(root, false);
|
|
68
|
+
if (dir === undefined)
|
|
69
|
+
return undefined;
|
|
70
|
+
try {
|
|
71
|
+
const p = join(dir, file);
|
|
72
|
+
if (!lstatSync(p).isFile())
|
|
73
|
+
return undefined;
|
|
74
|
+
return JSON.parse(readFileSync(p, 'utf8'));
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const isPid = (x) => Number.isInteger(x) && x > 0;
|
|
81
|
+
export function writeLive(root, state) {
|
|
82
|
+
put(root, DRIVE_FILE, state);
|
|
83
|
+
}
|
|
84
|
+
// Every field is checked against what this CLI knows: a target that is no canon id or effort, a kind,
|
|
85
|
+
// gate or stop this CLI does not name, is dropped whole. No free text is kept.
|
|
86
|
+
export function readLive(root, canon) {
|
|
87
|
+
const raw = get(root, DRIVE_FILE);
|
|
88
|
+
if (raw === undefined || raw === null || typeof raw !== 'object' || !isPid(raw.pid))
|
|
89
|
+
return undefined;
|
|
90
|
+
// Canon ids and effort slugs: drive sets aside effort-level work too (final review b-I4).
|
|
91
|
+
const ids = new Set([...canon.docs.map((d) => String(d.meta.id)), ...effortStreams(root)]);
|
|
92
|
+
const stops = Object.keys(KEPT_STOP_NAMES);
|
|
93
|
+
const asides = [];
|
|
94
|
+
for (const a of Array.isArray(raw.asides) ? raw.asides : []) {
|
|
95
|
+
if (a === null || typeof a !== 'object')
|
|
96
|
+
continue;
|
|
97
|
+
const { target, kind, gate, stop } = a;
|
|
98
|
+
if (typeof target !== 'string' || (target !== TARGETLESS && !ids.has(target)))
|
|
99
|
+
continue;
|
|
100
|
+
if (!ASIDE_KINDS.includes(kind))
|
|
101
|
+
continue;
|
|
102
|
+
if (gate !== undefined && !GATE_NAMES.includes(gate))
|
|
103
|
+
continue;
|
|
104
|
+
if (stop !== undefined && !stops.includes(stop))
|
|
105
|
+
continue;
|
|
106
|
+
asides.push({
|
|
107
|
+
target, kind: kind,
|
|
108
|
+
...(gate !== undefined ? { gate: gate } : {}), ...(stop !== undefined ? { stop: stop } : {}),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const ended = END_REASONS.includes(raw.ended) ? { ended: raw.ended } : {};
|
|
112
|
+
return { pid: raw.pid, asides, ...ended };
|
|
113
|
+
}
|
|
114
|
+
// The live drive's state: only while the drive the file names holds the drive lock.
|
|
115
|
+
export function liveDrive(root, canon) {
|
|
116
|
+
const state = readLive(root, canon);
|
|
117
|
+
return state !== undefined && driveHolder(root)?.pid === state.pid ? state : undefined;
|
|
118
|
+
}
|
|
119
|
+
// How the last drive ended, once it no longer holds the lock — read even while its process is
|
|
120
|
+
// still on its way out, which is when a waiter first sees the lock gone.
|
|
121
|
+
export function lastEnd(root, canon) {
|
|
122
|
+
const state = readLive(root, canon);
|
|
123
|
+
return state !== undefined && driveHolder(root)?.pid !== state.pid ? state.ended : undefined;
|
|
124
|
+
}
|
|
125
|
+
// Row 204. One waiting chat per repo: the newest takes over, and the one it displaced learns so
|
|
126
|
+
// on its next poll. Final review C2: the waiter names its chat too (the harness's session, hashed
|
|
127
|
+
// — the raw id never lands on disk), so a chat whose human typed while it waited, and whose new
|
|
128
|
+
// turn started a second wait, reads as replaced by itself rather than taken over by another.
|
|
129
|
+
const chatKey = (session) => session === undefined || session === '' ? undefined : createHash('sha1').update(session).digest('hex').slice(0, 12);
|
|
130
|
+
export function takeWaiter(root, pid, session) {
|
|
131
|
+
const chat = chatKey(session);
|
|
132
|
+
put(root, WAITER_FILE, { pid, ...(chat !== undefined ? { chat } : {}) });
|
|
133
|
+
}
|
|
134
|
+
export function waiterState(root, pid, session) {
|
|
135
|
+
const raw = get(root, WAITER_FILE);
|
|
136
|
+
if (raw !== undefined && raw !== null && raw.pid === pid)
|
|
137
|
+
return 'mine';
|
|
138
|
+
const chat = chatKey(session);
|
|
139
|
+
return chat !== undefined && raw !== undefined && raw !== null && raw.chat === chat ? 'replaced' : 'taken';
|
|
140
|
+
}
|
|
141
|
+
export function waiterIs(root, pid) {
|
|
142
|
+
return waiterState(root, pid) === 'mine';
|
|
143
|
+
}
|
package/dist/migration.js
CHANGED
|
@@ -144,7 +144,7 @@ export function migrateValues(raw, from, opts) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
// What is missing takes the current default. An ambient setting meant something else while
|
|
147
|
-
// absent (the judge ladder, the
|
|
147
|
+
// absent (the judge ladder, the session default, "not configured"), so only a write fills it —
|
|
148
148
|
// the judge with the session's own harness — and names it `filled`.
|
|
149
149
|
for (const s of list) {
|
|
150
150
|
if (s.since > to || getIn(out, s.path) !== undefined || !fillable(out, s.path))
|
package/dist/model.js
CHANGED
|
@@ -1,35 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { parse } from 'yaml';
|
|
5
|
-
import { checkPin } from './pin.js';
|
|
6
|
-
import { ok, refuse } from './refusal.js';
|
|
1
|
+
import { checkPin, parsePin } from './pin.js';
|
|
2
|
+
import { humanCall, ok, refuse, v } from './refusal.js';
|
|
7
3
|
export { MODEL_ALIASES } from './pin.js';
|
|
8
4
|
export const SESSION_DEFAULT = 'session-default';
|
|
9
|
-
export function shippedMatrixPath() {
|
|
10
|
-
return join(dirname(fileURLToPath(import.meta.url)), '..', 'calibration.yaml');
|
|
11
|
-
}
|
|
12
|
-
// Per-(harness, model) calibration (Decision 88): a pi-invoked reviewer on the same
|
|
13
|
-
// model id is a DIFFERENT reviewer. Legacy top-level `models:` predates the harness
|
|
14
|
-
// dimension and was only ever measured through claude -p — it reads as claude-code.
|
|
15
|
-
function readModels(path, harness) {
|
|
16
|
-
if (!existsSync(path))
|
|
17
|
-
return [];
|
|
18
|
-
const doc = parse(readFileSync(path, 'utf8'));
|
|
19
|
-
const scoped = doc?.matrices?.[harness]?.models;
|
|
20
|
-
if (Array.isArray(scoped))
|
|
21
|
-
return scoped.map(String);
|
|
22
|
-
return harness === 'claude-code' && Array.isArray(doc?.models) ? doc.models.map(String) : [];
|
|
23
|
-
}
|
|
24
|
-
export function loadMatrix(root, harness) {
|
|
25
|
-
return {
|
|
26
|
-
shipped: readModels(shippedMatrixPath(), harness),
|
|
27
|
-
local: readModels(join(root, '.witness', 'calibration.local.yaml'), harness),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
5
|
// A stage's model pin, from its own setting (row 193: nothing inherited). A gate's pin drives
|
|
31
6
|
// its reviewers AND, for implement, its worker agent; the arbiter's is its own (row 172).
|
|
32
|
-
// Undefined only for an older file that never pinned one: the
|
|
7
|
+
// Undefined only for an older file that never pinned one: the session default answers.
|
|
33
8
|
export function stagePin(cfg, role) {
|
|
34
9
|
const pin = role === 'arbiter' ? cfg.arbiter.model : cfg.gates[role].model;
|
|
35
10
|
if (pin === undefined)
|
|
@@ -37,45 +12,37 @@ export function stagePin(cfg, role) {
|
|
|
37
12
|
const checked = checkPin(role === 'arbiter' ? 'arbiter.model' : `gates.${role}.model`, pin);
|
|
38
13
|
return checked.ok ? ok(pin) : refuse(checked.violations);
|
|
39
14
|
}
|
|
40
|
-
|
|
15
|
+
// Row 212. The one model a stage's reviewers (or the arbiter) are asked on: its pin, else the
|
|
16
|
+
// session default. There is no stand-in — a model that cannot be invoked refuses the gate.
|
|
17
|
+
export function stageModel(cfg, role) {
|
|
41
18
|
const pinR = stagePin(cfg, role);
|
|
42
19
|
if (!pinR.ok)
|
|
43
20
|
return refuse(pinR.violations);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
? `calibration matrix is empty — no calibrated model exists yet; ${headLabel} runs uncalibrated`
|
|
64
|
-
: `reviewer model ${headLabel} is below the model floor — no calibration matrix entry covers it`;
|
|
65
|
-
return ok({ chain, calibrationOf, warning, warningKind });
|
|
21
|
+
return ok(pinR.value ?? SESSION_DEFAULT);
|
|
22
|
+
}
|
|
23
|
+
// Row 212 (C3). Every stand-in round in the field came from a pin edited into a model the
|
|
24
|
+
// harness could not invoke, so a refusal on a pinned model names the setting to fix. It is a
|
|
25
|
+
// human's call only when the harness's own error names that model as one it cannot run — only
|
|
26
|
+
// the config's owner knows which model they meant. Anything else (a provider blip, a missing
|
|
27
|
+
// binary, an expired login) is named, not blamed: clearing that error and re-running is the
|
|
28
|
+
// fix, and the human trailer would say re-running cannot clear it.
|
|
29
|
+
export function unansweredPin(rows, field, model, harness) {
|
|
30
|
+
if (model === SESSION_DEFAULT)
|
|
31
|
+
return rows;
|
|
32
|
+
const failed = rows.filter((x) => x.rule === 'reviewer-invocation');
|
|
33
|
+
if (failed.length === 0)
|
|
34
|
+
return rows;
|
|
35
|
+
const named = failed.some((x) => namesMissingModel(x.got, model));
|
|
36
|
+
const row = v(field, 'pin-unanswered', model, named
|
|
37
|
+
? `a model the ${harness} harness can invoke — its error names this pin, so fix it in witness.config.yaml`
|
|
38
|
+
: `a model the ${harness} harness can invoke — if the error above is about this pin, fix it in witness.config.yaml; otherwise clear that error and re-run`);
|
|
39
|
+
return [...rows, named ? humanCall(row) : row];
|
|
66
40
|
}
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
for (const gate of ['decompose', 'plan', 'implement', 'ship', 'design']) {
|
|
75
|
-
const r = resolveModel(cfg, matrix, gate);
|
|
76
|
-
if (r.ok && r.value.warning) {
|
|
77
|
-
byWarning.set(r.value.warning, [...(byWarning.get(r.value.warning) ?? []), gate]);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return [...byWarning].map(([warning, gates]) => `${gates.join(' · ')}: ${warning}`);
|
|
41
|
+
// The model id itself in the error, beside a phrase saying it cannot be run: claude's
|
|
42
|
+
// `not_found_error` and its "issue with the selected model" text, pi's "not found" — an error
|
|
43
|
+
// that names no model (a 5xx, a login, ENOENT) is about something else.
|
|
44
|
+
const MISSING_MODEL = /not.?found|not exist|unknown|invalid|unsupported|not available|access to/i;
|
|
45
|
+
function namesMissingModel(got, pin) {
|
|
46
|
+
const parsed = parsePin('model', pin);
|
|
47
|
+
return got.includes(parsed.ok ? parsed.value.model : pin) && MISSING_MODEL.test(got);
|
|
81
48
|
}
|