@kitman-sh/software-engineering 0.10.79 → 0.10.81

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/bundle.js CHANGED
@@ -12418,6 +12418,43 @@ var ContextPackRetrievedContext = Struct({
12418
12418
  })
12419
12419
  });
12420
12420
 
12421
+ // ../../packages/core/src/secret.ts
12422
+ var SecretName = String5.check(isPattern2(new RegExp("^[A-Za-z_][A-Za-z0-9_]*$", "u")), isMinLength(1), isMaxLength(128));
12423
+ var SecretScope = Union2([Literal2("workspace"), Literal2("team")]);
12424
+ var SecretHost = String5.check(isPattern2(new RegExp("^(\\*\\.)?[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*(?::[0-9]{1,5})?$", "u")), isMaxLength(260));
12425
+ var SecretHosts = ArraySchema(SecretHost).check(isMaxLength(32));
12426
+ var referencePattern = /secret:\/\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+/;
12427
+ var placeholderMarker = "kitmanref";
12428
+ var tokenCharacter = "[A-Za-z0-9._~+/-]";
12429
+ var placeholderPattern = new RegExp(`(?<!${tokenCharacter})(?:proxy-ep=[A-Za-z0-9.-]+;)?${tokenCharacter}*${placeholderMarker}((?:[0-9a-f]{2})+)`);
12430
+ var anyReference = new RegExp(`${referencePattern.source}|${placeholderPattern.source}`, "g");
12431
+ var unhex = (text) => new TextDecoder().decode(Uint8Array.from(text.match(/../g) ?? [], (pair) => Number.parseInt(pair, 16)));
12432
+ var isReference2 = (text) => new RegExp(`^${referencePattern.source}$`).test(text);
12433
+ var tokenPrefix = /^(?:sk-ant-[a-z]+[0-9]*-|sk-proj-|sk-or-v[0-9]+-|sk-|ya29\.|gh[opsu]_|github_pat_|xai-|gsk_|AIza)/;
12434
+ var wholePlaceholder = new RegExp(`^(?:[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.|proxy-ep=[A-Za-z0-9.-]+;|${tokenPrefix.source.slice(1)})?${placeholderMarker}((?:[0-9a-f]{2})+)$`);
12435
+ var isSecretReference = (text) => {
12436
+ if (isReference2(text))
12437
+ return true;
12438
+ const encoded = wholePlaceholder.exec(text)?.[1];
12439
+ return encoded !== undefined && isReference2(unhex(encoded));
12440
+ };
12441
+ var SecretSummary = Struct({
12442
+ name: SecretName,
12443
+ scope: SecretScope,
12444
+ teamId: optionalKey2(Id),
12445
+ hosts: SecretHosts,
12446
+ setByActorType: ActorType,
12447
+ setByActorId: String5,
12448
+ setAt: Timestamp
12449
+ });
12450
+ var SecretList = Struct({ items: ArraySchema(SecretSummary) });
12451
+ var SecretSet = Struct({
12452
+ value: String5.check(isMinLength(1), isMaxLength(65536)),
12453
+ teamId: optionalKey2(String5.check(isMinLength(1))),
12454
+ hosts: optionalKey2(SecretHosts)
12455
+ });
12456
+ var SecretScopeQuery = Struct({ teamId: optionalKey2(Id) });
12457
+
12421
12458
  // ../../packages/core/src/redaction.ts
12422
12459
  var EvidenceRefContractVersion = "evidence-ref.v1";
12423
12460
  var RedactionClassificationSchema = Union2([
@@ -12438,7 +12475,8 @@ var RedactionFindingSchema = Struct({
12438
12475
  classification: RedactionClassificationSchema,
12439
12476
  rule: String5.check(isMinLength(1), isMaxLength(120)),
12440
12477
  preview: String5.check(isMaxLength(160)),
12441
- sha256: String5.check(isPattern2(new RegExp("^[a-f0-9]{64}$", "u")))
12478
+ sha256: String5.check(isPattern2(new RegExp("^[a-f0-9]{64}$", "u"))),
12479
+ span: optionalKey2(Struct({ start: Int.check(isGreaterThanOrEqualTo2(0)), end: Int }))
12442
12480
  });
12443
12481
  var EvidenceRef = Struct({
12444
12482
  contractVersion: Literal2(EvidenceRefContractVersion),
@@ -12513,37 +12551,83 @@ var LOCAL_PATH_KEYS = new Set([
12513
12551
  "docker_socket",
12514
12552
  "ssh_agent_socket"
12515
12553
  ]);
12554
+ var wrappedValue = String.raw`<[A-Za-z][A-Za-z0-9 _.-]*>|\$\{[^{}\s]*\}|\{\{[^{}]*\}\}|proxy-ep=[A-Za-z0-9.-]+;kitmanref(?:[0-9a-f]{2})+(?![A-Za-z0-9._~+/-])`;
12555
+ var secretReferenceTail = String.raw`(?<=secret:)\/\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?![^\s,;}"')\]\x60])`;
12556
+ var bearerValue = /[0-9]|[._~+/:-][A-Za-z0-9]|[<{]/u;
12516
12557
  var VALUE_RULES = [
12517
- ["secret", /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/u, "private-key"],
12518
- ["credential", /\bBearer\s+(?=[A-Za-z]*(?:[0-9]|[._~+/-][A-Za-z0-9]))[A-Za-z0-9._~+/-]+=*/iu, "bearer-token"],
12519
- [
12520
- "credential",
12521
- /(?:^|[^A-Za-z0-9])(?:ghp_|github_pat_|glpat-|ksa1\.|sk-[A-Za-z0-9_-]{8,}|xox[baprs]-)[A-Za-z0-9._-]+/u,
12522
- "provider-token"
12523
- ],
12524
- [
12525
- "credential",
12526
- /(?:api[_ -]?key|secret|token|password)\s*[:=]\s*(?!env\b|file\b|exec\b)[^\s,;}]+/iu,
12527
- "credential-assignment"
12528
- ],
12529
- ["pii", /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/iu, "email"],
12530
- ["pii", /\b\d{3}-\d{2}-\d{4}\b/u, "ssn"],
12531
- ["pii", /(?:\+\d[\d ()-]{8,}\d|\(\d{3}\)[\d -]{7,}\d|\b\d{3}[ -]\d{3}[ -]\d{4}\b)/u, "phone"],
12532
- ["pii", /\b(?:\d[ -]*?){13,19}\b/u, "payment-number"],
12533
- ["url", /\b(?:https?|ftp):\/\/[^\s]+/iu, "url-content"],
12534
- ["diff", /(^|\n)diff --git\s/u, "diff-content"],
12535
- ["source", /(^|\n)\s*(?:import|export|const|let|var|function|class)\s+[A-Za-z_$]/u, "source-content"],
12536
- ["log", /(?:^|\n)\s*\d{4}-\d{2}-\d{2}T\S+\s+(?:ERROR|WARN|INFO|DEBUG)\b/u, "structured-log"],
12537
- ["transcript", /(?:^|\n)\s*(?:user|assistant|system)\s*:/iu, "transcript-content"]
12558
+ { classification: "secret", name: "private-key", pattern: /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/u },
12559
+ {
12560
+ classification: "credential",
12561
+ name: "bearer-token",
12562
+ pattern: new RegExp(`\\bBearer\\s+(?<value>(?:${wrappedValue}|[A-Za-z0-9._~+/*:=-])+(?<![.,:]))`, "iu"),
12563
+ holds: (value) => !isPlaceholder(value) && bearerValue.test(value)
12564
+ },
12565
+ {
12566
+ classification: "credential",
12567
+ name: "provider-token",
12568
+ pattern: /(?:^|[^A-Za-z0-9])(?<value><?(?:ghp_|github_pat_|glpat-|ksa1\.|sk-[A-Za-z0-9_-]{8,}|xox[baprs]-)[A-Za-z0-9._*-]*[A-Za-z0-9_*-]>?)/u,
12569
+ holds: (value) => !isPlaceholder(value)
12570
+ },
12571
+ {
12572
+ classification: "credential",
12573
+ name: "credential-assignment",
12574
+ pattern: new RegExp(`(?:api[_ -]?key|secret|token|password)\\s*[:=]\\s*(?!env\\b|file\\b|exec\\b|${secretReferenceTail})(?<value>(?:${wrappedValue}|[^\\s,;{}])+)`, "iu"),
12575
+ holds: looksLikeCredential
12576
+ },
12577
+ { classification: "pii", name: "email", pattern: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/iu },
12578
+ { classification: "pii", name: "ssn", pattern: /\b\d{3}-\d{2}-\d{4}\b/u },
12579
+ {
12580
+ classification: "pii",
12581
+ name: "phone",
12582
+ pattern: /(?:\+\d[\d ()-]{8,}\d|\(\d{3}\)[\d -]{7,}\d|\b\d{3}[ -]\d{3}[ -]\d{4}\b)/u
12583
+ },
12584
+ { classification: "pii", name: "payment-number", pattern: /\b(?:\d[ -]*?){13,19}\b/u },
12585
+ { classification: "url", name: "url-content", pattern: /\b(?:https?|ftp):\/\/[^\s]+/iu },
12586
+ { classification: "diff", name: "diff-content", pattern: /(^|\n)diff --git\s/u },
12587
+ {
12588
+ classification: "source",
12589
+ name: "source-content",
12590
+ pattern: /(^|\n)\s*(?:import|export|const|let|var|function|class)\s+[A-Za-z_$]/u
12591
+ },
12592
+ {
12593
+ classification: "log",
12594
+ name: "structured-log",
12595
+ pattern: /(?:^|\n)\s*\d{4}-\d{2}-\d{2}T\S+\s+(?:ERROR|WARN|INFO|DEBUG)\b/u
12596
+ },
12597
+ { classification: "transcript", name: "transcript-content", pattern: /(?:^|\n)\s*(?:user|assistant|system)\s*:/iu }
12538
12598
  ];
12539
- var credentialUrl = /\b(?:https?|ftp):\/\/(?:[^\s/?#]*@|[^\s?#]*\?)[^\s]*/iu;
12599
+ var maskedToken = /^(?:ghp_|github_pat_|glpat-|ksa1\.|xox[baprs]-|sk-(?:ant-(?:[a-z]+[0-9]*-)?|proj-|or-v[0-9]+-)?)(?:x{4,}|X{4,}|\*{4,})$/u;
12600
+ var placeholderWord = "(?:[A-Z]?[a-z]+|[A-Z]+)";
12601
+ var placeholders = [
12602
+ maskedToken,
12603
+ new RegExp(`^<${placeholderWord}[0-9]{0,2}(?:[ _.-]${placeholderWord}[0-9]{0,2})*>$`, "u"),
12604
+ /^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/u,
12605
+ /^\$[A-Za-z_][A-Za-z0-9_]*$/u,
12606
+ /^\{\{\s*[A-Za-z_][A-Za-z0-9_.]*\s*\}\}$/u,
12607
+ /^%[A-Za-z_][A-Za-z0-9_]*%$/u,
12608
+ /^\[REDACTED(?::[a-z_]+)?\]$/u,
12609
+ /^[A-Z][A-Z0-9]*(?:_[A-Z][A-Z0-9]*)+$/u,
12610
+ /^([xX*\u2022#.-])\1{2,}$/u,
12611
+ /^runner-secret:[A-Z0-9_]+:(?:env|file|exec)$/u
12612
+ ];
12613
+ var isPlaceholder = (value) => placeholders.some((pattern) => pattern.test(value)) || isSecretReference(value);
12614
+ var unwrapped = (value) => value.replace(/^["'`(]+/u, "").replace(/["'`).]+$/u, "");
12615
+ function looksLikeCredential(raw, matched) {
12616
+ const value = unwrapped(raw);
12617
+ if (isPlaceholder(raw) || isPlaceholder(value))
12618
+ return false;
12619
+ return /^[^\s:=]+=\S/u.test(matched) || value.length >= 6 && /[0-9]/u.test(value) || value.length >= 20 && /[a-z]/u.test(value) && /[A-Z]/u.test(value);
12620
+ }
12621
+ var globalPatterns = new WeakMap;
12622
+ var credentialUrlRule = {
12623
+ classification: "url",
12624
+ name: "credential-url",
12625
+ pattern: /\b(?:https?|ftp):\/\/(?:[^\s/?#]*@|[^\s?#]*\?)[^\s]*/iu
12626
+ };
12540
12627
  var keptClassifications = new Set(["secret", "credential", "unknown"]);
12541
12628
  var normalizedKeys = new Map;
12542
- var CREDENTIAL_RULES = VALUE_RULES.flatMap(([classification, pattern]) => classification === "secret" || classification === "credential" ? [[classification, new RegExp(pattern.source, `${pattern.flags}g`)]] : []);
12543
- var RESPONSE_RULES = [
12544
- ...CREDENTIAL_RULES,
12545
- ["url", new RegExp(credentialUrl.source, "giu")]
12546
- ];
12629
+ var CREDENTIAL_RULES = VALUE_RULES.filter((rule) => rule.classification === "secret" || rule.classification === "credential");
12630
+ var RESPONSE_RULES = [...CREDENTIAL_RULES, credentialUrlRule];
12547
12631
 
12548
12632
  // ../../packages/core/src/run.ts
12549
12633
  var RunContractVersion = Literal2("run.v1");
@@ -13998,15 +14082,6 @@ var StepAttemptSessionUpdateList = Struct({
13998
14082
  items: ArraySchema(StepAttemptSessionUpdate),
13999
14083
  next: optionalKey2(String5)
14000
14084
  });
14001
- var StepOutputSubmissionResult = Union2([
14002
- Struct({ status: Literal2("accepted") }),
14003
- Struct({
14004
- status: Literal2("rejected"),
14005
- message: String5,
14006
- submissionsLeft: Int.check(isGreaterThanOrEqualTo2(0))
14007
- }),
14008
- Struct({ status: Literal2("failed"), message: String5 })
14009
- ]);
14010
14085
  var HarnessHoldReasons = ["out_of_quota", "rate_limited", "login_refused", "failed_to_start"];
14011
14086
  var SkippedChoiceReasons = ["not_on_runner", ...HarnessHoldReasons];
14012
14087
  var SkippedChoice = Struct({
@@ -14047,9 +14122,9 @@ var StepAttempt = Struct({
14047
14122
  });
14048
14123
  var StepAttemptList = Struct({ items: ArraySchema(StepAttempt) });
14049
14124
  var QuestionResponderPolicy = Struct({
14050
- eligibleMemberIds: ArraySchema(Id).check(isMinLength(1), isMaxLength(100), isUnique()),
14125
+ eligibleMemberIds: ArraySchema(Id).check(isMaxLength(100), isUnique()),
14051
14126
  allowWorkspaceAdmins: Boolean3
14052
- });
14127
+ }).check(makeFilter2((policy) => policy.eligibleMemberIds.length > 0 || policy.allowWorkspaceAdmins || "someone who may answer"));
14053
14128
  var QuestionAnswer = Struct({
14054
14129
  value: LoopSafeText,
14055
14130
  answeredByUserId: optionalKey2(Id),
@@ -14083,6 +14158,16 @@ var Question = Struct({
14083
14158
  updatedAt: Timestamp,
14084
14159
  resolvedAt: optionalKey2(Timestamp)
14085
14160
  });
14161
+ var StepOutputSubmissionResult = Union2([
14162
+ Struct({ status: Literal2("accepted") }),
14163
+ Struct({
14164
+ status: Literal2("rejected"),
14165
+ message: String5,
14166
+ submissionsLeft: Int.check(isGreaterThanOrEqualTo2(0))
14167
+ }),
14168
+ Struct({ status: Literal2("failed"), message: String5 }),
14169
+ Struct({ status: Literal2("parked"), message: String5, question: Question })
14170
+ ]);
14086
14171
  var QuestionAnswerCreate = Struct({
14087
14172
  value: LoopSafeText,
14088
14173
  idempotencyKey: String5.check(isMinLength(1), isMaxLength(240))
@@ -14452,7 +14537,7 @@ var LoopCapabilities = [
14452
14537
  "draft_update"
14453
14538
  ];
14454
14539
  var JsonObject2 = Record(String5, Json2);
14455
- var SecretName = String5.check(isPattern2(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/));
14540
+ var SecretName2 = String5.check(isPattern2(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/));
14456
14541
  var EventFilterValue = Union2([String5, Finite, Boolean3, Null2]);
14457
14542
  var LoopManifest = Struct({
14458
14543
  id: String5,
@@ -14476,7 +14561,7 @@ var LoopManifest = Struct({
14476
14561
  from: optionalKey2(String5)
14477
14562
  })),
14478
14563
  capabilities: ArraySchema(Literals(LoopCapabilities)),
14479
- secrets: optionalKey2(ArraySchema(SecretName)),
14564
+ secrets: optionalKey2(ArraySchema(SecretName2)),
14480
14565
  network: optionalKey2(AgentSandboxNetwork),
14481
14566
  schedule: optionalKey2(Struct({ rule: ScheduleRule, timezone: String5 }))
14482
14567
  });
@@ -19848,33 +19933,6 @@ var entities = new Map([
19848
19933
  ["apos", "'"]
19849
19934
  ]);
19850
19935
 
19851
- // ../../packages/core/src/secret.ts
19852
- var SecretName2 = String5.check(isPattern2(new RegExp("^[A-Za-z_][A-Za-z0-9_]*$", "u")), isMinLength(1), isMaxLength(128));
19853
- var SecretScope = Union2([Literal2("workspace"), Literal2("team")]);
19854
- var SecretHost = String5.check(isPattern2(new RegExp("^(\\*\\.)?[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*(?::[0-9]{1,5})?$", "u")), isMaxLength(260));
19855
- var SecretHosts = ArraySchema(SecretHost).check(isMaxLength(32));
19856
- var referencePattern = /secret:\/\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+/;
19857
- var placeholderMarker = "kitmanref";
19858
- var tokenCharacter = "[A-Za-z0-9._~+/-]";
19859
- var placeholderPattern = new RegExp(`(?<!${tokenCharacter})(?:proxy-ep=[A-Za-z0-9.-]+;)?${tokenCharacter}*${placeholderMarker}((?:[0-9a-f]{2})+)`);
19860
- var anyReference = new RegExp(`${referencePattern.source}|${placeholderPattern.source}`, "g");
19861
- var SecretSummary = Struct({
19862
- name: SecretName2,
19863
- scope: SecretScope,
19864
- teamId: optionalKey2(Id),
19865
- hosts: SecretHosts,
19866
- setByActorType: ActorType,
19867
- setByActorId: String5,
19868
- setAt: Timestamp
19869
- });
19870
- var SecretList = Struct({ items: ArraySchema(SecretSummary) });
19871
- var SecretSet = Struct({
19872
- value: String5.check(isMinLength(1), isMaxLength(65536)),
19873
- teamId: optionalKey2(String5.check(isMinLength(1))),
19874
- hosts: optionalKey2(SecretHosts)
19875
- });
19876
- var SecretScopeQuery = Struct({ teamId: optionalKey2(Id) });
19877
-
19878
19936
  // ../../packages/core/src/work-unit.ts
19879
19937
  var WorkUnitLease = Struct({
19880
19938
  leaseOwnerId: Id,
@@ -20038,14 +20096,14 @@ var WorkUnitHeartbeatInput = Struct({
20038
20096
  workUnitId: Id,
20039
20097
  lease: WorkUnitLeaseInput,
20040
20098
  leaseDurationSeconds: optionalKey2(Int.check(isGreaterThanOrEqualTo2(1), isLessThanOrEqualTo3(3600))),
20041
- secrets: optionalKey2(ArraySchema(Struct({ name: SecretName2, version: String5.check(isMinLength(1), isMaxLength(128)) })).check(isMaxLength(256)))
20099
+ secrets: optionalKey2(ArraySchema(Struct({ name: SecretName, version: String5.check(isMinLength(1), isMaxLength(128)) })).check(isMaxLength(256)))
20042
20100
  });
20043
20101
  var WorkUnitHeartbeatResult = Struct({
20044
20102
  settled: Boolean3,
20045
20103
  outputSubmitted: optionalKey2(Boolean3),
20046
20104
  outputMerged: optionalKey2(Boolean3),
20047
20105
  questionOpen: optionalKey2(Boolean3),
20048
- revokedSecrets: optionalKey2(ArraySchema(SecretName2))
20106
+ revokedSecrets: optionalKey2(ArraySchema(SecretName))
20049
20107
  });
20050
20108
  var WorkUnitReleaseInput = Struct({
20051
20109
  workUnitId: Id,
@@ -21359,6 +21417,7 @@ var ShepherdOutput = Struct({
21359
21417
  reason: String5,
21360
21418
  fixRounds: Int,
21361
21419
  replies: Int,
21420
+ unsettled: optional2(ArraySchema(String5)),
21362
21421
  release: optional2(Struct({ runStatus: String5, reason: String5, tag: optional2(String5) })),
21363
21422
  handBack: optional2(Struct({
21364
21423
  changeRequestId: String5,
@@ -21496,6 +21555,7 @@ var shepherd_default = defineLoop({
21496
21555
  const syncedFor = new Set;
21497
21556
  const syncedKey = (head, targetHead) => `${head}@${targetHead}`;
21498
21557
  const blockerSynced = new Set;
21558
+ const blockerRechecks = new Map;
21499
21559
  let turn;
21500
21560
  let turns = 0;
21501
21561
  let passes = 0;
@@ -21506,7 +21566,8 @@ var shepherd_default = defineLoop({
21506
21566
  status,
21507
21567
  reason,
21508
21568
  fixRounds: fixRounds(),
21509
- replies
21569
+ replies,
21570
+ ...status === "needs_you" || status === "handed_back" ? { unsettled: [reason] } : undefined
21510
21571
  });
21511
21572
  const handBack = (reason, open) => ({
21512
21573
  ...done("handed_back", reason),
@@ -21719,8 +21780,20 @@ ${open}`,
21719
21780
  const blocker = pipeline.conflicts === true ? `conflicts with ${target}` : `needs ${target} merged in`;
21720
21781
  const targetHead = pipeline.target?.head;
21721
21782
  const syncedAlready = targetHead === undefined ? blockerSynced.has(pipeline.head) : syncedFor.has(syncedKey(pipeline.head, targetHead));
21722
- if (syncedAlready)
21723
- return handBack(`The forge still says ${pipeline.head} ${blocker} after merging it in`, `Merge ${target} into the branch and settle what conflicts.`);
21783
+ if (syncedAlready) {
21784
+ const rechecks = (blockerRechecks.get(pipeline.head) ?? 0) + 1;
21785
+ blockerRechecks.set(pipeline.head, rechecks);
21786
+ if (rechecks <= 3) {
21787
+ yield* waitFor(`recheck:${cycle}`, {
21788
+ event: "change_request.mergeable",
21789
+ filter: { changeRequestId, head: pipeline.head },
21790
+ timeout: "2 minutes",
21791
+ ...pipeline.readAt === undefined ? undefined : { since: pipeline.readAt }
21792
+ }).pipe(catchTag2("WaitTimedOut", () => void_3));
21793
+ continue;
21794
+ }
21795
+ return handBack(`The forge still says ${pipeline.head} ${blocker} after merging it in, and three more looks said the same`, `Merge ${target} into the branch and settle what conflicts.`);
21796
+ }
21724
21797
  if (targetHead !== undefined)
21725
21798
  syncedFor.add(syncedKey(pipeline.head, targetHead));
21726
21799
  blockerSynced.add(pipeline.head);
@@ -30096,4 +30169,4 @@ var runKit = (config, identity, packages) => {
30096
30169
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
30097
30170
  };
30098
30171
  // .kitman-build-entry.ts
30099
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.79" }, []);
30172
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.81" }, []);
@@ -364,6 +364,19 @@
364
364
  "minimum": -9007199254740991,
365
365
  "maximum": 9007199254740991
366
366
  },
367
+ "unsettled": {
368
+ "anyOf": [
369
+ {
370
+ "type": "array",
371
+ "items": {
372
+ "type": "string"
373
+ }
374
+ },
375
+ {
376
+ "type": "null"
377
+ }
378
+ ]
379
+ },
367
380
  "release": {
368
381
  "anyOf": [
369
382
  {
@@ -2769,6 +2782,19 @@
2769
2782
  "minimum": -9007199254740991,
2770
2783
  "maximum": 9007199254740991
2771
2784
  },
2785
+ "unsettled": {
2786
+ "anyOf": [
2787
+ {
2788
+ "type": "array",
2789
+ "items": {
2790
+ "type": "string"
2791
+ }
2792
+ },
2793
+ {
2794
+ "type": "null"
2795
+ }
2796
+ ]
2797
+ },
2772
2798
  "release": {
2773
2799
  "anyOf": [
2774
2800
  {
@@ -3383,7 +3409,7 @@
3383
3409
  "carried": [
3384
3410
  {
3385
3411
  "name": "@kitman-sh/software-engineering",
3386
- "version": "0.10.79",
3412
+ "version": "0.10.81",
3387
3413
  "setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
3388
3414
  "loops": [
3389
3415
  "build",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitman-sh/software-engineering",
3
- "version": "0.10.79",
3
+ "version": "0.10.81",
4
4
  "description": "Everything for building software: Loops, their Agents, the skills they use and the Ponytail plugin.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -17,12 +17,12 @@
17
17
  "tsconfig.json"
18
18
  ],
19
19
  "dependencies": {
20
- "@kitman-sh/sdk": "0.10.79",
20
+ "@kitman-sh/sdk": "0.10.81",
21
21
  "effect": "4.1.2"
22
22
  },
23
23
  "kitman": {
24
24
  "bundle": "dist/bundle.js",
25
- "digest": "ae3d7067a071697886e9c7a674187f055dcdacaa49baea8b70a8701de8fb4bf5",
25
+ "digest": "8b38eb9071e521d41da1abdfb4579ddbaed942e423430be8211817fafaad6280",
26
26
  "protocolVersion": 5,
27
27
  "declarations": "dist/declarations.json",
28
28
  "setup": {
@@ -8,6 +8,8 @@ export const ShepherdOutput = Schema.Struct({
8
8
  reason: Schema.String,
9
9
  fixRounds: Schema.Int,
10
10
  replies: Schema.Int,
11
+ /** What still stands when it stopped without landing (needs_you, handed_back), so the Run and a Build above it read partial. */
12
+ unsettled: Schema.optional(Schema.Array(Schema.String)),
11
13
  /** The Release it started after merging, when it was told to release. */
12
14
  release: Schema.optional(
13
15
  Schema.Struct({ runStatus: Schema.String, reason: Schema.String, tag: Schema.optional(Schema.String) })
package/src/shepherd.ts CHANGED
@@ -273,6 +273,8 @@ export default defineLoop({
273
273
  const syncedKey = (head: string, targetHead: string) => `${head}@${targetHead}`
274
274
  /** The heads a sync for the forge's blocker started from or pushed, judged by when the target's head is unknown. */
275
275
  const blockerSynced = new Set<string>()
276
+ /** How often the forge's blocker has been looked at again at a head a sync settled it for. */
277
+ const blockerRechecks = new Map<string, number>()
276
278
 
277
279
  /** The target's turn: held from the sync before the merge until the merge, so one ChangeRequest merges at a time. */
278
280
  let turn: Claim | undefined
@@ -292,7 +294,8 @@ export default defineLoop({
292
294
  status,
293
295
  reason,
294
296
  fixRounds: fixRounds(),
295
- replies
297
+ replies,
298
+ ...(status === 'needs_you' || status === 'handed_back' ? { unsettled: [reason] } : undefined)
296
299
  })
297
300
 
298
301
  const handBack = (reason: string, open: string): Output => ({
@@ -623,11 +626,29 @@ export default defineLoop({
623
626
  ? blockerSynced.has(pipeline.head)
624
627
  : syncedFor.has(syncedKey(pipeline.head, targetHead))
625
628
 
626
- if (syncedAlready)
629
+ if (syncedAlready) {
630
+ // This head already took the target in, so the blocker is most likely the forge's answer for an older head:
631
+ // GitLab works mergeability out after a push and shows the last answer meanwhile. Look again before giving up.
632
+ const rechecks = (blockerRechecks.get(pipeline.head) ?? 0) + 1
633
+
634
+ blockerRechecks.set(pipeline.head, rechecks)
635
+
636
+ if (rechecks <= 3) {
637
+ yield* waitFor(`recheck:${cycle}`, {
638
+ event: 'change_request.mergeable',
639
+ filter: { changeRequestId, head: pipeline.head },
640
+ timeout: '2 minutes',
641
+ ...(pipeline.readAt === undefined ? undefined : { since: pipeline.readAt })
642
+ }).pipe(Effect.catchTag('WaitTimedOut', () => Effect.void))
643
+
644
+ continue
645
+ }
646
+
627
647
  return handBack(
628
- `The forge still says ${pipeline.head} ${blocker} after merging it in`,
648
+ `The forge still says ${pipeline.head} ${blocker} after merging it in, and three more looks said the same`,
629
649
  `Merge ${target} into the branch and settle what conflicts.`
630
650
  )
651
+ }
631
652
 
632
653
  if (targetHead !== undefined) syncedFor.add(syncedKey(pipeline.head, targetHead))
633
654
  blockerSynced.add(pipeline.head)