baro-ai 0.117.2 → 0.117.4

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/dist/cli.mjs CHANGED
@@ -20810,7 +20810,7 @@ var require_websocket = __commonJS({
20810
20810
  var http3 = __require("http");
20811
20811
  var net = __require("net");
20812
20812
  var tls = __require("tls");
20813
- var { randomBytes: randomBytes5, createHash: createHash20 } = __require("crypto");
20813
+ var { randomBytes: randomBytes5, createHash: createHash21 } = __require("crypto");
20814
20814
  var { Duplex, Readable: Readable2 } = __require("stream");
20815
20815
  var { URL: URL2 } = __require("url");
20816
20816
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -21478,7 +21478,7 @@ var require_websocket = __commonJS({
21478
21478
  abortHandshake(websocket, socket, "Invalid Upgrade header");
21479
21479
  return;
21480
21480
  }
21481
- const digest = createHash20("sha1").update(key + GUID).digest("base64");
21481
+ const digest = createHash21("sha1").update(key + GUID).digest("base64");
21482
21482
  if (res.headers["sec-websocket-accept"] !== digest) {
21483
21483
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
21484
21484
  return;
@@ -21847,7 +21847,7 @@ var require_websocket_server = __commonJS({
21847
21847
  var EventEmitter = __require("events");
21848
21848
  var http3 = __require("http");
21849
21849
  var { Duplex } = __require("stream");
21850
- var { createHash: createHash20 } = __require("crypto");
21850
+ var { createHash: createHash21 } = __require("crypto");
21851
21851
  var extension2 = require_extension();
21852
21852
  var PerMessageDeflate2 = require_permessage_deflate();
21853
21853
  var subprotocol2 = require_subprotocol();
@@ -22154,7 +22154,7 @@ var require_websocket_server = __commonJS({
22154
22154
  );
22155
22155
  }
22156
22156
  if (this._state > RUNNING) return abortHandshake(socket, 503);
22157
- const digest = createHash20("sha1").update(key + GUID).digest("base64");
22157
+ const digest = createHash21("sha1").update(key + GUID).digest("base64");
22158
22158
  const headers = [
22159
22159
  "HTTP/1.1 101 Switching Protocols",
22160
22160
  "Upgrade: websocket",
@@ -55271,7 +55271,7 @@ function asRecord(value) {
55271
55271
  }
55272
55272
 
55273
55273
  // ../baro-orchestrator/src/execution/collective-board.ts
55274
- import { randomUUID as randomUUID5 } from "crypto";
55274
+ import { createHash as createHash14, randomUUID as randomUUID5 } from "crypto";
55275
55275
 
55276
55276
  // ../baro-orchestrator/src/planning/domain/runtime-amendments.ts
55277
55277
  import { createHash as createHash10 } from "crypto";
@@ -60108,7 +60108,12 @@ var CollectiveBoard = class extends SerializedObserver {
60108
60108
  baseGraphVersion: this.runtimeReplans.graphVersion,
60109
60109
  reason: `autonomous remediation for ${invariantIds.join(", ")}: ` + remediation.reason,
60110
60110
  mutation: {
60111
- addedStories: [remediation.story],
60111
+ addedStories: [
60112
+ this.withRemediationPrerequisites(
60113
+ remediation.story,
60114
+ invariantIds
60115
+ )
60116
+ ],
60112
60117
  removedStoryIds: [],
60113
60118
  modifiedDeps: {}
60114
60119
  }
@@ -60162,6 +60167,23 @@ var CollectiveBoard = class extends SerializedObserver {
60162
60167
  else this.scheduleNextWave();
60163
60168
  }
60164
60169
  }
60170
+ /**
60171
+ * A remediation waits for every queued, not-yet-integrated story already
60172
+ * working the same invariants — e.g. the chain a surgeon split out of the
60173
+ * previous remediation. Running beside that chain, it re-attempts work
60174
+ * whose prerequisite has not landed and the review rejects it every turn
60175
+ * (#199). Leased stories are left out: the story that raised the challenge
60176
+ * is one, and a remediation must not wait on its own source.
60177
+ */
60178
+ withRemediationPrerequisites(story, invariantIds) {
60179
+ const targets = new Set(invariantIds);
60180
+ const prerequisites = (this.prd?.userStories ?? []).filter((candidate) => candidate.id !== story.id && !candidate.passes && !this.completed.includes(candidate.id) && !this.failed.has(candidate.id) && !this.leases.has(candidate.id) && (candidate.goalInvariantIds ?? []).some((id) => targets.has(id))).map(({ id }) => id);
60181
+ if (prerequisites.length === 0) return story;
60182
+ return {
60183
+ ...story,
60184
+ dependsOn: [.../* @__PURE__ */ new Set([...story.dependsOn, ...prerequisites])].sort()
60185
+ };
60186
+ }
60165
60187
  emitGoalRemediationAdmitted(remediation, graphVersion, disposition) {
60166
60188
  this.emit(
60167
60189
  GoalInvariantRemediationAdmitted.create({
@@ -60235,8 +60257,13 @@ var CollectiveBoard = class extends SerializedObserver {
60235
60257
  });
60236
60258
  }
60237
60259
  executeRuntimeReplan(queued, additionalImmutableStoryIds = [], retractedStoryIds = []) {
60238
- const { proposal, requireActiveLease } = queued;
60239
- const lease = this.leases.get(proposal.sourceStoryId);
60260
+ const { requireActiveLease } = queued;
60261
+ const lease = this.leases.get(queued.proposal.sourceStoryId);
60262
+ const { proposal, selfBlock } = splitSelfDependency(
60263
+ queued.proposal,
60264
+ requireActiveLease ? lease : void 0,
60265
+ this.prd
60266
+ );
60240
60267
  const immutableStoryIds = this.runtimeImmutableStoryIds();
60241
60268
  for (const storyId of additionalImmutableStoryIds) {
60242
60269
  immutableStoryIds.add(storyId);
@@ -60265,6 +60292,7 @@ var CollectiveBoard = class extends SerializedObserver {
60265
60292
  })
60266
60293
  );
60267
60294
  this.reconcileRuntimeGraphApplication(outcome.applied);
60295
+ if (selfBlock) this.onWorkBlocked(selfBlock);
60268
60296
  return outcome;
60269
60297
  }
60270
60298
  this.emitGraphDecision(outcome.event);
@@ -61243,7 +61271,8 @@ function addUnique(values, value) {
61243
61271
  if (!values.includes(value)) values.push(value);
61244
61272
  }
61245
61273
  function sameRemediationStory(current, expected) {
61246
- return current.id === expected.id && current.priority === expected.priority && current.title === expected.title && current.description === expected.description && sameStrings(current.dependsOn, expected.dependsOn) && current.retries === (expected.retries ?? 2) && sameStrings(current.acceptance, expected.acceptance ?? []) && sameStrings(current.tests, expected.tests ?? []) && sameStrings(
61274
+ return current.id === expected.id && current.priority === expected.priority && current.title === expected.title && current.description === expected.description && // Admission may add same-invariant prerequisites to the proposal.
61275
+ expected.dependsOn.every((id) => current.dependsOn.includes(id)) && sameStrings(current.acceptance, expected.acceptance ?? []) && sameStrings(current.tests, expected.tests ?? []) && sameStrings(
61247
61276
  current.goalInvariantIds ?? [],
61248
61277
  expected.goalInvariantIds ?? []
61249
61278
  ) && current.model === expected.model;
@@ -61268,6 +61297,34 @@ function nonNegativeSafeInteger(value) {
61268
61297
  function nonNegativeFinite(value) {
61269
61298
  return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
61270
61299
  }
61300
+ function splitSelfDependency(proposal, lease, prd) {
61301
+ const source = proposal.sourceStoryId;
61302
+ const own = proposal.mutation.modifiedDeps[source];
61303
+ if (!own || !lease || lease.leaseId !== proposal.leaseId || lease.generation !== proposal.generation) return { proposal };
61304
+ const otherDeps = Object.fromEntries(
61305
+ Object.entries(proposal.mutation.modifiedDeps).filter(([storyId]) => storyId !== source)
61306
+ );
61307
+ const stripped = {
61308
+ ...proposal,
61309
+ mutation: { ...proposal.mutation, modifiedDeps: otherDeps }
61310
+ };
61311
+ if (stripped.mutation.addedStories.length === 0 && stripped.mutation.removedStoryIds.length === 0 && Object.keys(otherDeps).length === 0) return { proposal };
61312
+ const current = prd?.userStories.find(({ id }) => id === source)?.dependsOn ?? [];
61313
+ const required2 = [...new Set(own.filter((id) => !current.includes(id)))];
61314
+ if (required2.length === 0) return { proposal: stripped };
61315
+ return {
61316
+ proposal: stripped,
61317
+ selfBlock: {
61318
+ runId: proposal.runId,
61319
+ blockId: `self-${createHash14("sha256").update(proposal.proposalId).digest("hex").slice(0, 24)}`,
61320
+ storyId: source,
61321
+ leaseId: proposal.leaseId,
61322
+ generation: proposal.generation,
61323
+ requiredStoryIds: required2,
61324
+ reason: proposal.reason
61325
+ }
61326
+ };
61327
+ }
61271
61328
  function validDependencyBlock(request) {
61272
61329
  return request.blockId.trim().length > 0 && request.blockId.length <= 200 && request.reason.trim().length > 0 && request.reason.length <= 8e3 && request.requiredStoryIds.length > 0 && request.requiredStoryIds.length <= 32 && request.requiredStoryIds.every(
61273
61330
  (storyId) => storyId.trim().length > 0 && storyId.trim() === storyId && storyId.length <= 128
@@ -61326,7 +61383,7 @@ function sharedAbortCode(codes) {
61326
61383
  }
61327
61384
 
61328
61385
  // ../baro-orchestrator/src/goal/goal-guardian.ts
61329
- import { createHash as createHash14 } from "crypto";
61386
+ import { createHash as createHash15 } from "crypto";
61330
61387
  var MAX_AGGREGATE_REMEDIATIONS_PER_INVARIANT = 3;
61331
61388
  var GoalGuardian = class extends BaseObserver {
61332
61389
  constructor(opts) {
@@ -61581,7 +61638,7 @@ var GoalGuardian = class extends BaseObserver {
61581
61638
  ({ invariantId }) => !this.contract.invariants.some(({ id }) => id === invariantId)
61582
61639
  )) return false;
61583
61640
  const canonical = [...targets].sort((left, right) => left.invariantId.localeCompare(right.invariantId) || left.challengeId.localeCompare(right.challengeId));
61584
- const digest = createHash14("sha256").update(this.contract.contractId).update("\0").update(canonical.length === 1 ? canonical[0].challengeId : canonical.map(({ challengeId, invariantId }) => `${invariantId}\0${challengeId}`).join("\0")).update(retryOf ? `\0retry-of\0${retryOf}` : "").digest("hex");
61641
+ const digest = createHash15("sha256").update(this.contract.contractId).update("\0").update(canonical.length === 1 ? canonical[0].challengeId : canonical.map(({ challengeId, invariantId }) => `${invariantId}\0${challengeId}`).join("\0")).update(retryOf ? `\0retry-of\0${retryOf}` : "").digest("hex");
61585
61642
  return this.ledger.bindChallengeRemediationGroup(
61586
61643
  canonical.map(({ challengeId }) => challengeId),
61587
61644
  {
@@ -61648,7 +61705,7 @@ var GoalGuardian = class extends BaseObserver {
61648
61705
  if (this.ledger.hasOpenChallenge(invariantId)) return false;
61649
61706
  if (kind === "aggregate" && this.ledger.aggregateRemediationCount(invariantId) >= MAX_AGGREGATE_REMEDIATIONS_PER_INVARIANT) return false;
61650
61707
  const ordinal = this.ledger.challengeCount(invariantId) + 1;
61651
- const digest = createHash14("sha256").update(this.contract.contractId).update(`\0${kind}\0`).update(invariantId).update("\0").update(String(ordinal)).digest("hex");
61708
+ const digest = createHash15("sha256").update(this.contract.contractId).update(`\0${kind}\0`).update(invariantId).update("\0").update(String(ordinal)).digest("hex");
61652
61709
  const challengeId = `${kind}-${invariantId.toLowerCase()}-${digest.slice(0, 12)}`;
61653
61710
  this.ledger.raiseChallenge({
61654
61711
  challengeId,
@@ -61679,7 +61736,7 @@ var GoalGuardian = class extends BaseObserver {
61679
61736
  )) return false;
61680
61737
  const targets = uniqueReviews.map(({ invariantId, reason }) => {
61681
61738
  const ordinal = this.ledger.challengeCount(invariantId) + 1;
61682
- const digest = createHash14("sha256").update(this.contract.contractId).update("\0aggregate-group\0").update(remediationGroupId).update("\0").update(invariantId).update("\0").update(String(ordinal)).digest("hex");
61739
+ const digest = createHash15("sha256").update(this.contract.contractId).update("\0aggregate-group\0").update(remediationGroupId).update("\0").update(invariantId).update("\0").update(String(ordinal)).digest("hex");
61683
61740
  return {
61684
61741
  challengeId: `aggregate-${invariantId.toLowerCase()}-${digest.slice(0, 12)}`,
61685
61742
  invariantId,
@@ -62016,6 +62073,7 @@ function boundedChallengeReason(reason) {
62016
62073
  const cut = sentenceEnd > MAX_CRITERION_REASON_CHARS / 2 ? window2.slice(0, sentenceEnd + 1) : window2.slice(0, Math.max(window2.lastIndexOf(" "), 1));
62017
62074
  return `${cut} \u2026 [truncated; the full reasoning is in the story description]`;
62018
62075
  }
62076
+ var REMEDIATION_STORY_RETRIES = 0;
62019
62077
  function legacyRemediationStory(storyId, { challenge, invariant }) {
62020
62078
  return {
62021
62079
  id: storyId,
@@ -62025,7 +62083,7 @@ function legacyRemediationStory(storyId, { challenge, invariant }) {
62025
62083
  Observed risk: ${challenge.reason}
62026
62084
  Implement the smallest correct fix and focused regression evidence; preserve every other GoalContract invariant.`,
62027
62085
  dependsOn: [],
62028
- retries: 2,
62086
+ retries: REMEDIATION_STORY_RETRIES,
62029
62087
  acceptance: [
62030
62088
  `[${invariant.id}] ${invariant.text}`,
62031
62089
  `Challenge ${challenge.challengeId} is addressed: ${boundedChallengeReason(challenge.reason)}`,
@@ -62047,7 +62105,7 @@ function groupedRemediationStory(storyId, targets) {
62047
62105
  ` + targets.map(({ challenge, invariant }) => `[${invariant.id}] ${invariant.text}
62048
62106
  Observed risk: ${challenge.reason}`).join("\n") + "\nImplement the smallest correct fix and focused regression evidence; preserve every other GoalContract invariant.",
62049
62107
  dependsOn: [],
62050
- retries: 2,
62108
+ retries: REMEDIATION_STORY_RETRIES,
62051
62109
  acceptance: [
62052
62110
  ...targets.map(({ invariant }) => `[${invariant.id}] ${invariant.text}`),
62053
62111
  ...targets.map(({ challenge }) => `Challenge ${challenge.challengeId} is addressed: ${boundedChallengeReason(challenge.reason)}`),
@@ -63252,7 +63310,7 @@ function extractVerdictJson(text2) {
63252
63310
  }
63253
63311
 
63254
63312
  // ../baro-orchestrator/src/acceptance/critic-evidence.ts
63255
- import { createHash as createHash15 } from "crypto";
63313
+ import { createHash as createHash16 } from "crypto";
63256
63314
  import { constants } from "fs";
63257
63315
  import { lstat as lstat2, open, readlink, realpath } from "fs/promises";
63258
63316
  import { isAbsolute as isAbsolute6, relative as relative7, resolve as resolve10, sep as sep4 } from "path";
@@ -63792,7 +63850,7 @@ async function changedContentFingerprint(target, timeoutMs) {
63792
63850
  `changed-content fingerprint exceeds ${MAX_FINGERPRINT_PATHS} paths`
63793
63851
  );
63794
63852
  }
63795
- const hash = createHash15("sha256");
63853
+ const hash = createHash16("sha256");
63796
63854
  hashField(hash, "schema", "baro-critic-changed-content-v1");
63797
63855
  hashField(hash, "base", base);
63798
63856
  let totalBytes = 0;
@@ -63932,7 +63990,13 @@ async function assertNoSymlinkParents(cwd, absolute) {
63932
63990
  let current = resolve10(cwd);
63933
63991
  for (const part of parts.slice(0, -1)) {
63934
63992
  current = resolve10(current, part);
63935
- const stat2 = await lstat2(current);
63993
+ let stat2;
63994
+ try {
63995
+ stat2 = await lstat2(current);
63996
+ } catch (error) {
63997
+ if (errorCode(error) === "ENOENT") return;
63998
+ throw error;
63999
+ }
63936
64000
  if (stat2.isSymbolicLink() || !stat2.isDirectory()) {
63937
64001
  throw new Error(
63938
64002
  "fingerprint path has a symlink or non-directory parent"
@@ -65406,7 +65470,7 @@ var CriticTargetRegistry = class extends BaseObserver {
65406
65470
  var import_cross_spawn3 = __toESM(require_cross_spawn(), 1);
65407
65471
 
65408
65472
  // ../baro-orchestrator/src/harness/codex/failure-diagnostics.ts
65409
- import { createHash as createHash16 } from "crypto";
65473
+ import { createHash as createHash17 } from "crypto";
65410
65474
  import { stripVTControlCharacters } from "util";
65411
65475
  var MAX_MESSAGE_BYTES = 2 * 1024;
65412
65476
  var MAX_IDENTIFIER_BYTES = 128;
@@ -65565,7 +65629,7 @@ function mcpDiagnostic(lifecycle, item, redactionEnvironment) {
65565
65629
  const server = firstString(item, ["server", "server_name"]);
65566
65630
  const tool = firstString(item, ["tool", "tool_name", "name"]);
65567
65631
  const status = normalizedStatus(item.status);
65568
- const keyHash = createHash16("sha256");
65632
+ const keyHash = createHash17("sha256");
65569
65633
  if (id) keyHash.update("id\0").update(id);
65570
65634
  else {
65571
65635
  keyHash.update("anonymous\0").update(server ?? "?").update("\0").update(tool ?? "?");
@@ -71520,10 +71584,10 @@ var GitCoordinator = class extends SerializedObserver {
71520
71584
  };
71521
71585
 
71522
71586
  // ../baro-orchestrator/src/goal/goal-invariant-reviewer.ts
71523
- import { createHash as createHash18 } from "crypto";
71587
+ import { createHash as createHash19 } from "crypto";
71524
71588
 
71525
71589
  // ../baro-orchestrator/src/goal/goal-invariant-review-evidence.ts
71526
- import { createHash as createHash17 } from "crypto";
71590
+ import { createHash as createHash18 } from "crypto";
71527
71591
  import { constants as constants2 } from "fs";
71528
71592
  import { lstat as lstat3, open as open2, readlink as readlink2, realpath as realpath2 } from "fs/promises";
71529
71593
  import { isAbsolute as isAbsolute7, relative as relative8, resolve as resolve11, sep as sep5 } from "path";
@@ -71701,7 +71765,7 @@ async function collectStableRepositoryEvidence(cwd, baseSha, deadline) {
71701
71765
  }
71702
71766
  return {
71703
71767
  evidence: after,
71704
- fingerprint: createHash17("sha256").update("baro-goal-review-repository-v1\0").update(after, "utf8").digest("hex")
71768
+ fingerprint: createHash18("sha256").update("baro-goal-review-repository-v1\0").update(after, "utf8").digest("hex")
71705
71769
  };
71706
71770
  }
71707
71771
  async function collectLosslessRepositoryEvidence(cwdValue, baseShaValue, deadline) {
@@ -73183,7 +73247,7 @@ function parseRemediationGroups(value, verdict, violatedCriteria, groupNamespace
73183
73247
  }
73184
73248
  function deterministicRemediationGroupId(invariantIds, namespace = "legacy") {
73185
73249
  const canonical = [...invariantIds].sort();
73186
- const digest = createHash18("sha256").update("baro-goal-remediation-group-v1\0").update(namespace).update("\0").update(canonical.join("\0")).digest("hex");
73250
+ const digest = createHash19("sha256").update("baro-goal-remediation-group-v1\0").update(namespace).update("\0").update(canonical.join("\0")).digest("hex");
73187
73251
  return `goal-remediation-group-${digest.slice(0, 24)}`;
73188
73252
  }
73189
73253
  function aggregateStatus(invariants) {
@@ -76301,7 +76365,7 @@ function jsonQuotedShellArgument(value) {
76301
76365
  }
76302
76366
 
76303
76367
  // ../baro-orchestrator/src/telemetry/model-telemetry-collector.ts
76304
- import { createHash as createHash19 } from "crypto";
76368
+ import { createHash as createHash20 } from "crypto";
76305
76369
  var ModelTelemetryCollector = class extends SerializedObserver {
76306
76370
  constructor(opts) {
76307
76371
  super();
@@ -76692,7 +76756,7 @@ function routeKey(storyId, correlation) {
76692
76756
  ]) : storyId;
76693
76757
  }
76694
76758
  function terminalFingerprint2(event, correlation) {
76695
- return createHash19("sha256").update(event.type).update("\0").update(JSON.stringify(event.data)).update("\0").update(correlation ? routeKey(correlation.storyId, correlation) : "legacy").digest("hex");
76759
+ return createHash20("sha256").update(event.type).update("\0").update(JSON.stringify(event.data)).update("\0").update(correlation ? routeKey(correlation.storyId, correlation) : "legacy").digest("hex");
76696
76760
  }
76697
76761
 
76698
76762
  // ../baro-orchestrator/src/execution/operator.ts
@@ -83962,6 +84026,7 @@ function createRuntimeReplanTool(graphVersion) {
83962
84026
  },
83963
84027
  modifiedDeps: {
83964
84028
  type: "object",
84029
+ description: "Record<storyId, full dependsOn>. Started stories are immutable, except your own: when stories you add here are prerequisites of THIS story, set your own id to your dependsOn plus their ids \u2014 the Board adds them, then suspends this story and resumes it after they integrate. Stop working once that is applied.",
83965
84030
  additionalProperties: {
83966
84031
  type: "array",
83967
84032
  items: { type: "string" }
@@ -87713,7 +87778,7 @@ var StoryFactory = class extends BaseObserver {
87713
87778
  ...includeCliDagMutationCommands ? [
87714
87779
  ...graphVersion !== void 0 ? [
87715
87780
  `- The launch DAG version is ${graphVersion}. To atomically add, replace, or rewire future work and receive the Board's decision immediately: ${command} emit ${capability} --kind replan --base-version ${graphVersion} --replan-json ${JSON.stringify('{"addedStories":[],"removedStoryIds":[],"modifiedDeps":{}}')} --reason ${JSON.stringify("WHY THE PLAN MUST CHANGE")}`,
87716
- " Use the newest `graphVersion` returned by a prior decision. Active/already-started stories are immutable; express additional work as future stories.",
87781
+ " Use the newest `graphVersion` returned by a prior decision. Active/already-started stories are immutable; express additional work as future stories. The one exception is your own story: when stories you add are its prerequisites, also set `modifiedDeps` for your own id to your dependsOn plus their ids \u2014 the Board then suspends this story until they integrate, so stop work once the replan is applied.",
87717
87782
  ` If replan exits 3 or returns \`outcome_unknown\`, do not assume whether it applied. Resolve that same proposal before continuing: ${command} decision ${capability} --proposal ${JSON.stringify("PROPOSAL_ID")} --wait-ms 30000`
87718
87783
  ] : []
87719
87784
  ] : [],