@buildaharness/aielia 0.3.2 → 0.3.3

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.
@@ -934,13 +934,19 @@ function isNearDuplicateText(a, b) {
934
934
  const lb = b.toLowerCase();
935
935
  return la.includes(lb) || lb.includes(la);
936
936
  }
937
+ function modelInferredFactsEnabled(env) {
938
+ const source = typeof process !== "undefined" ? process.env : {};
939
+ const raw = String(source.AUDIT_MODEL_INFERRED_FACTS ?? "").trim().toLowerCase();
940
+ if (raw === "") return true;
941
+ return !["0", "false", "off", "no", "disabled"].includes(raw);
942
+ }
937
943
  function mergeTurnFacts(lexicalFacts, llmFacts) {
938
944
  const novelLlmFacts = llmFacts.filter((llmFact) => !lexicalFacts.some((lexFact) => isNearDuplicateText(lexFact.text, llmFact.text)));
939
945
  return [...lexicalFacts, ...novelLlmFacts];
940
946
  }
941
947
  function buildTurnFacts(sessionId, userMessage, statedFacts) {
942
948
  const lexicalFacts = extractFactsFromTurn(userMessage, `turn:${sessionId}`);
943
- const llmFacts = statedFacts.map((fact) => ({
949
+ const llmFacts = modelInferredFactsEnabled() ? statedFacts.map((fact) => ({
944
950
  text: fact.text,
945
951
  extractedAt: (/* @__PURE__ */ new Date()).toISOString(),
946
952
  sourceTurn: `turn:${sessionId}`,
@@ -948,7 +954,7 @@ function buildTurnFacts(sessionId, userMessage, statedFacts) {
948
954
  durable: fact.durable,
949
955
  confidence: fact.confidence,
950
956
  category: fact.category
951
- }));
957
+ })) : [];
952
958
  return mergeTurnFacts(lexicalFacts, llmFacts);
953
959
  }
954
960
  function shouldAutoPromote(fact) {
@@ -6137,6 +6143,12 @@ function toTaskRiskLevel(riskLevel) {
6137
6143
  function planTaskRiskLevel(description) {
6138
6144
  return classifyRisk(description).riskLevel;
6139
6145
  }
6146
+ function decompositionEnabled(env) {
6147
+ const source = typeof process !== "undefined" ? process.env : {};
6148
+ const raw = String(source.AUDIT_DECOMPOSITION ?? "").trim().toLowerCase();
6149
+ if (raw === "") return true;
6150
+ return !["0", "false", "off", "no", "disabled"].includes(raw);
6151
+ }
6140
6152
  class TurnInterpreter {
6141
6153
  constructor(llmClient, model, planService, reminderStore) {
6142
6154
  this.llmClient = llmClient;
@@ -6198,8 +6210,9 @@ class TurnInterpreter {
6198
6210
  */
6199
6211
  async resolveTasks(params) {
6200
6212
  const { userMessage, sessionId, classification, planForCancelCheck, onUsage } = params;
6213
+ const decompose = decompositionEnabled();
6201
6214
  let initialTasks = toHarnessTasks([{ id: "respond", description: userMessage, depends_on: [] }], toTaskRiskLevel(classification.riskLevel));
6202
- const decomposed = classification.decomposedTasks;
6215
+ const decomposed = decompose ? classification.decomposedTasks : null;
6203
6216
  if (decomposed) {
6204
6217
  initialTasks = toHarnessTasks(decomposed, toTaskRiskLevel(classification.riskLevel));
6205
6218
  }
@@ -6214,7 +6227,7 @@ class TurnInterpreter {
6214
6227
  } else {
6215
6228
  planClassifiedTrace = { isCandidate: classification.matchedPlanTemplate !== null, matchedTemplate: classification.matchedPlanTemplate };
6216
6229
  }
6217
- if (initialTasks.length === 1 && initialTasks[0].id === "respond" && classification.riskLevel !== "LOW" && looksLikeCodingFact(userMessage)) {
6230
+ if (decompose && initialTasks.length === 1 && initialTasks[0].id === "respond" && classification.riskLevel !== "LOW" && looksLikeCodingFact(userMessage)) {
6218
6231
  const reframed = await reframeTaskDescriptionWithLLM(userMessage, this.llmClient, this.model(), onUsage);
6219
6232
  if (reframed) {
6220
6233
  initialTasks = toHarnessTasks([{ id: "respond", description: reframed, depends_on: [] }], toTaskRiskLevel(classification.riskLevel));
@@ -6285,6 +6298,12 @@ const REVIEW_SCHEMA = {
6285
6298
  },
6286
6299
  required: ["conflict"]
6287
6300
  };
6301
+ function semanticChangeReviewEnabled(env) {
6302
+ const source = typeof process !== "undefined" ? process.env : {};
6303
+ const raw = String(source.AUDIT_SEMANTIC_CHANGE_REVIEW ?? "").trim().toLowerCase();
6304
+ if (raw === "") return true;
6305
+ return !["0", "false", "off", "no", "disabled"].includes(raw);
6306
+ }
6288
6307
  const SYSTEM_PROMPT$2 = `You check whether a proposed action genuinely conflicts with something already known to be true (a high-confidence belief) or predicted (an active hypothesis's predicted observation) — a real logical conflict, not just a superficially related topic (e.g. proposing to remove something a belief says is required, or an action that presumes the opposite of what's predicted). You are given "changeDescription", "highConfidenceBeliefs", and "hypothesisPredictions" as JSON. Respond with JSON only: {"conflict": boolean, "reason": string}. reason only needs to be set when conflict is true.`;
6289
6308
  async function checkSemanticReviewConflict(changeDescription, highConfidenceBeliefs, hypothesisPredictions, llmClient, model, onUsage) {
6290
6309
  if (looksLikeCodingFact(changeDescription)) return { conflict: false };
@@ -6342,6 +6361,12 @@ async function checkSemanticFailureMatch(symptoms, libraryEntries, llmClient, mo
6342
6361
  }
6343
6362
  }
6344
6363
  const NON_CHECKABLE_DEFAULT_CRITERION = "Respond helpfully, accurately, and safely to the user request.";
6364
+ function semanticCriterionCoverageEnabled(env) {
6365
+ const source = typeof process !== "undefined" ? process.env : {};
6366
+ const raw = String(source.AUDIT_SEMANTIC_CRITERION_COVERAGE ?? "").trim().toLowerCase();
6367
+ if (raw === "") return true;
6368
+ return !["0", "false", "off", "no", "disabled"].includes(raw);
6369
+ }
6345
6370
  const COVERAGE_SCHEMA = {
6346
6371
  type: "object",
6347
6372
  properties: {
@@ -6367,6 +6392,18 @@ async function checkSemanticCriterionCoverage(criterion, beliefs, llmClient, mod
6367
6392
  return false;
6368
6393
  }
6369
6394
  }
6395
+ function verificationEnabled(env) {
6396
+ const source = typeof process !== "undefined" ? process.env : {};
6397
+ const raw = String(source.AUDIT_VERIFICATION ?? "").trim().toLowerCase();
6398
+ if (raw === "") return true;
6399
+ return !["0", "false", "off", "no", "disabled"].includes(raw);
6400
+ }
6401
+ function reviewerPassEnabled(env) {
6402
+ const source = typeof process !== "undefined" ? process.env : {};
6403
+ const raw = String(source.AUDIT_REVIEWER_PASS ?? "").trim().toLowerCase();
6404
+ if (raw === "") return true;
6405
+ return !["0", "false", "off", "no", "disabled"].includes(raw);
6406
+ }
6370
6407
  const PLAN_AUTO_ADVANCE_TASK_CEILING = 10;
6371
6408
  class HarnessBridge {
6372
6409
  constructor(memory, experienceStore, checkpointStore, llmClient, model, maxSteps, planService, assistantSession, onTrace, oneLoopMode = DEFAULT_ONE_LOOP_MODE) {
@@ -6448,6 +6485,13 @@ class HarnessBridge {
6448
6485
  onVerification: (result) => {
6449
6486
  lastVerification = result;
6450
6487
  },
6488
+ // AUDIT_VERIFICATION (feature-value audit, Phase C5, eval-only) → skip verify() entirely.
6489
+ // Default ON — unchanged shipped behaviour; skipVerification stays undefined.
6490
+ skipVerification: verificationEnabled() ? void 0 : true,
6491
+ // AUDIT_REVIEWER_PASS (feature-value audit, Phase C6, eval-only) → skip reviewerPass()
6492
+ // (and any reviewer_pass_2 re-run) entirely, including its C1/C2 sub-mechanisms. Default
6493
+ // ON — unchanged shipped behaviour; skipReviewerPass stays undefined.
6494
+ skipReviewerPass: reviewerPassEnabled() ? void 0 : true,
6451
6495
  // Trajectory Supervisor GATHER_EVIDENCE host (S5). Inert unless a supervisorDecider is
6452
6496
  // also wired and returns a GATHER_EVIDENCE directive at a stall edge; absent → the
6453
6497
  // harness degrades GATHER_EVIDENCE to CONTINUE.
@@ -6494,7 +6538,11 @@ class HarnessBridge {
6494
6538
  // Layered on top of review-proposed-change.ts's lexical isNegation check — same "skip
6495
6539
  // when it reads like a coding fact" gate contradictionChecker uses, since that's the
6496
6540
  // domain the fixed-phrase check already covers reasonably well.
6497
- semanticChangeReviewer: (input) => checkSemanticReviewConflict(input.changeDescription, input.highConfidenceBeliefs, input.hypothesisPredictions, this.llmClient, this.model(), onUsage),
6541
+ // AUDIT_SEMANTIC_CHANGE_REVIEW (feature-value audit, Phase C2) gates the whole hook: OFF →
6542
+ // no host semanticChangeReviewer is wired at all, so the harness's mechanical
6543
+ // reviewProposedChange (lexical isNegation) is the only conflict check. Default ON —
6544
+ // unchanged shipped behaviour.
6545
+ semanticChangeReviewer: semanticChangeReviewEnabled() ? (input) => checkSemanticReviewConflict(input.changeDescription, input.highConfidenceBeliefs, input.hypothesisPredictions, this.llmClient, this.model(), onUsage) : void 0,
6498
6546
  // Layered on top of FailureModeLibrary's own exact-string-overlap match() — see
6499
6547
  // failure-mode-matcher.ts's doc comment for why exact equality against a curated symptom
6500
6548
  // list almost never happens for free-text observations in practice.
@@ -6505,7 +6553,10 @@ class HarnessBridge {
6505
6553
  // Layered on top of reviewerPass's implementerLens's own `.includes()` substring check —
6506
6554
  // called only for a success criterion that substring check found no coverage for. See
6507
6555
  // semantic-criterion-coverage.ts's doc comment.
6508
- semanticCriterionCoverage: (criterion, beliefs) => checkSemanticCriterionCoverage(criterion, beliefs, this.llmClient, this.model(), onUsage),
6556
+ // AUDIT_SEMANTIC_CRITERION_COVERAGE (feature-value audit, Phase C1) gates the whole hook:
6557
+ // OFF → no host semanticCriterionCoverage is wired at all, so the reviewer's implementer
6558
+ // lens runs its `.includes()` substring check alone. Default ON — unchanged shipped behaviour.
6559
+ semanticCriterionCoverage: semanticCriterionCoverageEnabled() ? (criterion, beliefs) => checkSemanticCriterionCoverage(criterion, beliefs, this.llmClient, this.model(), onUsage) : void 0,
6509
6560
  // Stop right after a MEDIUM/HIGH-risk plan step resolves (COMPLETE or FAILED), before
6510
6561
  // the loop would go pick the next one — undefined for a non-plan turn, so shouldPause is
6511
6562
  // simply never checked and behavior is unchanged.
@@ -8289,4 +8340,4 @@ export {
8289
8340
  buildWhyChain as y,
8290
8341
  classifyError as z
8291
8342
  };
8292
- //# sourceMappingURL=cli-session-BiX2DOni.js.map
8343
+ //# sourceMappingURL=cli-session-DnSc6Hhx.js.map