instar 1.3.897 → 1.3.899

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.
Files changed (32) hide show
  1. package/.claude/skills/autonomous/hooks/autonomous-stop-hook.sh +19 -2
  2. package/dist/core/AutonomousRealCheckAnnotator.d.ts +2 -3
  3. package/dist/core/AutonomousRealCheckAnnotator.d.ts.map +1 -1
  4. package/dist/core/AutonomousRealCheckAnnotator.js +2 -25
  5. package/dist/core/AutonomousRealCheckAnnotator.js.map +1 -1
  6. package/dist/core/AutonomousRunStore.d.ts +7 -0
  7. package/dist/core/AutonomousRunStore.d.ts.map +1 -1
  8. package/dist/core/AutonomousRunStore.js.map +1 -1
  9. package/dist/core/PostUpdateMigrator.d.ts +2 -0
  10. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  11. package/dist/core/PostUpdateMigrator.js +117 -2
  12. package/dist/core/PostUpdateMigrator.js.map +1 -1
  13. package/dist/data/provenanceCoverage.d.ts +15 -0
  14. package/dist/data/provenanceCoverage.d.ts.map +1 -1
  15. package/dist/data/provenanceCoverage.js +61 -0
  16. package/dist/data/provenanceCoverage.js.map +1 -1
  17. package/dist/server/CapabilityIndex.js +1 -1
  18. package/dist/server/CapabilityIndex.js.map +1 -1
  19. package/dist/server/routes.d.ts.map +1 -1
  20. package/dist/server/routes.js +105 -3
  21. package/dist/server/routes.js.map +1 -1
  22. package/package.json +2 -1
  23. package/scripts/feature-maturation-plan-gate.mjs +1 -0
  24. package/skills/spec-converge/scripts/write-convergence-tag.mjs +13 -0
  25. package/src/core/FeatureMaturationPlanGate.mjs +58 -0
  26. package/src/data/builtin-manifest.json +63 -63
  27. package/src/data/provenanceCoverage.ts +74 -0
  28. package/src/scaffold/templates/jobs/instar/llm-decision-grading.md +2 -2
  29. package/upgrades/1.3.898.md +24 -0
  30. package/upgrades/1.3.899.md +28 -0
  31. package/upgrades/side-effects/decision-quality-grading.md +86 -0
  32. package/upgrades/side-effects/feature-maturation-plan-visibility.md +84 -0
@@ -71,7 +71,8 @@ import { classifyMachineEmptyState } from './poolEmptyState.js';
71
71
  // LLM-Decision Quality Meter (llm-decision-quality-meter §5.5) — P9/P10 routes.
72
72
  import { runDecisionGradingPass } from '../core/decisionGradingPass.js';
73
73
  import { annotateDecisionOutcome, getDecisionAnnotationRejectionCounters } from '../core/DecisionQualityRecorderImpl.js';
74
- import { PROVENANCE_COVERAGE } from '../data/provenanceCoverage.js';
74
+ import { annotateCompletionRealcheck } from '../core/AutonomousRealCheckAnnotator.js';
75
+ import { DP_COMPLETION_EVALUATE, PROVENANCE_COVERAGE, findWiredWithoutGraders } from '../data/provenanceCoverage.js';
75
76
  import { RemoteCloseAudit } from '../core/RemoteCloseAudit.js';
76
77
  import { RemoteAckStore } from '../core/RemoteAckStore.js';
77
78
  import { FailureLedger } from '../monitoring/FailureLedger.js';
@@ -4040,6 +4041,99 @@ export function createRoutes(ctx) {
4040
4041
  res.status(409).json({ ok: false, error: 'runId mismatch', currentRunId: rec.runId });
4041
4042
  return;
4042
4043
  }
4044
+ const rawRealcheck = body.realcheck;
4045
+ const rawRealcheckRow = rawRealcheck && typeof rawRealcheck === 'object'
4046
+ ? rawRealcheck
4047
+ : null;
4048
+ const realcheckPayloadValid = rawRealcheckRow?.configured === false || (rawRealcheckRow?.configured === true && (rawRealcheckRow.outcome === 'pass' || rawRealcheckRow.outcome === 'fail'));
4049
+ const realcheck = rawRealcheckRow?.configured === true && realcheckPayloadValid
4050
+ ? {
4051
+ configured: true,
4052
+ outcome: rawRealcheckRow.outcome,
4053
+ ...(typeof rawRealcheckRow.exitCode === 'number' && Number.isFinite(rawRealcheckRow.exitCode)
4054
+ ? { exitCode: Math.max(-1, Math.min(255, Math.trunc(rawRealcheckRow.exitCode))) }
4055
+ : {}),
4056
+ }
4057
+ : { configured: false };
4058
+ const terminal = body.terminal !== false;
4059
+ const correlationId = rec.lastCompletionCorrelationId;
4060
+ const priorObservation = correlationId ? rec.realcheckOutcomeByCorrelation?.[correlationId] : undefined;
4061
+ let realcheckAnnotation = 'skipped-unconfigured';
4062
+ if (body.met !== true) {
4063
+ realcheckAnnotation = 'skipped-not-met';
4064
+ }
4065
+ else if (realcheck.configured && priorObservation && priorObservation.outcome !== realcheck.outcome) {
4066
+ realcheckAnnotation = 'conflicting-observation';
4067
+ }
4068
+ else if (realcheck.configured && priorObservation?.applied) {
4069
+ realcheckAnnotation = 'duplicate-observation';
4070
+ }
4071
+ else if (rec.status !== 'active' && !(realcheck.configured && priorObservation && !priorObservation.applied)) {
4072
+ realcheckAnnotation = 'skipped-terminal-record';
4073
+ }
4074
+ else {
4075
+ const observedAtMs = Date.parse(rec.lastCompletionCorrelationAt ?? '');
4076
+ const stableObservedAtMs = Number.isFinite(observedAtMs) ? observedAtMs : Date.parse(rec.registeredAt);
4077
+ let reservationReady = !realcheck.configured || !correlationId || priorObservation !== undefined;
4078
+ if (!reservationReady && realcheck.configured && correlationId) {
4079
+ try {
4080
+ const reserved = autonomousRunStore.update(rec.topicId, rec.runId, (current) => {
4081
+ current.realcheckOutcomeByCorrelation ??= {};
4082
+ current.realcheckOutcomeByCorrelation[correlationId] ??= {
4083
+ outcome: realcheck.outcome,
4084
+ observedAtMs: stableObservedAtMs,
4085
+ applied: false,
4086
+ };
4087
+ });
4088
+ if (!reserved)
4089
+ throw new Error('run-record-missing');
4090
+ reservationReady = true;
4091
+ }
4092
+ catch {
4093
+ realcheckAnnotation = 'observation-persist-error';
4094
+ }
4095
+ }
4096
+ if (reservationReady) {
4097
+ realcheckAnnotation = annotateCompletionRealcheck(rec, { met: body.met === true, realcheck }, (annotation) => {
4098
+ const applied = annotateDecisionOutcome({
4099
+ correlationId: annotation.correlationId,
4100
+ ruleId: annotation.ruleId,
4101
+ gradedBy: { component: annotation.gradedBy.component },
4102
+ grade: annotation.grade,
4103
+ decisionPoint: DP_COMPLETION_EVALUATE,
4104
+ evidence: annotation.evidence,
4105
+ });
4106
+ if (!applied.applied)
4107
+ throw new Error(applied.rejected ?? (applied.disabled ? 'disabled' : 'not-applied'));
4108
+ }, stableObservedAtMs);
4109
+ if ((realcheckAnnotation === 'annotated-right' || realcheckAnnotation === 'annotated-wrong') && correlationId && realcheck.configured) {
4110
+ try {
4111
+ const marked = autonomousRunStore.update(rec.topicId, rec.runId, (current) => {
4112
+ const receipt = current.realcheckOutcomeByCorrelation?.[correlationId];
4113
+ if (receipt?.outcome === realcheck.outcome)
4114
+ receipt.applied = true;
4115
+ });
4116
+ if (!marked)
4117
+ throw new Error('run-record-missing');
4118
+ }
4119
+ catch {
4120
+ // The pre-annotation reservation still blocks opposite replay. A
4121
+ // same-outcome replay safely retries the idempotent annotation.
4122
+ realcheckAnnotation = 'annotation-applied-receipt-pending';
4123
+ }
4124
+ }
4125
+ }
4126
+ }
4127
+ if (!terminal) {
4128
+ res.json({
4129
+ ok: true,
4130
+ runId: rec.runId,
4131
+ terminal: false,
4132
+ realcheckAnnotation,
4133
+ ...(rawRealcheck !== undefined && !realcheckPayloadValid ? { realcheckPayloadInvalid: true } : {}),
4134
+ });
4135
+ return;
4136
+ }
4043
4137
  let unbuiltEnumerated = 0;
4044
4138
  if (scopeAccretionEffective(rec)) {
4045
4139
  try {
@@ -4056,7 +4150,14 @@ export function createRoutes(ctx) {
4056
4150
  }
4057
4151
  }
4058
4152
  autonomousRunStore.markTerminal(rec.topicId, rec.runId, 'ended', reason);
4059
- res.json({ ok: true, runId: rec.runId, unbuiltEnumerated });
4153
+ res.json({
4154
+ ok: true,
4155
+ runId: rec.runId,
4156
+ terminal: true,
4157
+ unbuiltEnumerated,
4158
+ realcheckAnnotation,
4159
+ ...(rawRealcheck !== undefined && !realcheckPayloadValid ? { realcheckPayloadInvalid: true } : {}),
4160
+ });
4060
4161
  });
4061
4162
  // ── POST /autonomous/:topic/ratify-deferral (R23 path 1 — PIN, phone-first) ──
4062
4163
  router.post('/autonomous/:topic/ratify-deferral', async (req, res) => {
@@ -14403,11 +14504,12 @@ document.getElementById('mcpForm').addEventListener('submit', async function (e)
14403
14504
  totalCounters.joinMiss += c.joinMiss;
14404
14505
  totalCounters.droppedByBudget += c.droppedByBudget;
14405
14506
  }
14507
+ const wiredButNoGrader = findWiredWithoutGraders();
14406
14508
  return {
14407
14509
  sinceHours,
14408
14510
  gate: { enabled: true, dryRun: ctx.config.provenance?.uniformSeam?.dryRun !== false },
14409
14511
  points,
14410
- censusDebt: { wired, pending, exempt, pendingRefDead },
14512
+ censusDebt: { wired, pending, exempt, pendingRefDead, wiredButNoGrader },
14411
14513
  counters: totalCounters,
14412
14514
  // The four §5.5 annotation-rejection counters, by class.
14413
14515
  rejections: getDecisionAnnotationRejectionCounters(),