@gooseworks/staff-cli 0.1.6 → 0.1.7

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 (2) hide show
  1. package/goose-staff.mjs +530 -149
  2. package/package.json +3 -3
package/goose-staff.mjs CHANGED
@@ -13269,10 +13269,11 @@ var init_finding_style_checks = __esmMin((() => {
13269
13269
  sureOfSize: "sure of the size"
13270
13270
  };
13271
13271
  misSplitProblem = "The fix splits in the wrong place: a step would start with a number. A name ending in a number, like \"Ad set 2.\", can't end a sentence. Reword it, like \"the Ad set 2 ads.\".";
13272
- })), queueAnswer, queueFix, queueFoundBy, queueFlag, staffQueueFilters;
13272
+ })), noOwner, queueOwner, queueAnswer, queueFix, queueFlag, queueFoundOn, staffQueueFilters;
13273
13273
  var init_staff_queue_filters = __esmMin((() => {
13274
13274
  init_zod();
13275
- init_finding_generators();
13275
+ noOwner = "none";
13276
+ queueOwner = union([uuid(), literal(noOwner)]).nullable().describe(`Only drafts this staffer owns, or ${noOwner} for only drafts nobody owns. null for any owner.`);
13276
13277
  queueAnswer = _enum([
13277
13278
  "none",
13278
13279
  "on_it",
@@ -13286,18 +13287,19 @@ var init_staff_queue_filters = __esmMin((() => {
13286
13287
  "due",
13287
13288
  "failed"
13288
13289
  ]).nullable().describe("unconfirmed: the client said fixed, and neither its check worked nor Goose closed it. confirmed: its check worked or Goose closed it, it wasn't reopened after its check worked, and the client's \"Not a problem\" doesn't stand on it. unopened: published with no check yet. due: its measure is approved, its check isn't final, a whole week has ended since the week its fix went live, and the newest whole week has no read. failed: its check found no change or worse. null skips this filter.");
13289
- queueFoundBy = _enum([...generatorKinds, "unrecorded"]).nullable().describe("How the problem was found, as the draft saved it. unrecorded for a draft saved before generators. null skips this filter.");
13290
13290
  queueFlag = _enum([
13291
13291
  "low_confidence",
13292
13292
  "not_sized",
13293
13293
  "client_commented"
13294
13294
  ]).nullable().describe(`low_confidence: sure it's real or sure of the cause under ${String(50)}. not_sized: no money at stake. client_commented: someone at the brand commented on the published finding. null skips this filter.`);
13295
+ queueFoundOn = date().nullable().describe("Only drafts first saved on this day, on the daily watch's clock: the New York day of the draft's first save. null for any day.");
13295
13296
  staffQueueFilters = object({
13297
+ owner: queueOwner,
13296
13298
  answer: queueAnswer,
13297
13299
  fix: queueFix,
13298
13300
  isAssigned: boolean().nullable().describe("true for published findings someone at the brand gave to a person in their organization, false for published ones nobody has. null skips this filter."),
13299
- foundBy: queueFoundBy,
13300
- flag: queueFlag
13301
+ flag: queueFlag,
13302
+ foundOn: queueFoundOn
13301
13303
  });
13302
13304
  })), staffLabelName, staffLabelList, staffLabelGroups, staffLabelCatalog, draftLanes, draftLane;
13303
13305
  var init_staff_labels = __esmMin((() => {
@@ -14890,7 +14892,8 @@ var init_findings = __esmMin((() => {
14890
14892
  object({
14891
14893
  by: literal("goose_team"),
14892
14894
  heardHow: string()
14893
- }).describe("The Goose team, recording what the client told them outside Goose.")
14895
+ }).describe("The Goose team, recording what the client told them outside Goose."),
14896
+ object({ by: literal("goose") }).describe("Goose's weekly check, which put a finding marked fixed back to On it because part of it is still left.")
14894
14897
  ]).describe("Who decided, or who recorded the client's decision.");
14895
14898
  decision = {
14896
14899
  decidedBy: findingDecider,
@@ -15721,7 +15724,11 @@ var init_staff_findings = __esmMin((() => {
15721
15724
  "declined",
15722
15725
  "acted_on"
15723
15726
  ]),
15724
- recordedBy: _enum(["client", "staff"]).describe("client when someone at the brand decided in Goose, staff when the Goose team recorded it."),
15727
+ recordedBy: _enum([
15728
+ "client",
15729
+ "staff",
15730
+ "goose"
15731
+ ]).describe("client when someone at the brand decided in Goose, staff when the Goose team recorded it, goose when the weekly fix check put a finding marked fixed back to On it because part of it is still left."),
15725
15732
  heardHow: string().nullable().describe("How the Goose team heard it. null when the client decided."),
15726
15733
  decidedAt: date$1()
15727
15734
  });
@@ -15745,6 +15752,7 @@ var init_staff_findings = __esmMin((() => {
15745
15752
  findingStanding = findingState.pick({
15746
15753
  status: true,
15747
15754
  fixedAt: true,
15755
+ resolvedBy: true,
15748
15756
  isHidden: true
15749
15757
  }).extend({
15750
15758
  outcome: clientOutcome.pick({ kind: true }).nullable(),
@@ -15832,7 +15840,6 @@ var init_staff_findings = __esmMin((() => {
15832
15840
  tier: signalTier.nullable().describe("One tier's rows, or null for every tier."),
15833
15841
  isMissingTrail: boolean().describe("true lists only drafts saved with no fix time, trail or found-by."),
15834
15842
  show: staffDraftShow.nullable().describe("null lists every draft, whatever its status."),
15835
- ownerId: uuid().nullable().describe("Only drafts this staffer owns. null for any owner."),
15836
15843
  lane: draftLane.nullable().describe("Only drafts in this lane, worked out the same way as the lanes totals. null for every lane."),
15837
15844
  query: string().trim().min(1).max(200).nullable().describe("Words to find in a draft's title, TL;DR, subject, summary or number (like F-12), ignoring case. null for no search."),
15838
15845
  ...staffQueueFilters.shape,
@@ -20724,9 +20731,50 @@ var init_staff = __esmMin((() => {
20724
20731
  }).describe("Failed work from the last 30 days, grouped.")), readCall("people").input(timePageInput).output(timePageOf(deletingTeam)), readCall("people").output(object({ stuck: number$1().int().nonnegative() }));
20725
20732
  }));
20726
20733
  // ../../packages/contract/src/staff-fix-check.ts
20734
+ function describeLeftClose(proof, note) {
20735
+ return `${proof} Still left: ${note}`;
20736
+ }
20727
20737
  function listVerdictsWith(part) {
20728
20738
  return fixCheckVerdict$1.options.filter((verdict) => lookNeeds[verdict][part] !== "none");
20729
20739
  }
20740
+ function listLeftProblems(look) {
20741
+ if (look.verdict !== "partly_fixed") return ["isLeftWorthSending", "leftAmount"].filter((part) => look[part] !== null).map((part) => ({
20742
+ path: [part],
20743
+ message: `A ${look.verdict} look takes ${part} null. Send ${part} only on partly_fixed.`
20744
+ }));
20745
+ if (look.note !== null && look.note.length > fixCheckLimits.partlyNote) return [{
20746
+ path: ["note"],
20747
+ message: `A partly_fixed look's note holds ${String(fixCheckLimits.partlyNote)} characters at most, and this one has ${String(look.note.length)}: the server keeps room under it for its reason when the look's close or reopen is refused. Shorten note.`
20748
+ }];
20749
+ if (look.isLeftWorthSending === null) return [{
20750
+ path: ["isLeftWorthSending"],
20751
+ message: "A partly_fixed look needs isLeftWorthSending: whether what is left would be worth sending as a finding of its own."
20752
+ }];
20753
+ if (look.isLeftWorthSending || look.proof === null || look.note === null) return [];
20754
+ const reason = describeLeftClose(look.proof, look.note);
20755
+ return [
20756
+ ...listProofStyleProblems(look.proof).map((message) => ({
20757
+ path: ["proof"],
20758
+ message
20759
+ })),
20760
+ ...listClientNoteStyleProblems(look.note).map((message) => ({
20761
+ path: ["note"],
20762
+ message
20763
+ })),
20764
+ ...reason.length > fixCheckLimits.closeReason ? [{
20765
+ path: ["note"],
20766
+ message: `What isn't worth sending closes the finding with proof, "Still left:" and note as one reason of ${String(reason.length)} characters, over the ${String(fixCheckLimits.closeReason)} a close reason holds. Shorten note.`
20767
+ }] : []
20768
+ ];
20769
+ }
20770
+ function listSureProblems(look) {
20771
+ if (!sureVerdicts.has(look.verdict) || look.sure >= 75) return [];
20772
+ const what = look.verdict === "partly_fixed" ? "that its fixed part is fixed" : "";
20773
+ return [{
20774
+ path: ["sure"],
20775
+ message: `A ${look.verdict} look needs sure at ${String(75)} or more${what === "" ? "" : ` ${what}`}, and this one is ${String(look.sure)}. Under ${String(75)} nothing is called fixed: save the verdict the reads support.`
20776
+ }];
20777
+ }
20730
20778
  function listLookProblems(look) {
20731
20779
  const needs = lookNeeds[look.verdict];
20732
20780
  const missing = neededLookParts.filter((part) => needs[part] === "required" && look[part] === null).map((part) => ({
@@ -20744,7 +20792,9 @@ function listLookProblems(look) {
20744
20792
  return [
20745
20793
  ...missing,
20746
20794
  ...unwanted,
20747
- ...unclear
20795
+ ...unclear,
20796
+ ...listLeftProblems(look),
20797
+ ...listSureProblems(look)
20748
20798
  ];
20749
20799
  }
20750
20800
  function waitingList(item) {
@@ -20753,14 +20803,16 @@ function waitingList(item) {
20753
20803
  totalCount: count$1.describe("How many wait in all.")
20754
20804
  });
20755
20805
  }
20756
- var fixCheckRules, fixCheckLimits, count$1, fixCheckPerson, fixCheckMode, fixCheckRunStatus, fixCheckRunFailure, fixCheckVerdict$1, fixCheckJob, fixCheckEffect, fixCheckSaleKind, fixCheckFixDaySource, fixCheckCounts, fixCheckRunSummary, fixCheckRunNotesInput, fixCheckRunRecord, timerOwnerPerson, fixCheckTimerOwner, fixCheckSetup, fixCheckWeekInput, fixCheckWeek, fixCheckCreditInput, fixCheckFixDay, fixCheckLookFields, neededLookParts, lookParts, lookNeeds, lookAsks$1, fixCheckLookInput, fixCheckReadInput, fixCheckLook, fixCheckLastLook, fixCheckMeasuring, fixCheckReturningDraft, fixCheckWatchHit, fixCheckFacts, fixCheckListItem, fixCheckFinding, fixCheckSavedLook, waitingFindingId, waitingTitle, waitingLookNote, fixCheckListedLook, waitingLook, fixCheckClose, fixCheckWaiting, fixCheckMoneyBack, fixCheckWeekState;
20806
+ var fixCheckRules, fixCheckLimits, count$1, fixCheckPerson, fixCheckMode, fixCheckRunStatus, fixCheckRunFailure, fixCheckVerdict$1, fixCheckJob, fixCheckEffect, fixCheckSaleKind, fixCheckFixDaySource, fixCheckCounts, fixCheckRunSummary, fixCheckRunNotesInput, fixCheckRunRecord, timerOwnerPerson, fixCheckTimerOwner, fixCheckSetup, fixCheckWeekInput, fixCheckWeek, fixCheckCreditInput, fixCheckFixDay, fixCheckSure, fixCheckLeftAmount, fixCheckLookFields, neededLookParts, lookParts, lookNeeds, lookAsks$1, sureVerdicts, fixCheckLookInput, fixCheckReadInput, fixCheckLook, fixCheckLastLook, fixCheckMeasuring, fixCheckReturningDraft, fixCheckWatchHit, fixCheckFacts, fixCheckListItem, fixCheckFinding, fixCheckSavedLook, waitingFindingId, waitingTitle, waitingLookNote, fixCheckListedLook, fixCheckNoProgress, waitingLook, fixCheckClose, fixCheckWaiting, fixCheckMoneyBack, fixCheckWeekState;
20757
20807
  var init_staff_fix_check = __esmMin((() => {
20758
20808
  init_zod();
20759
20809
  init_finding_checks();
20760
20810
  init_finding_style_text();
20761
20811
  init_finding_trail();
20812
+ init_finding_words();
20762
20813
  init_findings();
20763
20814
  init_signal_keys();
20815
+ init_staff_queue_filters();
20764
20816
  init_staff_watch();
20765
20817
  fixCheckRules = {
20766
20818
  listedDays: 60,
@@ -20771,7 +20823,8 @@ var init_staff_fix_check = __esmMin((() => {
20771
20823
  lookSaveLimit: 15,
20772
20824
  recentRunLimit: 8,
20773
20825
  pageLimit: 50,
20774
- waitingLimit: 20
20826
+ waitingLimit: 20,
20827
+ noProgressWeeks: 3
20775
20828
  };
20776
20829
  fixCheckLimits = {
20777
20830
  proof: 300,
@@ -20780,7 +20833,10 @@ var init_staff_fix_check = __esmMin((() => {
20780
20833
  note: 2e3,
20781
20834
  evidence: 1e3,
20782
20835
  fixDayNote: 500,
20783
- weekReason: 1e3
20836
+ weekReason: 1e3,
20837
+ closeReason: 2e3,
20838
+ partlyNote: 1500,
20839
+ serverNote: 498
20784
20840
  };
20785
20841
  count$1 = number$1().int().min(0);
20786
20842
  fixCheckPerson = object({
@@ -20818,7 +20874,7 @@ var init_staff_fix_check = __esmMin((() => {
20818
20874
  "closed",
20819
20875
  "reopened",
20820
20876
  "none"
20821
- ]).describe("closed: the look closed the finding by Goose. reopened: the look reopened a close the fix check made. none: the look changed nothing the brand sees.");
20877
+ ]).describe("closed: the look closed the finding by Goose, on fixed or on a partly_fixed look whose leftover isn't worth sending. reopened: the look took the finding off fixed: a fix_not_held look reopened a close the fix check made, or a partly_fixed look whose leftover is worth sending reopened that close or put a finding marked fixed back to On it. none: the look changed nothing the brand sees.");
20822
20878
  fixCheckSaleKind = _enum([
20823
20879
  "black_friday",
20824
20880
  "storewide_discount",
@@ -20917,15 +20973,25 @@ var init_staff_fix_check = __esmMin((() => {
20917
20973
  source: fixCheckFixDaySource,
20918
20974
  note: string().trim().min(1).max(fixCheckLimits.fixDayNote).describe("What was seen, like the change-log line.")
20919
20975
  });
20976
+ fixCheckSure = int().min(0).max(100).describe(`How sure the checker is, from 0 to 100, that the problem it judges is gone: under ${String(50)} unsure, under ${String(75)} fairly sure, ${String(75)} and up sure. fixed, fix_held and partly_fixed need ${String(75)} or more. A neighboring read counts as evidence, and a gap lowers it instead of ending the judgment.`);
20977
+ fixCheckLeftAmount = object({
20978
+ low: number$1().nonnegative().describe("The low end."),
20979
+ high: number$1().nonnegative().describe("The high end."),
20980
+ currency: currencyCode.describe("A three-letter code like USD, the finding's own currency."),
20981
+ period: literal("month").describe("Always month: what is left costs this each month.")
20982
+ }).refine((amount) => amount.low <= amount.high, "low can't be above high.").describe("The money what is left still costs each month, low to high.");
20920
20983
  fixCheckLookFields = object({
20921
20984
  findingId: uuid().describe("A finding on this run's list, from fix_check_run_start or fix_check_looks_read."),
20922
20985
  verdict: fixCheckVerdict$1,
20923
- proof: string().trim().min(1).max(fixCheckLimits.proof).nullable().describe("One line the brand can read, with the number the read showed and its day. On fixed it becomes the close reason the brand reads on the finding, in its activity and in their AI app. On partly_fixed it says what is fixed, on fix_seen what reads clean, and both stay staff only. Required on partly_fixed, fix_seen, fixed, fix_held and fix_not_held. null on still_open, brand_decided and cant_check."),
20986
+ proof: string().trim().min(1).max(fixCheckLimits.proof).nullable().describe("One line the brand can read, with the number the read showed and its day. On fixed it becomes the close reason the brand reads on the finding, in its activity and in their AI app. On partly_fixed it says what is fixed, and stays staff only unless the leftover isn't worth sending and the look closes the finding: then it begins the close reason the brand reads. On fix_seen it says what reads clean, staff only. Required on partly_fixed, fix_seen, fixed, fix_held and fix_not_held. null on still_open, brand_decided and cant_check."),
20924
20987
  tried: array(string().trim().min(1).max(fixCheckLimits.triedLine)).min(1).max(fixCheckLimits.triedLines).describe("Each read rerun and what it showed, how the checker tried to prove the problem still there, and what it checked that the fix touched, one line each. Staff only."),
20925
- note: string().trim().min(1).max(fixCheckLimits.note).nullable().describe("On partly_fixed, what still isn't fixed. On fix_seen, the week that will prove it. On brand_decided, the brand's words, who said them, where and when. On cant_check, why it couldn't be read. On any other verdict send null. The server writes it on a fix_not_held look whose reopen was refused, and on a fixed look that closed nothing in a live run. Staff only."),
20988
+ note: string().trim().min(1).max(fixCheckLimits.note).nullable().describe(`On partly_fixed, what still isn't fixed, ${String(fixCheckLimits.partlyNote)} characters at most so the server's reason fits under it: when the leftover isn't worth sending and the look closes the finding, the brand reads it after "Still left:" in the close reason, and otherwise it stays staff only. On fix_seen, the week that will prove it. On brand_decided, the brand's words, who said them, where and when. On cant_check, why it couldn't be read. On any other verdict send null. The server writes it on a fix_not_held look whose reopen was refused and on a fixed look that closed nothing in a live run, and adds its reason under a partly_fixed look's note when its close or reopen is refused. Staff only on every other look.`),
20926
20989
  credit: fixCheckCreditInput.nullable().describe("Who gets the credit for the fix. client_fixed: a change only a person could make, dated on or after the day the brand first saw the finding. went_away: the number recovered with nothing visibly changed. Required on fixed, allowed on fix_held, null on every other verdict."),
20927
20990
  fixedOn: fixCheckFixDay.nullable().describe("The day the fix went live, where that day comes from and what was seen. Required on fixed, allowed on fix_held, null on every other verdict."),
20928
- draftId: uuid().nullable().describe("A draft this look names, from finding_draft_save or findings_list. On fixed or fix_held: the waiting draft of a new problem the fix created. On fix_not_held with reopensIfNotHeld false: the draft that returns from this finding, which is the waiting one in returningDraft, the one a staffer discarded, a waiting draft on the same problem that returns from no finding yet, or a new one saved with returnsFromFindingId. null on fix_not_held with reopensIfNotHeld true and on every verdict not named here.")
20991
+ draftId: uuid().nullable().describe("A draft this look names, from finding_draft_save or findings_list. On fixed or fix_held: the waiting draft of a new problem the fix created. On fix_not_held with reopensIfNotHeld false: the draft that returns from this finding, which is the waiting one in returningDraft, the one a staffer discarded, a waiting draft on the same problem that returns from no finding yet, or a new one saved with returnsFromFindingId. null on fix_not_held with reopensIfNotHeld true and on every verdict not named here."),
20992
+ sure: fixCheckSure,
20993
+ isLeftWorthSending: boolean().nullable().describe("On partly_fixed, whether what is left would be worth sending as a finding of its own: above the brand's minimum and something to act on. false: in a live run it counts as fixed, so a find_fix finding closes by Goose as a fixed look does, with proof and then note after \"Still left:\" as the close reason the brand reads, and waits for a staffer's confirm; a recheck_fix finding doesn't change. true: a find_fix finding keeps its status, and a recheck_fix finding goes back: one marked fixed by the brand or staff goes back to On it, and a close the fix check made itself reopens. null on every other verdict."),
20994
+ leftAmount: fixCheckLeftAmount.nullable().describe("On partly_fixed, the money what is left still costs each month, in the finding's currency. null when the finding has no money, and on every other verdict.")
20929
20995
  });
20930
20996
  neededLookParts = [
20931
20997
  "proof",
@@ -20998,6 +21064,11 @@ var init_staff_fix_check = __esmMin((() => {
20998
21064
  fixedOn: "the day the fix went live, where that day comes from and what was seen",
20999
21065
  note: "what isn't fixed on partly_fixed, the week that will prove it on fix_seen, the brand's words on brand_decided, or why it couldn't be read on cant_check"
21000
21066
  };
21067
+ sureVerdicts = /* @__PURE__ */ new Set([
21068
+ "fixed",
21069
+ "fix_held",
21070
+ "partly_fixed"
21071
+ ]);
21001
21072
  fixCheckLookInput = fixCheckLookFields.superRefine((look, context) => {
21002
21073
  for (const { path, message } of listLookProblems(look)) context.addIssue({
21003
21074
  code: "custom",
@@ -21026,6 +21097,9 @@ var init_staff_fix_check = __esmMin((() => {
21026
21097
  }).nullable().describe("The credit the look proposes for the fix. null when it proposes none."),
21027
21098
  fixedOn: fixCheckFixDay.nullable().describe("The fix day the look found, with its source. null when it found none."),
21028
21099
  draftId: uuid().nullable().describe("The draft the look names: one that returns from this finding on fix_not_held, or a new problem the fix created on fixed or fix_held. null when it names none."),
21100
+ sure: fixCheckSure.nullable().describe("How sure the checker was, 0 to 100, that the problem it judged is gone. null on a look saved before looks carried it."),
21101
+ isLeftWorthSending: boolean().nullable().describe("On partly_fixed, whether what is left is worth sending as a finding of its own. null on every other look, and on a partly_fixed look saved before looks carried it."),
21102
+ leftAmount: fixCheckLeftAmount.nullable().describe("On partly_fixed, the money what is left still costs each month. null when the finding has no money, and on every other look."),
21029
21103
  effect: fixCheckEffect,
21030
21104
  createdAt: date$1().describe("When the look was saved.")
21031
21105
  });
@@ -21036,6 +21110,9 @@ var init_staff_fix_check = __esmMin((() => {
21036
21110
  proof: true,
21037
21111
  note: true,
21038
21112
  fixedOn: true,
21113
+ sure: true,
21114
+ isLeftWorthSending: true,
21115
+ leftAmount: true,
21039
21116
  effect: true,
21040
21117
  createdAt: true
21041
21118
  });
@@ -21084,7 +21161,11 @@ var init_staff_fix_check = __esmMin((() => {
21084
21161
  "declined",
21085
21162
  "acted_on"
21086
21163
  ]).describe("on_it: the brand said it will do it. declined: the brand said it isn't a problem. acted_on: an Acted on decision, which stops every Goose reopen."),
21087
- recordedBy: _enum(["client", "staff"]).describe("client: someone at the brand decided in Goose. staff: the Goose team recorded what the client told them."),
21164
+ recordedBy: _enum([
21165
+ "client",
21166
+ "staff",
21167
+ "goose"
21168
+ ]).describe("client: someone at the brand decided in Goose. staff: the Goose team recorded what the client told them. goose: the weekly fix check put a finding marked fixed back to On it, because part of it is still left and worth sending."),
21088
21169
  decidedAt: date$1().describe("When it was decided."),
21089
21170
  heardHow: string().nullable().describe("How the Goose team heard it. null when the brand decided in Goose.")
21090
21171
  }).nullable().describe("The decision the finding holds. null when it holds none."),
@@ -21144,7 +21225,17 @@ var init_staff_fix_check = __esmMin((() => {
21144
21225
  title: waitingTitle,
21145
21226
  runWeek: date().describe("The run's week, its Monday in New York time."),
21146
21227
  proof: string().nullable().describe("What the look saw fixed or clean. null on still_open, brand_decided and cant_check."),
21147
- note: waitingLookNote.nullable().describe("What isn't fixed yet, the week that will prove it, the brand's words, or why it couldn't be read, as the verdict has it. null on still_open, fixed and fix_held.")
21228
+ note: waitingLookNote.nullable().describe("What isn't fixed yet, the week that will prove it, the brand's words, or why it couldn't be read, as the verdict has it. null on still_open, fixed and fix_held."),
21229
+ sure: fixCheckLook.shape.sure,
21230
+ isLeftWorthSending: fixCheckLook.shape.isLeftWorthSending,
21231
+ leftAmount: fixCheckLook.shape.leftAmount
21232
+ });
21233
+ fixCheckNoProgress = object({
21234
+ findingId: waitingFindingId,
21235
+ title: waitingTitle,
21236
+ runWeeks: array(date()).length(fixCheckRules.noProgressWeeks).describe("The weeks of the looks that saw no progress, by their New York Mondays, newest first."),
21237
+ note: string().describe("What the newest look says is still left."),
21238
+ leftAmount: fixCheckLeftAmount.nullable().describe("The money the newest look says is still left each month. null when the finding has no money.")
21148
21239
  });
21149
21240
  waitingLook = waitingList(fixCheckListedLook.extend({ note: waitingLookNote }));
21150
21241
  fixCheckClose = object({
@@ -21156,8 +21247,9 @@ var init_staff_fix_check = __esmMin((() => {
21156
21247
  isMarkedFixedByBrand: boolean().describe("true when someone at the brand marked it fixed in Goose. Then a staffer can only confirm the close: only the brand reopens it."),
21157
21248
  proposal: fixCheckLook.pick({
21158
21249
  credit: true,
21159
- fixedOn: true
21160
- }).nullable().describe("The credit and fix day the newest fix-check look proposes for this close. null when no look does, as on a watch close nobody re-checked.")
21250
+ fixedOn: true,
21251
+ sure: true
21252
+ }).nullable().describe("The credit, fix day and sureness of the newest fix-check look that proposes a credit for this close or made it. null when no look does, as on a watch close nobody re-checked.")
21161
21253
  });
21162
21254
  fixCheckWaiting = object({
21163
21255
  closes: waitingList(fixCheckClose).describe("Closes by Goose that no staffer has confirmed, the daily watch's and the weekly fix check's. A staffer confirms each with finding_close_confirm and its credit, or reopens it with finding_reopen."),
@@ -21167,6 +21259,7 @@ var init_staff_fix_check = __esmMin((() => {
21167
21259
  runWeek: date().describe("The run's week, its Monday in New York time."),
21168
21260
  proof: string().describe("The look's proof line."),
21169
21261
  note: string().describe("The server's reason the look closed nothing."),
21262
+ sure: fixCheckLook.shape.sure,
21170
21263
  canResolve: boolean().describe("True when finding_resolve closes it. A first-audit finding's is false: finding_outcome_save records what the client did with it.")
21171
21264
  })).describe("Findings the newest live run saw fixed and didn't close, still open, with the look's proof and the server's reason. A staffer closes each by hand, with finding_resolve, or with finding_outcome_save when the client fixed it, or leaves it open."),
21172
21265
  watchHits: waitingList(object({
@@ -21188,7 +21281,8 @@ var init_staff_fix_check = __esmMin((() => {
21188
21281
  title: waitingTitle,
21189
21282
  measureName: string().describe("The proposed measure's name.")
21190
21283
  })).describe("Measures a run proposed that wait for a staffer to approve or decline, newest first. No read saves on one until it is approved."),
21191
- partlyFixed: waitingLook.describe("The findings the brand's newest run saw partly fixed: proof says what is fixed and note what isn't. A staffer sends the brand what is left."),
21284
+ partlyFixed: waitingLook.describe("The findings the brand's newest run saw partly fixed and didn't close: proof says what is fixed, note what isn't, and leftAmount what that still costs. A staffer sends the brand what is left."),
21285
+ noProgress: waitingList(fixCheckNoProgress).describe(`The findings whose last ${String(fixCheckRules.noProgressWeeks)} weekly looks all saw them partly fixed with a leftover worth sending, and whose money left hasn't fallen since the first of them, the newest run's included. A staffer nudges the brand, or records that they're leaving it. Nothing closes by itself.`),
21192
21286
  fixSeen: waitingLook.describe("The findings whose number the brand's newest run saw read clean: proof says what it showed and note the week that will prove it."),
21193
21287
  brandDecided: waitingLook.describe("The findings the brand's newest run saw still there by the brand's own choice: note holds the brand's words. A staffer records the choice with decision_save, or asks again later."),
21194
21288
  cantCheck: waitingLook.describe("The findings the brand's newest run couldn't check, each with why in note.")
@@ -22160,7 +22254,7 @@ var init_staff_agent = __esmMin((() => {
22160
22254
  readFixCheckBrand: staffRead().input(brandInput).output(object({
22161
22255
  setup: fixCheckSetup.describe("The brand's fix check: its mode and who timer runs act as. With nothing saved yet the mode is off."),
22162
22256
  runs: array(fixCheckRunSummary).max(fixCheckRules.recentRunLimit).describe(`The brand's newest ${fixCheckRules.recentRunLimit} runs with their counts, dry and real together, newest week first.`),
22163
- waiting: fixCheckWaiting.describe("What waits for a staffer: Goose closes to confirm, findings a run saw fixed and didn't close, findings the fix check closed that the daily watch has hit since, drafts that return from a finding, measures to approve and looks that couldn't check.")
22257
+ waiting: fixCheckWaiting.describe("What waits for a staffer: Goose closes to confirm, findings a run saw fixed and didn't close, findings the fix check closed that the daily watch has hit since, drafts that return from a finding, measures to approve, the newest run's partly fixed, fix seen, brand decided and couldn't check looks, and findings with no progress after three weekly looks.")
22164
22258
  })),
22165
22259
  saveFixCheckBrand: staffChange().input(brandInput.extend({ mode: fixCheckMode.describe("The brand's mode. off: every start is refused. dry_run: every run is a dry run, which saves looks, sale calls, reads and measures and closes and reopens nothing. live: a run closes a finding it sees fixed, which the brand sees at once, and reopens its own close. Only a staffer's word changes it.") })).output(fixCheckSetup.describe("The brand's fix check with its new mode. A run keeps the kind it opened with, and a run still going when the mode changes takes no more saves.")),
22166
22260
  startFixCheckRun: staffChange().input(brandInput.extend({
@@ -22820,7 +22914,7 @@ Windsor builds a report it hasn't stored yet from Amazon, Amazon Ads or TikTok i
22820
22914
  fixCheckBrandRead = defineTool({
22821
22915
  name: "fix_check_brand_read",
22822
22916
  title: "Read a brand's fix check",
22823
- description: `Read a brand's weekly fix check: its mode (off, dry run or live), who timer runs act as (the brand's watch owner; with none, the timer skips the brand), its newest ${fixCheckRules.recentRunLimit} runs with their counts, and what waits for a staffer, up to ${fixCheckRules.waitingLimit} of each with its full count: closes by Goose to confirm, each with the credit and fix day a look proposes; findings a run saw fixed and didn't close; findings the fix check closed that the daily watch has hit since; drafts that return from a finding; measures to approve; and looks that couldn't check. It opens no run.`,
22917
+ description: `Read a brand's weekly fix check: its mode (off, dry run or live), who timer runs act as (the brand's watch owner; with none, the timer skips the brand), its newest ${fixCheckRules.recentRunLimit} runs with their counts, and what waits for a staffer, up to ${fixCheckRules.waitingLimit} of each with its full count: closes by Goose to confirm, each with the credit and fix day a look proposes; findings a run saw fixed and didn't close; findings the fix check closed that the daily watch has hit since; drafts that return from a finding; measures to approve; looks that saw a finding partly fixed, seen too new to be sure, left by the brand or couldn't check, each with how sure it was; and findings with no progress, whose last ${String(fixCheckRules.noProgressWeeks)} weekly looks saw a leftover worth sending whose money hasn't fallen. It opens no run.`,
22824
22918
  effect: "read",
22825
22919
  input: getCallInput(calls$5.readFixCheckBrand),
22826
22920
  run: (backend, input) => backend.readFixCheckBrand(input)
@@ -22897,6 +22991,7 @@ function listLabelsByGroup() {
22897
22991
  var calls$4, reportInput, reportSaveInput, onlyWhenAsked, styleGuide, findingPictureUpload, findingDraftSave, findingVersionMakeCurrent, findingVersionDiscard, findingPublish, findingDiscard, findingDraftTriage, findingDraftSnooze, findingDraftUnsnooze, findingDraftReverify, findingReverifyFinish, findingDraftRestore, findingCloseConfirm, findingUnpublish, findingResolve, findingReopen, findingOutcomeSave, findingOutcomeClear, findingCommentAdd, clientSlackRules, markdownRule, brandSlackFileUpload, brandSlackPost, brandSlackEdit, brandSlackDelete, findingCheckSave, findingMeasureApprove, findingMeasureDecline, findingReportCreate, findingIssueSave, providerCall, providerRuleAdd, reportUpload, reportSave, reportPublish, reportDiscard, reportShare, reportShareStop, auditWordsSave, auditReviewSave, auditReportPublish, watchBrandSave, watchRunStart, watchCheckSave, watchRunFinish, watchFlagWordsSave, fixCheckBrandSave, fixCheckRunStart, fixCheckLookSave, fixCheckWeekSave, fixCheckReadSave, fixCheckMeasurePropose, fixCheckRunFinish, moneyMapSave, dataFolderCreate, dataFileUpload, dataFileUploadConfirm, dataFolderNoteSave;
22898
22992
  var init_change_tools = __esmMin((() => {
22899
22993
  init_finding_reading();
22994
+ init_finding_words();
22900
22995
  init_staff_agent();
22901
22996
  init_staff_fix_check();
22902
22997
  init_staff_labels();
@@ -23323,7 +23418,7 @@ var init_change_tools = __esmMin((() => {
23323
23418
  fixCheckLookSave = defineTool({
23324
23419
  name: "fix_check_look_save",
23325
23420
  title: "Save fix check looks",
23326
- description: `Save up to ${fixCheckRules.lookSaveLimit} looks in a running fix check run, one per finding per run, never changed once saved. A finding whose job is find_fix takes still_open, partly_fixed, fix_seen, brand_decided, fixed or cant_check. One whose job is recheck_fix takes fix_held, partly_fixed, fix_not_held or cant_check. partly_fixed says in proof what is fixed and in note what isn't, fix_seen says in note the week that will prove it, brand_decided holds the brand's words in note, and none of the three changes anything. A fixed look carries its proof line, the credit and the fix day. Where the finding's closesIfFixed is true, it closes the finding by Goose with that proof line, which the brand reads at once, and the close waits for a staffer's confirm. Where closesIfFixed is false (a dry run, a finding reopened and not seen open by a run since, a finding the watch raised), the look is saved, closes nothing and waits for a staffer. A fix_not_held look reopens only a close the fix check made itself, where reopensIfNotHeld is true, and takes draftId null there. Otherwise it changes nothing the brand sees and names in draftId the draft that returns from the finding: the waiting one in returningDraft, the one a staffer discarded, a waiting draft on the same problem that returns from no finding yet, which the server ties to the finding, or a new one saved with finding_draft_save and returnsFromFindingId. A fixed or fix_held look may carry the draft of a new problem the fix created. A fix_held look on a finding with a watchHit says in tried how the watch's read was rerun. fix_check_run_finish waits for a look on every listed finding, so save cant_check with why when one can't be read. ${styleGuide}`,
23421
+ description: `Save up to ${fixCheckRules.lookSaveLimit} looks in a running fix check run, one per finding per run, never changed once saved. A finding whose job is find_fix takes still_open, partly_fixed, fix_seen, brand_decided, fixed or cant_check. One whose job is recheck_fix takes fix_held, partly_fixed, fix_not_held or cant_check. Every look carries sure, 0 to 100: how sure the checker is that the problem it judges is gone, and fixed, fix_held and partly_fixed under ${String(75)} are refused. partly_fixed says in proof what is fixed and in note what isn't, with isLeftWorthSending and leftAmount, the money left a month or null when the finding has no money. In a live run, a leftover not worth sending counts as fixed: a find_fix finding closes by Goose like a fixed look, with proof and then note after "Still left:" as the close reason the brand reads, and a recheck_fix finding doesn't change. A leftover worth sending keeps a find_fix finding as it is, and puts a recheck_fix finding back: one the brand or staff marked fixed goes back to On it, reopened when it was closed, and a close the fix check made reopens; any other changes nothing. fix_seen says in note the week that will prove it and brand_decided holds the brand's words in note, and neither changes anything the brand sees. A fixed look carries its proof line, the credit and the fix day. Where the finding's closesIfFixed is true, it closes the finding by Goose with that proof line, which the brand reads at once, and the close waits for a staffer's confirm. Where closesIfFixed is false (a dry run, a finding reopened and not seen open by a run since, a finding the watch raised), the look is saved, closes nothing and waits for a staffer. A fix_not_held look reopens only a close the fix check made itself, where reopensIfNotHeld is true, and takes draftId null there. Otherwise it changes nothing the brand sees and names in draftId the draft that returns from the finding: the waiting one in returningDraft, the one a staffer discarded, a waiting draft on the same problem that returns from no finding yet, which the server ties to the finding, or a new one saved with finding_draft_save and returnsFromFindingId. A fixed or fix_held look may carry the draft of a new problem the fix created. A fix_held look on a finding with a watchHit says in tried how the watch's read was rerun. fix_check_run_finish waits for a look on every listed finding, so save cant_check with why when one can't be read. ${styleGuide}`,
23327
23422
  effect: "change",
23328
23423
  input: getCallInput(calls$4.saveFixCheckLooks),
23329
23424
  run: (backend, input) => backend.saveFixCheckLooks(input)
@@ -24032,7 +24127,7 @@ var init_staff_rules = __esmMin((() => {
24032
24127
  "- Carrying findings over from earlier work, like when a brand joins: draft only the ones the brand's current numbers still show, publish each with firstFoundAt set to when it was first found, and ask the staffer whether to alert the customer. Put problems that are already fixed in a report, not in findings.",
24033
24128
  "- Fixing an audit report, the ones clients open from their audits page: find it with audits_find, read it with audit_report_read, change its text with audit_words_save and its order or what's shown with audit_review_save. Nothing reaches the client until audit_report_publish, which you call only when the staffer says so, or until staff give a staff-run audit, which ships the same draft.",
24034
24129
  "- A brand's daily watch records its signal checks with watch_run_start, watch_check_save and watch_run_finish; watch_brand_read and watch_history_read show earlier runs and checks, by signal or by run. The server builds each run's signal list, and the run names its money map's cycle, so the server adds a key number for each node that map watches. Each check saves the numbers it read and the calls behind them, and each flag its proof. A flag is leak or know with a draft, monitor (Keep an eye on) with none, or false_alarm when the checker ruled it out. Public-page signals are audit_only: the audit checks them, and the watch never counts them as can't run. Signals that read only tools the brand doesn't use are not_applicable, also never counted as can't run. Watch calls save checks and never publish findings. They close drafts and findings the watch raised once two checks in a row see them fixed on new data, and reopen a finding the watch closed when it comes back; they never close or reopen anything else. A hit on a finding the weekly fix check closed and will reopen is linked as already known. A hit on any other fixed finding is a new draft that names the finding in returnsFromFindingId. When the staffer checks a watch close, bring back a draft it discarded with finding_draft_restore, reopen a finding it closed with finding_reopen, or mark a right close checked with finding_close_confirm. To reword a saved flag's reason, like an unclear line on the Daily watch tab, use watch_flag_words_save only when the staffer says so.",
24035
- "- A brand's weekly fix check runs with fix_check_run_start, fix_check_look_save, fix_check_week_save, fix_check_read_save, fix_check_measure_propose and fix_check_run_finish; fix_check_brand_read and fix_check_looks_read show the mode, earlier runs and looks. A run may close a finding with proof, reopen its own close, save weekly reads, propose a measure and save a draft that returns from a finding. It never publishes, never reopens a person's fix or the watch's close, never records a decision, never changes a published finding's words and never sets its own brand's mode. A staffer confirms each close with finding_close_confirm and its credit, or reopens it with finding_reopen.",
24130
+ "- A brand's weekly fix check runs with fix_check_run_start, fix_check_look_save, fix_check_week_save, fix_check_read_save, fix_check_measure_propose and fix_check_run_finish; fix_check_brand_read and fix_check_looks_read show the mode, earlier runs and looks. A run may close a finding with proof, reopen its own close, save weekly reads, propose a measure and save a draft that returns from a finding. A partly_fixed look whose leftover isn't worth sending closes the finding like a fixed one, and one worth sending puts a finding the brand or staff marked fixed back to On it, reopening it when it was closed. Otherwise it never publishes, never reopens a person's fix or the watch's close, never records a decision, never changes a published finding's words and never sets its own brand's mode. A staffer confirms each close with finding_close_confirm and its credit, or reopens it with finding_reopen.",
24036
24131
  "- A brand's money map is saved once per growth cycle with money_map_save, as learn-brand builds it, and saving that cycle again replaces it. money_map_read reads one cycle's map, or the newest with cycle null. The daily watch and the Scout start from it.",
24037
24132
  "- When you read a brand's data in a chat with a staffer, end with a Save to Goose table. Rows W1, W2… are brand wiki pages to add or update, saved with wiki_write; rows A1, A2… are findings worth drafting, saved only through the /draft-findings skill. Each row says where, what and why. Then save exactly the rows the staffer names. Facts go to the wiki, and problems and tests to findings, never anywhere else: not your own memory or notes, and not your AI app's memory. With nothing worth saving, say so in one line.",
24038
24133
  "- Every call is logged with the staffer's name.",
@@ -26089,7 +26184,7 @@ function nameGroup(inputs, labels, hasVisit) {
26089
26184
  if (matched !== void 0) return matched;
26090
26185
  return hasVisit ? "other" : "no_visit";
26091
26186
  }
26092
- function readAmount$1(order, field) {
26187
+ function readAmount$2(order, field) {
26093
26188
  return toNumber(dig(order, [
26094
26189
  field,
26095
26190
  "shopMoney",
@@ -26105,16 +26200,16 @@ function readShippingTax(order) {
26105
26200
  ]), "A shipping tax line"), 0);
26106
26201
  }
26107
26202
  function readNet(order) {
26108
- const subtotal = readAmount$1(order, "subtotalPriceSet");
26109
- const taxNow = readAmount$1(order, "currentTotalTaxSet");
26110
- const refundedShipping = readAmount$1(order, "totalRefundedShippingSet");
26111
- const refundedBesidesShipping = readAmount$1(order, "totalRefundedSet") - refundedShipping;
26203
+ const subtotal = readAmount$2(order, "subtotalPriceSet");
26204
+ const taxNow = readAmount$2(order, "currentTotalTaxSet");
26205
+ const refundedShipping = readAmount$2(order, "totalRefundedShippingSet");
26206
+ const refundedBesidesShipping = readAmount$2(order, "totalRefundedSet") - refundedShipping;
26112
26207
  if (order.taxesIncluded === false) {
26113
- const refundedTax = readAmount$1(order, "totalTaxSet") - taxNow;
26208
+ const refundedTax = readAmount$2(order, "totalTaxSet") - taxNow;
26114
26209
  return Math.max(0, subtotal - Math.max(0, refundedBesidesShipping - refundedTax));
26115
26210
  }
26116
26211
  if (order.taxesIncluded !== true) throw new Error(`Order ${readText$3(order, "id")} doesn't say whether its prices include tax.`);
26117
- const shipping = readAmount$1(order, "totalShippingPriceSet");
26212
+ const shipping = readAmount$2(order, "totalShippingPriceSet");
26118
26213
  const shippingTaxNow = shipping > 0 ? readShippingTax(order) * Math.max(0, 1 - refundedShipping / shipping) : 0;
26119
26214
  return Math.max(0, subtotal - Math.max(0, refundedBesidesShipping) - (taxNow - shippingTaxNow));
26120
26215
  }
@@ -26124,7 +26219,7 @@ function nameLeftOut(inputs, order, day, source) {
26124
26219
  if (order.test === true) return "test";
26125
26220
  if (typeof order.cancelledAt === "string") return "cancelled";
26126
26221
  if (!paidStatuses.includes(readText$3(order, "displayFinancialStatus"))) return "notPaid";
26127
- if (readAmount$1(order, "totalPriceSet") <= 0) return "zeroDollar";
26222
+ if (readAmount$2(order, "totalPriceSet") <= 0) return "zeroDollar";
26128
26223
  if (inputs.outsideStore.includes(source)) return "outsideStore";
26129
26224
  }
26130
26225
  function readOrderIndex(row) {
@@ -26564,7 +26659,7 @@ var init_meta_tables_shape = __esmMin((() => {
26564
26659
  };
26565
26660
  }));
26566
26661
  // src/harness/check-calls.ts
26567
- var check_calls_exports = /* @__PURE__ */ __exportAll({ run: () => run$23 });
26662
+ var check_calls_exports = /* @__PURE__ */ __exportAll({ run: () => run$24 });
26568
26663
  function checkEntry(entry, name, provider) {
26569
26664
  const id = readText$3(entry, "id");
26570
26665
  const problems = [];
@@ -26600,7 +26695,7 @@ function checkFile(fileName) {
26600
26695
  problems: [...entries.flatMap((entry) => checkEntry(entry, name, provider)), ...leaked === null ? [] : [`${fileName} holds the number ${leaked[0]}, which looks like a brand's own id. Write a named placeholder like <ad account id>.`]]
26601
26696
  };
26602
26697
  }
26603
- function run$23() {
26698
+ function run$24() {
26604
26699
  const files = readdirSync(callsFolder$1).filter((fileName) => fileName.endsWith(".json"));
26605
26700
  const checked = files.map(checkFile);
26606
26701
  const calls = checked.flatMap((file) => file.calls);
@@ -26641,8 +26736,8 @@ var init_check_calls = __esmMin((() => {
26641
26736
  longNumber = /[0-9]{7,}/u;
26642
26737
  }));
26643
26738
  // src/harness/check-generators.ts
26644
- var check_generators_exports = /* @__PURE__ */ __exportAll({ run: () => run$22 });
26645
- function run$22() {
26739
+ var check_generators_exports = /* @__PURE__ */ __exportAll({ run: () => run$23 });
26740
+ function run$23() {
26646
26741
  const files = readdirSync(join(harnessFolder$1, "catalog", "generators")).filter((name) => name.endsWith(".md")).map((name) => basename(name, ".md"));
26647
26742
  const current = generatorNames;
26648
26743
  const retired = retiredGeneratorNames;
@@ -37257,7 +37352,7 @@ var init_tree_walk_check = __esmMin((() => {
37257
37352
  walkTrees = /* @__PURE__ */ new Map();
37258
37353
  }));
37259
37354
  // src/harness/check-handoff.ts
37260
- var check_handoff_exports = /* @__PURE__ */ __exportAll({ run: () => run$21 });
37355
+ var check_handoff_exports = /* @__PURE__ */ __exportAll({ run: () => run$22 });
37261
37356
  function checkKind(kind, value) {
37262
37357
  return checkAgainstSchema(join(schemaFolder$1, `${kind}.schema.json`), value, kind);
37263
37358
  }
@@ -37273,7 +37368,7 @@ function countDays(window) {
37273
37368
  const { since, until } = readWindowEnds(window);
37274
37369
  return (Date.parse(until) - Date.parse(since)) / dayLength + 1;
37275
37370
  }
37276
- function readAmount(source, field) {
37371
+ function readAmount$1(source, field) {
37277
37372
  const value = readField(source, field);
37278
37373
  if (typeof value !== "number") throw new Error(`${field} should be a number.`);
37279
37374
  return value;
@@ -37819,6 +37914,10 @@ function readGroupKeys(file, group) {
37819
37914
  const gateFile = join(dirname(file), "..", "gate.json");
37820
37915
  if (!existsSync(gateFile)) return void 0;
37821
37916
  if (group === "money_map") return readList$1(readJson$1(gateFile), "mapNodes").map((node) => readText$3(node, "key"));
37917
+ if (group.startsWith(`money_map-`)) {
37918
+ const mapGroup = readList$1(readJson$1(gateFile), "mapGroups").find((candidate) => readText$3(candidate, "id") === group);
37919
+ return mapGroup === void 0 ? [] : readTexts(mapGroup, "nodes");
37920
+ }
37822
37921
  const entry = readList$1(readJson$1(gateFile), "groups").find((candidate) => readText$3(candidate, "id") === group);
37823
37922
  if (entry === void 0) return [];
37824
37923
  return readList$1(entry, "signals").map((signal) => readText$3(signal, "key"));
@@ -37876,8 +37975,8 @@ function checkWatchVerdict(value) {
37876
37975
  const verdict = readText$3(value, "verdict");
37877
37976
  const draft = readField(value, "draft");
37878
37977
  const scores = readField(value, "scores");
37879
- const sureItsReal = readAmount(scores, "sureItsReal");
37880
- const sureOfCause = readAmount(scores, "sureOfCause");
37978
+ const sureItsReal = readAmount$1(scores, "sureItsReal");
37979
+ const sureOfCause = readAmount$1(scores, "sureOfCause");
37881
37980
  if (verdict !== "leak" && verdict !== "know") return draft === null ? [] : [`A ${verdict} verdict has no draft; set draft to null.`];
37882
37981
  const problems = [];
37883
37982
  if (draft === null) problems.push(`A ${verdict} verdict needs its draft.`);
@@ -37888,8 +37987,8 @@ function checkWatchVerdict(value) {
37888
37987
  "sureOfCause",
37889
37988
  "sureOfSize"
37890
37989
  ]) {
37891
- const given = readAmount(scores, score);
37892
- if (readAmount(readField(draft, score), "score") !== given) problems.push(`The draft's ${score} score should be ${given}, like scores.${score}.`);
37990
+ const given = readAmount$1(scores, score);
37991
+ if (readAmount$1(readField(draft, score), "score") !== given) problems.push(`The draft's ${score} score should be ${given}, like scores.${score}.`);
37893
37992
  }
37894
37993
  problems.push(...checkTrail("draft", draft));
37895
37994
  problems.push(...listShownFirstProblems(readList$1(draft, "evidence")));
@@ -37977,14 +38076,14 @@ function listUpdateProblems(update, facts) {
37977
38076
  if (moved.includes("cause") && readField(facts.size, "cause") === null) problems.push("update.moved holds cause, so size.cause names the cause now.");
37978
38077
  const money = readField(update, "monthlyDollars");
37979
38078
  if (moved.includes("size") && money === null) problems.push("update.moved holds size, so update.monthlyDollars holds the new money.");
37980
- if (money !== null && readAmount(money, "low") > readAmount(money, "high")) problems.push("update.monthlyDollars low is above its high.");
38079
+ if (money !== null && readAmount$1(money, "low") > readAmount$1(money, "high")) problems.push("update.monthlyDollars low is above its high.");
37981
38080
  for (const score of [
37982
38081
  "sureItsReal",
37983
38082
  "sureOfCause",
37984
38083
  "sureOfSize"
37985
38084
  ]) {
37986
- const given = readAmount(facts.scores, score);
37987
- if (readAmount(readField(update, score), "score") !== given) problems.push(`update.${score} score should be ${String(given)}, like scores.${score}.`);
38085
+ const given = readAmount$1(facts.scores, score);
38086
+ if (readAmount$1(readField(update, score), "score") !== given) problems.push(`update.${score} score should be ${String(given)}, like scores.${score}.`);
37988
38087
  }
37989
38088
  return problems;
37990
38089
  }
@@ -37994,7 +38093,7 @@ function checkReverifyVerdict(value) {
37994
38093
  const update = readField(value, "update");
37995
38094
  const reruns = readList$1(value, "reruns");
37996
38095
  const readsOn = reruns.map((rerun) => readText$3(rerun, "on"));
37997
- const isUnderBar = readAmount(scores, "sureItsReal") < 75 || readAmount(scores, "sureOfCause") < 75;
38096
+ const isUnderBar = readAmount$1(scores, "sureItsReal") < 75 || readAmount$1(scores, "sureOfCause") < 75;
37998
38097
  const ownReads = reruns.filter((rerun) => readText$3(rerun, "on") !== "today" && readField(rerun, "was") !== null);
37999
38098
  const hasMovedNumber = ownReads.some((rerun) => readField(rerun, "isSame") === false);
38000
38099
  const size = readField(value, "size");
@@ -38047,7 +38146,7 @@ function listMondaysBefore(day, count) {
38047
38146
  return Array.from({ length: count }, (_slot, index) => addDays(monday, -7 * (count - index)));
38048
38147
  }
38049
38148
  function isDay(value) {
38050
- return typeof value === "string" && dayPattern.test(value) && isRealDay(value);
38149
+ return typeof value === "string" && dayPattern$1.test(value) && isRealDay(value);
38051
38150
  }
38052
38151
  function readRunStart(startFile) {
38053
38152
  const start = readJson$1(startFile);
@@ -38203,7 +38302,7 @@ function listProofWeekProblems(value, start, entry) {
38203
38302
  const week = readField(value, "week");
38204
38303
  if (week === null) {
38205
38304
  const verdict = readText$3(value, "verdict");
38206
- return (verdict === "fixed" || verdict === "fix_not_held") && readField(value, "proofKind") === "numbers" ? [`A ${verdict} verdict on numbers needs week: the whole settled week it rests on, after the fix and never a sale week. fixed and fix_not_held both act on the brand's page in a live run.`] : [];
38305
+ return isActingOnNumbers(value) ? [`A ${verdict} verdict on numbers needs week: the whole settled week it rests on, after the fix and never a sale week. fixed, partly_fixed and fix_not_held all act on the brand's page in a live run.`] : [];
38207
38306
  }
38208
38307
  const weekStart = readText$3(week, "weekStart");
38209
38308
  const weekEnd = readText$3(week, "weekEnd");
@@ -38211,15 +38310,15 @@ function listProofWeekProblems(value, start, entry) {
38211
38310
  if (listed === void 0) return [`week runs ${weekStart} to ${weekEnd}, which isn't one of start.json's weeks. Take a whole week's first and last day from there.`];
38212
38311
  const fixDay = readProofFixDay(value, entry);
38213
38312
  const problems = [];
38214
- if (fixDay === null) problems.push("list.json gives this finding no fix day, in measuring.fixedOn or fixedAt, so no week can be shown to come after its fix. Send cant_check, with that in note.");
38215
- else if (weekStart <= fixDay.day) problems.push(`week starts on ${weekStart}, which isn't after the fix day, ${fixDay.day}, from ${fixDay.from}. Rest the verdict on a whole week that starts after it.`);
38313
+ if (fixDay === null && readText$3(value, "verdict") !== "partly_fixed") problems.push("list.json gives this finding no fix day, in measuring.fixedOn or fixedAt, so no week can be shown to come after its fix. Send cant_check, with that in note.");
38314
+ else if (fixDay !== null && weekStart <= fixDay.day) problems.push(`week starts on ${weekStart}, which isn't after the fix day, ${fixDay.day}, from ${fixDay.from}. Rest the verdict on a whole week that starts after it.`);
38216
38315
  if (isSaleCall(listed.call)) problems.push(`start.json holds a sale call for the week of ${weekStart}, and a sale week proves nothing either way. Rest the verdict on a week that isn't one.`);
38217
38316
  if (holdsBlackFriday(weekStart, weekEnd)) problems.push(`The week of ${weekStart} holds a day from Black Friday to Cyber Monday, and a sale week proves nothing either way. Rest the verdict on a week that isn't one.`);
38218
38317
  return problems;
38219
38318
  }
38220
38319
  function listGoneProblems(verdict, value, results) {
38221
38320
  const problems = [];
38222
- if (results.some((result) => result !== "clean")) problems.push(`A ${verdict} verdict needs every rerun to read clean, the watch's included. A gap proves nothing and a still_there one shows the problem: give the verdict those reads support.`);
38321
+ if (results.includes("still_there")) problems.push(`A ${verdict} verdict needs no rerun that reads still_there, the watch's included: one that shows the problem makes it still_open, partly_fixed or fix_not_held. A gap only lowers sure.`);
38223
38322
  if (readList$1(value, "stillThere").length === 0) problems.push(`A ${verdict} verdict lists in stillThere each try to find the problem still there.`);
38224
38323
  if (readList$1(value, "touched").length === 0) problems.push(`A ${verdict} verdict lists in touched each thing the fix touched, as checked.`);
38225
38324
  return problems;
@@ -38237,8 +38336,7 @@ function readJudgedWeeks(runFolder) {
38237
38336
  return judged;
38238
38337
  }
38239
38338
  function isActingOnNumbers(value) {
38240
- const verdict = readText$3(value, "verdict");
38241
- return (verdict === "fixed" || verdict === "fix_not_held") && readField(value, "proofKind") === "numbers";
38339
+ return numbersActingVerdicts.has(readText$3(value, "verdict")) && readField(value, "proofKind") === "numbers";
38242
38340
  }
38243
38341
  function listJudgedWeekProblems(value, start, judged, isSending) {
38244
38342
  const week = readField(value, "week");
@@ -38252,6 +38350,30 @@ function listJudgedWeekProblems(value, start, judged, isSending) {
38252
38350
  if (!isSending || isSaleWeek === false || !isActingOnNumbers(value)) return [];
38253
38351
  return [`No call judges the week of ${weekStart}: start.json holds none, and weeks.json doesn't call it normal. A ${readText$3(value, "verdict")} look on numbers waits until its week is judged, as weeks.md's proof weeks says. A week left unjudged sends cant_check, with why in note.`];
38254
38352
  }
38353
+ function readSure(value) {
38354
+ const sure = readField(value, "sure");
38355
+ return typeof sure === "number" && Number.isInteger(sure) && sure >= 0 && sure <= 100 ? sure : null;
38356
+ }
38357
+ function listCantCheckProblems(value, results, sure) {
38358
+ const isBack = results.includes("still_there");
38359
+ const isRecheck = readText$3(value, "job") === "recheck_fix";
38360
+ if (results.every((result) => result === "gap")) return [];
38361
+ if (isRecheck && !isBack && sure < 75) return [];
38362
+ return [isRecheck ? `A cant_check verdict is for reads that say nothing either way, or on recheck_fix for sure under ${String(75)} with no read showing the problem back. A read here leans one way: give the verdict it supports, with its sure.` : "A cant_check verdict is for reads that say nothing either way. A read here leans one way: give the verdict it supports, with its sure, and still_open when the reads leave sure under the Sure line."];
38363
+ }
38364
+ function listSureVerdictProblems(value, results, sure) {
38365
+ const verdict = readText$3(value, "verdict");
38366
+ const isBack = results.includes("still_there");
38367
+ const problems = [];
38368
+ if ((verdict === "fixed" || verdict === "fix_held" || verdict === "partly_fixed") && sure < 75) problems.push(verdict === "partly_fixed" ? `A partly_fixed verdict needs sure at ${String(75)} or more that its fixed part is fixed, and it is ${String(sure)}. Under it, nothing is fixed: still_open on find_fix, cant_check on recheck_fix unless a read shows the problem back.` : `A ${verdict} verdict needs sure at ${String(75)} or more, and it is ${String(sure)}. Under it nothing is fixed: still_open on find_fix, cant_check on recheck_fix unless a read shows the problem back.`);
38369
+ if (verdict === "still_open" && !isBack && sure >= 75) problems.push(`A still_open verdict with no rerun that reads still_there is for reads that leave sure under ${String(75)}, and it is ${String(sure)}. Reads that make you sure the problem is gone give fixed, or fix_seen for numbers with no whole settled week since the fix yet.`);
38370
+ if (verdict === "cant_check") problems.push(...listCantCheckProblems(value, results, sure));
38371
+ return problems;
38372
+ }
38373
+ function listWrongIfProblems(value) {
38374
+ const last = readTexts(value, "stillThere").at(-1);
38375
+ return last === void 0 || last.startsWith("Wrong if:") ? [] : ["stillThere's last line begins Wrong if: and names the read that would overturn the verdict and what it would show."];
38376
+ }
38255
38377
  function listLookRerunProblems(value, entry) {
38256
38378
  const verdict = readText$3(value, "verdict");
38257
38379
  const watchRerun = readField(value, "watchRerun");
@@ -38261,17 +38383,34 @@ function listLookRerunProblems(value, entry) {
38261
38383
  const isGone = verdict === "fixed" || verdict === "fix_held";
38262
38384
  const hasRuledOut = readList$1(value, "ruledOut").length > 0;
38263
38385
  const needsWatchRerun = readField(entry, "watchHit") !== null && (verdict === "fix_held" || verdict === "fix_not_held");
38386
+ const sure = readSure(value);
38264
38387
  const problems = isGone ? listGoneProblems(verdict, value, results) : [];
38388
+ if (sure === null) problems.push("sure is a whole number from 0 to 100: how sure you are the problem is gone.");
38389
+ else problems.push(...listSureVerdictProblems(value, results, sure));
38265
38390
  if (verdict === "fix_not_held" && !isBack) problems.push("A fix_not_held verdict needs a rerun that reads still_there: the read that shows the problem back.");
38266
38391
  if (verdict === "fix_not_held" && !hasRuledOut) problems.push("A fix_not_held verdict lists in ruledOut each other explanation tested, and the counter-case.");
38267
38392
  if (!isBack && hasRuledOut) problems.push("ruledOut holds lines only when a rerun reads still_there. Empty it.");
38268
- if ((verdict === "still_open" || verdict === "brand_decided") && !isBack) problems.push(`A ${verdict} verdict needs a rerun that reads still_there: the read that shows the problem, wherever it was found. Numbers that all read clean with no whole settled week since the fix yet are fix_seen. With no read that shows the problem, the verdict is cant_check with why in note: the server reads ${verdict} as the problem seen open.`);
38393
+ if (verdict === "brand_decided" && !isBack) problems.push("A brand_decided verdict needs a rerun that reads still_there: the read that shows the problem the brand chose to leave.");
38269
38394
  if (verdict === "partly_fixed" && !(isBack && results.includes("clean"))) problems.push("A partly_fixed verdict needs a rerun that reads clean, for the part that is fixed, and one that reads still_there, for the part that isn't.");
38270
- if (verdict === "fix_seen" && (readField(value, "proofKind") !== "numbers" || results.some((result) => result !== "clean"))) problems.push("A fix_seen verdict is for numbers alone, with every rerun clean: a rerun that reads still_there makes it still_open or partly_fixed, and a gap makes it cant_check.");
38395
+ if ((verdict === "fixed" || verdict === "fix_held" || verdict === "fix_seen") && !results.includes("clean")) problems.push(`A ${verdict} verdict needs at least one rerun that reads clean, the watch's included: a gap shows nothing either way, so reads that are all gaps are cant_check whatever sure says.`);
38396
+ if (verdict === "fix_seen" && (readField(value, "proofKind") !== "numbers" || isBack)) problems.push("A fix_seen verdict is for numbers alone, with no rerun that reads still_there: one that does makes it still_open or partly_fixed. A gap only lowers sure.");
38271
38397
  if (isBack && !isGone && readList$1(value, "stillThere").length + readList$1(value, "touched").length > 0) problems.push("A rerun reads still_there, so stillThere and touched stay empty.");
38398
+ if (verdict !== "cant_check") problems.push(...listWrongIfProblems(value));
38272
38399
  if (needsWatchRerun !== (watchRerun !== null)) problems.push(needsWatchRerun ? "This finding has a watchHit in list.json, so watchRerun holds the watch's own read, made again." : "watchRerun is set only on a fix_held or fix_not_held verdict of a finding with a watchHit. Set it to null.");
38273
38400
  return problems;
38274
38401
  }
38402
+ function listPartlyLeftProblems(value, worthField) {
38403
+ const verdict = readText$3(value, "verdict");
38404
+ const worth = readField(value, worthField);
38405
+ const amount = readField(value, "leftAmount");
38406
+ if (verdict !== "partly_fixed") return [worthField, "leftAmount"].filter((part) => readField(value, part) !== null).map((part) => `A ${verdict} verdict takes ${part} null. Send it only on partly_fixed.`);
38407
+ if (typeof worth !== "boolean") return [`A partly_fixed verdict needs ${worthField}: whether what's left would be worth sending as a finding of its own.`];
38408
+ const problems = [];
38409
+ if (amount !== null && readText$3(amount, "period") !== "month") problems.push("leftAmount's period is month: what's left costs it each month.");
38410
+ const note = readField(value, "note");
38411
+ if (!worth && typeof note === "string") problems.push(...listClientNoteStyleProblems(note).map((problem) => `note, the Still left line the brand reads: ${problem}`));
38412
+ return problems;
38413
+ }
38275
38414
  function listReturningDraftProblems(returning, returningDraft) {
38276
38415
  const use = readText$3(returning, "use");
38277
38416
  if (returningDraft === null) return use === "new" ? [] : ["This finding has no returningDraft, so returning.use is new."];
@@ -38301,8 +38440,8 @@ function listLookDraftProblems(value, entry) {
38301
38440
  if (owesDraft !== (draft !== null)) return [owesDraft ? "This verdict owes a draft, since returning.use is new or newProblem is set: write its facts in draft." : "draft is set only when returning.use is new or newProblem is set. Set it to null."];
38302
38441
  if (draft === null) return [];
38303
38442
  const measure = readField(draft, "measure");
38304
- const sureItsReal = readAmount(readField(draft, "sureItsReal"), "score");
38305
- const sureOfCause = readAmount(readField(draft, "sureOfCause"), "score");
38443
+ const sureItsReal = readAmount$1(readField(draft, "sureItsReal"), "score");
38444
+ const sureOfCause = readAmount$1(readField(draft, "sureOfCause"), "score");
38306
38445
  const problems = [
38307
38446
  ...checkTrail("draft", draft),
38308
38447
  ...listShownFirstProblems(readList$1(draft, "evidence")),
@@ -38332,6 +38471,7 @@ function checkFixCheckVerdict(file, value) {
38332
38471
  ...listProofWeekProblems(value, start, entry),
38333
38472
  ...listJudgedWeekProblems(value, start, readJudgedWeeks(runFolder), false),
38334
38473
  ...listLookRerunProblems(value, entry),
38474
+ ...listPartlyLeftProblems(value, "leftWorthSending"),
38335
38475
  ...listReturningProblems(value, entry),
38336
38476
  ...listLookDraftProblems(value, entry)
38337
38477
  ];
@@ -38406,12 +38546,18 @@ function listLookDraftIds(source, entry, handBackFile) {
38406
38546
  function listBuiltLookProblems(where, look, source) {
38407
38547
  const problems = [];
38408
38548
  if (toCanonical(readField(look, "tried")) !== toCanonical(listTriedLines(source))) problems.push(`${where} takes tried from its checker's file: watchRerun and each rerun as "<read> (<result>): <saw>", then ruledOut, stillThere and touched, each line as written.`);
38409
- if (readText$3(look, "verdict") === "cant_check") return problems;
38549
+ if (readText$3(look, "verdict") === "cant_check") {
38550
+ const sure = readText$3(source, "verdict") === "cant_check" ? readField(source, "sure") : 0;
38551
+ return readField(look, "sure") === sure ? problems : [...problems, `${where} is cant_check, so its sure is ${String(sure)}: its checker's file's sure on a cant_check file, else 0.`];
38552
+ }
38410
38553
  const expected = [
38411
38554
  ["proof", readField(source, "proof")],
38412
38555
  ["credit", toLookCredit(readField(source, "credit"))],
38413
38556
  ["fixedOn", readField(source, "fixedOn")],
38414
- ["note", readField(source, "note")]
38557
+ ["note", readField(source, "note")],
38558
+ ["sure", readField(source, "sure")],
38559
+ ["isLeftWorthSending", readField(source, "leftWorthSending")],
38560
+ ["leftAmount", readField(source, "leftAmount")]
38415
38561
  ];
38416
38562
  return [...problems, ...expected.filter(([part, written]) => toCanonical(readField(look, part)) !== toCanonical(written)).map(([part]) => `${where} takes ${part} from its checker's file, as written there.`)];
38417
38563
  }
@@ -38422,9 +38568,12 @@ function listLookSourceProblems(look, sources) {
38422
38568
  const where = `The look for ${findingId}`;
38423
38569
  const entry = entries.find((candidate) => readText$3(candidate, "findingId") === findingId);
38424
38570
  if (entry === void 0) return [`${where} names a finding that isn't in list.json.`];
38425
- const parts = listLookPartProblems(look).map((problem) => `${where}: ${problem}`);
38571
+ const parts = [...listLookPartProblems(look), ...listPartlyLeftProblems(look, "isLeftWorthSending")].map((problem) => `${where}: ${problem}`);
38426
38572
  const checked = readCheckerFile(join(runFolder, "checks", `${findingId}.json`));
38427
- if (checked.problems.length > 0) return verdict === "cant_check" ? parts : [...parts, `${where} is ${verdict}, and its checker's file doesn't pass as fix-check-verdict: ${checked.problems.join(" ")} Only a checker's file that passes builds a look: send cant_check, with why in note.`];
38573
+ if (checked.problems.length > 0) {
38574
+ const unbuilt = verdict === "cant_check" && readField(look, "sure") !== 0 ? [`${where} is built with no checker's file that passed, so its sure is 0, not ${String(readField(look, "sure"))}.`] : [];
38575
+ return verdict === "cant_check" ? [...parts, ...unbuilt] : [...parts, `${where} is ${verdict}, and its checker's file doesn't pass as fix-check-verdict: ${checked.problems.join(" ")} Only a checker's file that passes builds a look: send cant_check, with why in note.`];
38576
+ }
38428
38577
  const source = checked.value;
38429
38578
  const written = readText$3(source, "verdict");
38430
38579
  if (verdict !== written && verdict !== "cant_check") return [...parts, `${where} is ${verdict}, and its checker's file says ${written}. Send the file's verdict, or cant_check with why in note.`];
@@ -38892,13 +39041,13 @@ function listFileProblems$1(kind, file, answerPath) {
38892
39041
  const schemaProblems = checkKind("money-map", value);
38893
39042
  return schemaProblems.length > 0 ? schemaProblems : checkScoutMap(value, resolve(answerPath));
38894
39043
  }
38895
- if (!handoffKinds.includes(kind) || answerPath !== void 0) throw new Error(usage$8);
39044
+ if (!handoffKinds.includes(kind) || answerPath !== void 0) throw new Error(usage$9);
38896
39045
  const schemaProblems = checkKind(kind, value);
38897
39046
  return schemaProblems.length > 0 ? schemaProblems : checkRules(kind, file, value);
38898
39047
  }
38899
- function run$21(args) {
39048
+ function run$22(args) {
38900
39049
  const [kind, path, answerPath] = args;
38901
- if (kind === void 0 || path === void 0) throw new Error(usage$8);
39050
+ if (kind === void 0 || path === void 0) throw new Error(usage$9);
38902
39051
  const file = resolve(path);
38903
39052
  const problems = listFileProblems$1(kind, file, answerPath);
38904
39053
  if (problems.length > 0) {
@@ -38907,7 +39056,7 @@ function run$21(args) {
38907
39056
  process.exitCode = 1;
38908
39057
  } else console.log(`${file} passes as ${kind}.`);
38909
39058
  }
38910
- var schemaFolder$1, reasonLimit$1, readerGroupLimit, plainLineWords, sanityGapPct, numbersReadDays, dayLength, uuidPattern$1, dayPattern, generatorFolder, investigationFolder, nodelessCats, unreachedBases, findingLevels, leakBases, testedProposals, levelOrder, findingBarLines, betSharedLines, newFails, betLines, streamRoles, testLines, unprovenBarLines, lookAsks, shortNoteVerdicts, shortNoteLimit, widestZoneLead, callFields, raisedFields, mapFields, usage$8;
39059
+ var schemaFolder$1, reasonLimit$1, readerGroupLimit, plainLineWords, sanityGapPct, numbersReadDays, dayLength, uuidPattern$1, dayPattern$1, generatorFolder, investigationFolder, nodelessCats, unreachedBases, findingLevels, leakBases, testedProposals, levelOrder, findingBarLines, betSharedLines, newFails, betLines, streamRoles, testLines, unprovenBarLines, lookAsks, shortNoteVerdicts, shortNoteLimit, widestZoneLead, numbersActingVerdicts, callFields, raisedFields, mapFields, usage$9;
38911
39060
  var init_check_handoff = __esmMin((() => {
38912
39061
  init_finding_words();
38913
39062
  init_finding_style_text();
@@ -38930,7 +39079,7 @@ var init_check_handoff = __esmMin((() => {
38930
39079
  numbersReadDays = 31;
38931
39080
  dayLength = 864e5;
38932
39081
  uuidPattern$1 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
38933
- dayPattern = /^\d{4}-\d{2}-\d{2}$/;
39082
+ dayPattern$1 = /^\d{4}-\d{2}-\d{2}$/;
38934
39083
  generatorFolder = fromHarness("catalog", "generators");
38935
39084
  investigationFolder = fromHarness("catalog", "investigations");
38936
39085
  nodelessCats = [
@@ -39009,6 +39158,11 @@ var init_check_handoff = __esmMin((() => {
39009
39158
  ]);
39010
39159
  shortNoteLimit = 500;
39011
39160
  widestZoneLead = 504e5;
39161
+ numbersActingVerdicts = /* @__PURE__ */ new Set([
39162
+ "fixed",
39163
+ "partly_fixed",
39164
+ "fix_not_held"
39165
+ ]);
39012
39166
  callFields = /* @__PURE__ */ new Map([["numbers_read", [
39013
39167
  "brandId",
39014
39168
  "table",
@@ -39035,7 +39189,7 @@ var init_check_handoff = __esmMin((() => {
39035
39189
  "window",
39036
39190
  "rates"
39037
39191
  ];
39038
- usage$8 = `Run it as: goose-staff harness check-handoff <${handoffKinds.join("|")}> <file>, or goose-staff harness check-handoff ${scoutMapKind} <money-map.json> <money-map-read.json>`;
39192
+ usage$9 = `Run it as: goose-staff harness check-handoff <${handoffKinds.join("|")}> <file>, or goose-staff harness check-handoff ${scoutMapKind} <money-map.json> <money-map-read.json>`;
39039
39193
  }));
39040
39194
  // ../../packages/contract/src/signal-map/signals.json
39041
39195
  var signals_default = {
@@ -43441,7 +43595,7 @@ var init_leak_library = __esmMin((() => {
43441
43595
  wiki$1 = loadWiki(readWikiFiles(readWikiFolder()));
43442
43596
  }));
43443
43597
  // src/harness/check-leaks.ts
43444
- var check_leaks_exports = /* @__PURE__ */ __exportAll({ run: () => run$20 });
43598
+ var check_leaks_exports = /* @__PURE__ */ __exportAll({ run: () => run$21 });
43445
43599
  function readSignals$2() {
43446
43600
  return readList$1(signals_default, "signals").map((signal) => ({
43447
43601
  key: readText$3(signal, "key"),
@@ -43498,7 +43652,7 @@ function checkStage(value) {
43498
43652
  problems
43499
43653
  };
43500
43654
  }
43501
- function run$20() {
43655
+ function run$21() {
43502
43656
  const library = readLeakStages();
43503
43657
  if (library.length === 0) throw new Error(`${leakLibraryAddress} holds no stage.`);
43504
43658
  const checked = library.map(checkStage);
@@ -43527,7 +43681,7 @@ var init_check_leaks = __esmMin((() => {
43527
43681
  schemaFile$1 = join(fromHarness(), "schema", "leaks.schema.json");
43528
43682
  }));
43529
43683
  // src/harness/check-limits.ts
43530
- var check_limits_exports = /* @__PURE__ */ __exportAll({ run: () => run$19 });
43684
+ var check_limits_exports = /* @__PURE__ */ __exportAll({ run: () => run$20 });
43531
43685
  function listStepLimits(schema, sourcePath) {
43532
43686
  return [
43533
43687
  {
@@ -43741,7 +43895,7 @@ function listMeasureShapeProblems() {
43741
43895
  return others.filter((schema) => toCanonical(readSchemaNode(schema, ["$defs", part])) !== shape).map((schema) => `${schema}.schema.json $defs.${part} differs from ${first}.schema.json's. The measure has one shape: keep the copies the same.`);
43742
43896
  });
43743
43897
  }
43744
- function run$19() {
43898
+ function run$20() {
43745
43899
  const sums = listSums();
43746
43900
  const shapeProblems = [...listOptionProblems(), ...listMeasureShapeProblems()];
43747
43901
  const drifted = [
@@ -44051,7 +44205,7 @@ var init_check_limits = __esmMin((() => {
44051
44205
  ];
44052
44206
  }));
44053
44207
  // src/harness/check-map.ts
44054
- var check_map_exports = /* @__PURE__ */ __exportAll({ run: () => run$18 });
44208
+ var check_map_exports = /* @__PURE__ */ __exportAll({ run: () => run$19 });
44055
44209
  function has(record, field) {
44056
44210
  const value = record.fields[field];
44057
44211
  return value !== void 0 && value !== null;
@@ -44276,7 +44430,7 @@ function describeMap(questions, context) {
44276
44430
  const calls = new Set(questions.flatMap((question) => readWords$1(question.record, "calls")).filter((read) => !read.startsWith(tablePrefix)));
44277
44431
  return `${mapAddress} holds ${countTier(questions, "ground")} ground rules, ${countTier(questions, "first")} first-pass checks and ${countTier(questions, "deep")} deep questions, with ${String(context.branches.length)} branches. They name ${String(calls.size)} calls from catalog/calls and list ${String(context.proofs.length)} reads still to prove, with every id, layer, count, table and source resolved and no brand's own ids.`;
44278
44432
  }
44279
- function run$18() {
44433
+ function run$19() {
44280
44434
  const questions = listCatalogRecords(wiki, `${mapAddress}#questions`).map((record) => ({
44281
44435
  id: record.id,
44282
44436
  entry: readWord$1(record, "entry"),
@@ -44414,7 +44568,7 @@ var init_check_map = __esmMin((() => {
44414
44568
  wiki = loadWiki(readWikiFiles(readWikiFolder()));
44415
44569
  }));
44416
44570
  // src/harness/check-skills.ts
44417
- var check_skills_exports = /* @__PURE__ */ __exportAll({ run: () => run$17 });
44571
+ var check_skills_exports = /* @__PURE__ */ __exportAll({ run: () => run$18 });
44418
44572
  function showPath$2(path) {
44419
44573
  return relative(stackRoot, path);
44420
44574
  }
@@ -44680,7 +44834,7 @@ function checkReference(path) {
44680
44834
  ...checkLinks(page)
44681
44835
  ];
44682
44836
  }
44683
- function run$17() {
44837
+ function run$18() {
44684
44838
  const skills = readFolder(skillsFolder);
44685
44839
  if (skills.folders.length === 0) throw new Error(`${showPath$2(skillsFolder)} holds no skill.`);
44686
44840
  const agents = readFolder(agentsFolder);
@@ -45283,7 +45437,7 @@ var init_signal_map = __esmMin((() => {
45283
45437
  new Map(signalMap.signals.map((signal) => [signal.key, signal]));
45284
45438
  }));
45285
45439
  // src/harness/check-watch-list.ts
45286
- var check_watch_list_exports = /* @__PURE__ */ __exportAll({ run: () => run$16 });
45440
+ var check_watch_list_exports = /* @__PURE__ */ __exportAll({ run: () => run$17 });
45287
45441
  function checkGuides(groups) {
45288
45442
  const vendors = groups.flatMap((group) => group.vendors);
45289
45443
  const named = new Set(vendors.flatMap((vendor) => vendor.guide === null ? [] : [vendor.guide]));
@@ -45297,7 +45451,7 @@ function checkGuides(groups) {
45297
45451
  }
45298
45452
  return problems;
45299
45453
  }
45300
- function run$16() {
45454
+ function run$17() {
45301
45455
  const problems = checkGuides(signalMap.groups);
45302
45456
  if (problems.length > 0) {
45303
45457
  console.error(`The signal map's groups don't fit the harness:\n${problems.map((problem) => `- ${problem}`).join("\n")}`);
@@ -45337,7 +45491,7 @@ var init_leak_rules = __esmMin((() => {
45337
45491
  ];
45338
45492
  }));
45339
45493
  // src/harness/check-words.ts
45340
- var check_words_exports = /* @__PURE__ */ __exportAll({ run: () => run$15 });
45494
+ var check_words_exports = /* @__PURE__ */ __exportAll({ run: () => run$16 });
45341
45495
  function readCallInput(call) {
45342
45496
  const input = call["~orpc"].inputSchema;
45343
45497
  if (input === void 0) throw new Error("This contract call takes no input.");
@@ -45475,7 +45629,7 @@ function listLines(problems) {
45475
45629
  function isKind(name) {
45476
45630
  return wordKinds.some((kind) => kind === name);
45477
45631
  }
45478
- function run$15(args) {
45632
+ function run$16(args) {
45479
45633
  const [kind, path] = args;
45480
45634
  if (kind === void 0 || path === void 0 || !isKind(kind)) throw new Error(`Run it as: goose-staff harness check-words <${wordKinds.join("|")}> <file>`);
45481
45635
  const { file, text } = readFile$2(path);
@@ -45508,7 +45662,7 @@ var init_check_words = __esmMin((() => {
45508
45662
  };
45509
45663
  }));
45510
45664
  // src/harness/customer-tables.ts
45511
- var customer_tables_exports = /* @__PURE__ */ __exportAll({ run: () => run$14 });
45665
+ var customer_tables_exports = /* @__PURE__ */ __exportAll({ run: () => run$15 });
45512
45666
  function toPhone(value) {
45513
45667
  return value.replaceAll(/\D/gu, "");
45514
45668
  }
@@ -45880,7 +46034,7 @@ function buildCohorts$1(inputs, orders, storeDays, customers, personOf) {
45880
46034
  });
45881
46035
  }).toSorted((one, other) => toCohortKey(one).localeCompare(toCohortKey(other)));
45882
46036
  }
45883
- function describeBand(stage, gaps) {
46037
+ function describeBand$1(stage, gaps) {
45884
46038
  if (gaps === void 0) return {};
45885
46039
  const band = (/* @__PURE__ */ new Map([
45886
46040
  ["active", [void 0, gaps.median]],
@@ -45908,12 +46062,12 @@ function buildStages(customers, summaries) {
45908
46062
  customers: members.length,
45909
46063
  share: divide(members.length, inStep.length, 4),
45910
46064
  renewing: members.filter((customer) => typeof customer.last_renewal_day === "string" && customer.last_renewal_day > readCell(customer, "last_order_day")).length,
45911
- ...step === "all" ? {} : describeBand(stage, summaries.get(step))
46065
+ ...step === "all" ? {} : describeBand$1(stage, summaries.get(step))
45912
46066
  };
45913
46067
  });
45914
46068
  });
45915
46069
  }
45916
- function run$14(args) {
46070
+ function run$15(args) {
45917
46071
  const [inputsPath, outputPath] = args;
45918
46072
  if (inputsPath === void 0 || outputPath === void 0) throw new Error("Run it as: goose-staff harness customer-tables <inputs file> <output folder>");
45919
46073
  const { inputs, joinsNothing } = readInputs$1(inputsPath);
@@ -46712,7 +46866,7 @@ var init_rule_history = __esmMin((() => {
46712
46866
  // src/harness/rule-date.ts
46713
46867
  var rule_date_exports = /* @__PURE__ */ __exportAll({
46714
46868
  historyVariable: () => historyVariable,
46715
- run: () => run$13
46869
+ run: () => run$14
46716
46870
  });
46717
46871
  function readArguments$7(args) {
46718
46872
  const { values, positionals } = parseArgs({
@@ -46727,7 +46881,7 @@ function readArguments$7(args) {
46727
46881
  strict: true,
46728
46882
  allowPositionals: true
46729
46883
  });
46730
- if (positionals.length > 0 || values.words === void 0) throw new Error(usage$7);
46884
+ if (positionals.length > 0 || values.words === void 0) throw new Error(usage$8);
46731
46885
  return {
46732
46886
  words: values.words.map((text) => requireRuleWords(text)),
46733
46887
  checkout: values.checkout
@@ -46751,7 +46905,7 @@ function printDates(words, history) {
46751
46905
  }
46752
46906
  }
46753
46907
  }
46754
- function run$13(args) {
46908
+ function run$14(args) {
46755
46909
  const { words, checkout } = readArguments$7(args);
46756
46910
  if (checkout === void 0) {
46757
46911
  printDates(words, findHistory());
@@ -46766,16 +46920,16 @@ function run$13(args) {
46766
46920
  rmSync(folder, { recursive: true });
46767
46921
  }
46768
46922
  }
46769
- var historyVariable, usage$7;
46923
+ var historyVariable, usage$8;
46770
46924
  var init_rule_date = __esmMin((() => {
46771
46925
  init_rule_history();
46772
46926
  init_rule_words();
46773
46927
  init_stack();
46774
46928
  historyVariable = "GOOSESTACK_RULE_HISTORY";
46775
- usage$7 = "Run it as: goose-staff harness rule-date --words \"<a rule's own words>\" [--words \"<more>\"] [--checkout <proactive-growth checkout>]";
46929
+ usage$8 = "Run it as: goose-staff harness rule-date --words \"<a rule's own words>\" [--words \"<more>\"] [--checkout <proactive-growth checkout>]";
46776
46930
  }));
46777
46931
  // src/harness/dream-run.ts
46778
- var dream_run_exports = /* @__PURE__ */ __exportAll({ run: () => run$12 });
46932
+ var dream_run_exports = /* @__PURE__ */ __exportAll({ run: () => run$13 });
46779
46933
  function readArguments$6(values) {
46780
46934
  const found = /* @__PURE__ */ new Map();
46781
46935
  const from = [];
@@ -46787,18 +46941,18 @@ function readArguments$6(values) {
46787
46941
  continue;
46788
46942
  }
46789
46943
  const value = values[index + 1];
46790
- if (value === void 0 || value === "" || value.startsWith("--")) throw new Error(`${flag} needs a value.\n${usage$6}`);
46944
+ if (value === void 0 || value === "" || value.startsWith("--")) throw new Error(`${flag} needs a value.\n${usage$7}`);
46791
46945
  index += 1;
46792
46946
  if (flag === "--from") {
46793
46947
  from.push(resolve(value));
46794
46948
  continue;
46795
46949
  }
46796
- if (!valueFlags$1.has(flag)) throw new Error(`${flag} isn't an argument this takes.\n${usage$6}`);
46797
- if (found.has(flag)) throw new Error(`${flag} is given twice.\n${usage$6}`);
46950
+ if (!valueFlags$1.has(flag)) throw new Error(`${flag} isn't an argument this takes.\n${usage$7}`);
46951
+ if (found.has(flag)) throw new Error(`${flag} is given twice.\n${usage$7}`);
46798
46952
  found.set(flag, value);
46799
46953
  }
46800
46954
  const missing = [...valueFlags$1].filter((flag) => !found.has(flag));
46801
- if (missing.length > 0 || from.length === 0) throw new Error(`Missing ${[...missing, ...from.length === 0 ? ["--from"] : []].join(", ")}.\n${usage$6}`);
46955
+ if (missing.length > 0 || from.length === 0) throw new Error(`Missing ${[...missing, ...from.length === 0 ? ["--from"] : []].join(", ")}.\n${usage$7}`);
46802
46956
  const get = (flag) => String(found.get(flag));
46803
46957
  const timeZone = get("--time-zone");
46804
46958
  const budgetUsd = Number(get("--budget-usd"));
@@ -47212,7 +47366,7 @@ function setAside(options, error) {
47212
47366
  writeFileSync(join(failed, "failure.md"), `# The dream failed on ${options.night}\n\n${reason}\n\nNothing left this computer. Run the same command with \`--night ${options.night}\` to read the night again.\n`);
47213
47367
  appendFileSync(join(options.dreamRoot, "costs.md"), `- ${options.night}: failed, see ${join(failed, "failure.md")}\n`);
47214
47368
  }
47215
- function run$12(args) {
47369
+ function run$13(args) {
47216
47370
  const options = readArguments$6(args);
47217
47371
  const stack = readStackFolder();
47218
47372
  const unlanded = options.isLanding ? findUnlanded(options) : void 0;
@@ -47356,7 +47510,7 @@ function recordNight(options, runFolder, heldStack, kept, cost, { summary, nextL
47356
47510
  appendFileSync(join(options.dreamRoot, "costs.md"), `- ${options.night}: $${cost.toFixed(2)}, ${String(kept)} sessions, ${String(built.landed.length)} changes\n`);
47357
47511
  console.log(`${join(runFolder, "summary.md")} holds the morning summary.`);
47358
47512
  }
47359
- var usage$6, valueFlags$1, datePattern, clientFactsModes, versionPattern, oldestClaude, longestDreamMs, longestProjectName, runFolders, dreamTools, changesSchema, settingsTemplate;
47513
+ var usage$7, valueFlags$1, datePattern, clientFactsModes, versionPattern, oldestClaude, longestDreamMs, longestProjectName, runFolders, dreamTools, changesSchema, settingsTemplate;
47360
47514
  var init_dream_run = __esmMin((() => {
47361
47515
  init_dream_branches();
47362
47516
  init_dream_changes();
@@ -47368,7 +47522,7 @@ var init_dream_run = __esmMin((() => {
47368
47522
  init_rule_date();
47369
47523
  init_rule_history();
47370
47524
  init_stack();
47371
- usage$6 = "Run it as: goose-staff harness dream-run --night <YYYY-MM-DD|yesterday> --time-zone <IANA zone> --transcripts <Claude Code's projects folder> --dream-root <folder> --base <goosestack ref> --checkout <proactive-growth checkout> --claude <Claude Code's full path> --model <model> --budget-usd <dollars> --edits <most changes> --client-facts <skip|list> --brand-words <file> --from <folder> [--from <folder> ...] [--land]";
47525
+ usage$7 = "Run it as: goose-staff harness dream-run --night <YYYY-MM-DD|yesterday> --time-zone <IANA zone> --transcripts <Claude Code's projects folder> --dream-root <folder> --base <goosestack ref> --checkout <proactive-growth checkout> --claude <Claude Code's full path> --model <model> --budget-usd <dollars> --edits <most changes> --client-facts <skip|list> --brand-words <file> --from <folder> [--from <folder> ...] [--land]";
47372
47526
  valueFlags$1 = /* @__PURE__ */ new Set([
47373
47527
  "--night",
47374
47528
  "--time-zone",
@@ -47558,9 +47712,9 @@ var init_build_agents = __esmMin((() => {
47558
47712
  ];
47559
47713
  }));
47560
47714
  // src/harness/install.ts
47561
- var install_exports = /* @__PURE__ */ __exportAll({ run: () => run$11 });
47715
+ var install_exports = /* @__PURE__ */ __exportAll({ run: () => run$12 });
47562
47716
  function readFolderFlag(value, flag) {
47563
- if (value === void 0) throw new Error(`${flag} is needed.\n${usage$5}`);
47717
+ if (value === void 0) throw new Error(`${flag} is needed.\n${usage$6}`);
47564
47718
  const folder = resolve(value);
47565
47719
  if (!existsSync(folder) || !statSync(folder).isDirectory()) throw new Error(`${flag} names ${folder}, which isn't a folder. Make it first.`);
47566
47720
  return folder;
@@ -47577,7 +47731,7 @@ function readArguments$5(args) {
47577
47731
  strict: true,
47578
47732
  allowPositionals: true
47579
47733
  });
47580
- if (positionals.length > 0) throw new Error(usage$5);
47734
+ if (positionals.length > 0) throw new Error(usage$6);
47581
47735
  return {
47582
47736
  folders: {
47583
47737
  claudeDir: readFolderFlag(values["claude-dir"], "--claude-dir"),
@@ -47687,7 +47841,7 @@ function applyPlan(plan) {
47687
47841
  writeFileSync(file.path, file.text);
47688
47842
  }
47689
47843
  }
47690
- function run$11(args) {
47844
+ function run$12(args) {
47691
47845
  const { folders, isCheck } = readArguments$5(args);
47692
47846
  const { plan, skillCount, agentCount } = makePlan(folders);
47693
47847
  refuseBlocked(plan);
@@ -47704,11 +47858,11 @@ function run$11(args) {
47704
47858
  applyPlan(plan);
47705
47859
  console.log(`Linked ${String(skillCount)} growth skills into ${basename(folders.claudeDir)}/skills and ${basename(folders.agentsDir)}/skills, and wrote ${String(agentCount)} agent files: ${String(drift.length)} changes.`);
47706
47860
  }
47707
- var usage$5;
47861
+ var usage$6;
47708
47862
  var init_install = __esmMin((() => {
47709
47863
  init_build_agents();
47710
47864
  init_stack();
47711
- usage$5 = "Run it as: goose-staff harness install --claude-dir <folder> --agents-dir <folder> --codex-dir <folder> [--check]";
47865
+ usage$6 = "Run it as: goose-staff harness install --claude-dir <folder> --agents-dir <folder> --codex-dir <folder> [--check]";
47712
47866
  }));
47713
47867
  // src/harness/leak-selector.ts
47714
47868
  function lower(text) {
@@ -48520,7 +48674,7 @@ var init_leak_map_build = __esmMin((() => {
48520
48674
  howToRun = ["Run each finder as goose-staff knowledge read leaks/how-to-run#finder-rules says, and end it with one verdict from leaks/how-to-run#verdicts."];
48521
48675
  }));
48522
48676
  // src/harness/leak-map.ts
48523
- var leak_map_exports = /* @__PURE__ */ __exportAll({ run: () => run$10 });
48677
+ var leak_map_exports = /* @__PURE__ */ __exportAll({ run: () => run$11 });
48524
48678
  async function selectorScript() {
48525
48679
  const { build } = await import("rolldown");
48526
48680
  const [chunk] = (await build({
@@ -48573,7 +48727,7 @@ function readCurrent(name) {
48573
48727
  if (!existsSync(file)) return null;
48574
48728
  return readFileSync(file, "utf8");
48575
48729
  }
48576
- async function run$10(args) {
48730
+ async function run$11(args) {
48577
48731
  const isCheck = args.includes("--check");
48578
48732
  const { problems, map } = buildLeakMap();
48579
48733
  if (map === null || problems.length > 0) throw new Error(`The leak map has problems:\n${problems.join("\n")}`);
@@ -48612,7 +48766,7 @@ var init_leak_map = __esmMin((() => {
48612
48766
  selectorMark = "<script data-leak-selector><\/script>";
48613
48767
  }));
48614
48768
  // src/harness/leak-select.ts
48615
- var leak_select_exports = /* @__PURE__ */ __exportAll({ run: () => run$9 });
48769
+ var leak_select_exports = /* @__PURE__ */ __exportAll({ run: () => run$10 });
48616
48770
  function readLeakMap() {
48617
48771
  const { problems, map } = buildLeakMap();
48618
48772
  if (map === null || problems.length > 0) throw new Error(`The leak map has problems, so it can't select:\n${problems.join("\n")}`);
@@ -48671,7 +48825,7 @@ function block(finder) {
48671
48825
  for (const other of finder.related) lines.push(`- **Related ${other.id}:** ${other.why}`);
48672
48826
  return lines.join("\n");
48673
48827
  }
48674
- function run$9(args) {
48828
+ function run$10(args) {
48675
48829
  const selector = args.filter((arg) => !arg.startsWith("--")).join(" ");
48676
48830
  if (args.includes("--presets")) for (const preset of map.presets) {
48677
48831
  const picked = selectFinders(map, `preset=${preset.key}`).finders.length;
@@ -48711,10 +48865,10 @@ var init_leak_select = __esmMin((() => {
48711
48865
  laneNames = new Map(Object.entries(map.lanes).map(([lane, about]) => [lane, about.name]));
48712
48866
  }));
48713
48867
  // src/harness/make-video.ts
48714
- var make_video_exports = /* @__PURE__ */ __exportAll({ run: () => run$8 });
48868
+ var make_video_exports = /* @__PURE__ */ __exportAll({ run: () => run$9 });
48715
48869
  function readArguments$4(args) {
48716
48870
  const [stepsFile, video, ...extra] = args;
48717
- if (stepsFile === void 0 || video === void 0 || extra.length > 0) throw new Error(usage$4);
48871
+ if (stepsFile === void 0 || video === void 0 || extra.length > 0) throw new Error(usage$5);
48718
48872
  const videoFile = resolve(video);
48719
48873
  if (extname(videoFile).toLowerCase() !== ".mp4") throw new Error(`${videoFile} must end in .mp4.`);
48720
48874
  return {
@@ -48905,10 +49059,10 @@ async function makeVideo({ stepsFile, video }) {
48905
49059
  });
48906
49060
  }
48907
49061
  }
48908
- async function run$8(args) {
49062
+ async function run$9(args) {
48909
49063
  await makeVideo(readArguments$4(args));
48910
49064
  }
48911
- var frameWidth, frameHeight, frameRate, fadeSeconds, titleSeconds, captionLineLimit, byteLimit$1, pictureTypes, usage$4, stepsSchema, frameStyle;
49065
+ var frameWidth, frameHeight, frameRate, fadeSeconds, titleSeconds, captionLineLimit, byteLimit$1, pictureTypes, usage$5, stepsSchema, frameStyle;
48912
49066
  var init_make_video = __esmMin((() => {
48913
49067
  init_zod();
48914
49068
  frameWidth = 1280;
@@ -48924,7 +49078,7 @@ var init_make_video = __esmMin((() => {
48924
49078
  [".jpeg", "image/jpeg"],
48925
49079
  [".webp", "image/webp"]
48926
49080
  ]);
48927
- usage$4 = "Run it as: goose-staff harness make-video <steps.json> <video.mp4>. steps.json holds a title and 2 to 20 steps, each a picture beside it on disk, the caption shown under it and how many seconds it stays.";
49081
+ usage$5 = "Run it as: goose-staff harness make-video <steps.json> <video.mp4>. steps.json holds a title and 2 to 20 steps, each a picture beside it on disk, the caption shown under it and how many seconds it stays.";
48928
49082
  stepsSchema = strictObject({
48929
49083
  title: string().trim().min(1).max(90),
48930
49084
  steps: array(strictObject({
@@ -48948,7 +49102,7 @@ html, body { width: ${String(frameWidth)}px; height: ${String(frameHeight)}px; o
48948
49102
  `;
48949
49103
  }));
48950
49104
  // src/harness/meta-tables.ts
48951
- var meta_tables_exports = /* @__PURE__ */ __exportAll({ run: () => run$7 });
49105
+ var meta_tables_exports = /* @__PURE__ */ __exportAll({ run: () => run$8 });
48952
49106
  function readInputs(path) {
48953
49107
  const { value, inputs } = readStoreInputs(path, "meta-tables-inputs.schema.json", [requiredAnswers, optionalAnswers].flatMap((group) => Object.values(group)));
48954
49108
  return {
@@ -49211,7 +49365,7 @@ function buildAds(inputs) {
49211
49365
  function listEmptyColumns(columns, rows) {
49212
49366
  return columns.filter((column) => rows.every((row) => row[column] === void 0));
49213
49367
  }
49214
- function run$7(args) {
49368
+ function run$8(args) {
49215
49369
  const [inputsPath, outputPath] = args;
49216
49370
  if (inputsPath === void 0 || outputPath === void 0) throw new Error("Run it as: goose-staff harness meta-tables <inputs file> <output folder>");
49217
49371
  const inputs = readInputs(inputsPath);
@@ -49286,7 +49440,7 @@ var init_meta_tables = __esmMin((() => {
49286
49440
  ]);
49287
49441
  }));
49288
49442
  // src/harness/money-map.ts
49289
- var money_map_exports = /* @__PURE__ */ __exportAll({ run: () => run$6 });
49443
+ var money_map_exports = /* @__PURE__ */ __exportAll({ run: () => run$7 });
49290
49444
  function failOnProblems(heading, problems) {
49291
49445
  if (problems.length === 0) return;
49292
49446
  const lines = problems.map((problem) => `- ${problem}`).join("\n");
@@ -49315,7 +49469,7 @@ function writeMapFile(answerFile, slug, out) {
49315
49469
  writeJson(out, file);
49316
49470
  console.log(`${out} holds Goose's money map for cycle ${readText$3(file, "cycle")}.`);
49317
49471
  }
49318
- function run$6(args) {
49472
+ function run$7(args) {
49319
49473
  const [mode, source, second, out] = args;
49320
49474
  if (mode === "save-input" && source !== void 0 && second !== void 0 && out !== void 0) writeSaveInput(source, second, out);
49321
49475
  else if (mode === "file" && source !== void 0 && second !== void 0 && out !== void 0) writeMapFile(source, second, out);
@@ -49329,18 +49483,18 @@ var init_money_map = __esmMin((() => {
49329
49483
  slugPattern = /^[a-z0-9][a-z0-9-]*$/;
49330
49484
  }));
49331
49485
  // src/harness/render-figure.ts
49332
- var render_figure_exports = /* @__PURE__ */ __exportAll({ run: () => run$5 });
49486
+ var render_figure_exports = /* @__PURE__ */ __exportAll({ run: () => run$6 });
49333
49487
  function readWidth(flags) {
49334
49488
  if (flags.length === 0) return defaultWidth;
49335
49489
  const [flag, value] = flags;
49336
- if (flag !== "--width" || value === void 0 || flags.length !== 2) throw new Error(usage$3);
49490
+ if (flag !== "--width" || value === void 0 || flags.length !== 2) throw new Error(usage$4);
49337
49491
  const width = Number(value);
49338
49492
  if (!Number.isInteger(width) || width < smallestWidth || width > largestWidth) throw new Error(`--width takes a whole number of pixels from ${String(smallestWidth)} to ${String(largestWidth)}.`);
49339
49493
  return width;
49340
49494
  }
49341
49495
  function readArguments$3(args) {
49342
49496
  const [page, picture, ...flags] = args;
49343
- if (page === void 0 || picture === void 0) throw new Error(usage$3);
49497
+ if (page === void 0 || picture === void 0) throw new Error(usage$4);
49344
49498
  const pageFile = resolve(page);
49345
49499
  if (!existsSync(pageFile)) throw new Error(`${pageFile} doesn't exist.`);
49346
49500
  if (extname(pageFile).toLowerCase() !== ".html") throw new Error(`${pageFile} isn't an HTML file.`);
@@ -49400,10 +49554,10 @@ async function renderFigure({ page, picture, width }) {
49400
49554
  if (statSync(picture).size > byteLimit) throw new Error(`${picture} is over 20 MB. Draw the figure smaller.`);
49401
49555
  console.log(`Rendered ${picture} at ${String(width)} pixels wide, ${String(pixelRatio)}x sharp. Upload it with goose-staff finding picture upload --upload ${picture}.`);
49402
49556
  }
49403
- async function run$5(args) {
49557
+ async function run$6(args) {
49404
49558
  await renderFigure(readArguments$3(args));
49405
49559
  }
49406
- var defaultWidth, smallestWidth, largestWidth, pixelRatio, byteLimit, settleTime$1, usage$3, refused;
49560
+ var defaultWidth, smallestWidth, largestWidth, pixelRatio, byteLimit, settleTime$1, usage$4, refused;
49407
49561
  var init_render_figure = __esmMin((() => {
49408
49562
  defaultWidth = 720;
49409
49563
  smallestWidth = 320;
@@ -49411,11 +49565,11 @@ var init_render_figure = __esmMin((() => {
49411
49565
  pixelRatio = 2;
49412
49566
  byteLimit = 2e7;
49413
49567
  settleTime$1 = 300;
49414
- usage$3 = "Run it as: goose-staff harness render-figure <figure.html> <figure.png> [--width 720]. The page must hold everything it needs: inline CSS, SVG and scripts, and pictures beside it on disk.";
49568
+ usage$4 = "Run it as: goose-staff harness render-figure <figure.html> <figure.png> [--width 720]. The page must hold everything it needs: inline CSS, SVG and scripts, and pictures beside it on disk.";
49415
49569
  refused = [];
49416
49570
  }));
49417
49571
  // src/harness/report-page.ts
49418
- var report_page_exports = /* @__PURE__ */ __exportAll({ run: () => run$4 });
49572
+ var report_page_exports = /* @__PURE__ */ __exportAll({ run: () => run$5 });
49419
49573
  function readSource(path) {
49420
49574
  if (!existsSync(path)) throw new Error(`${path} doesn't exist.`);
49421
49575
  return readFileSync(path, "utf8").replaceAll(/\r\n?/g, "\n");
@@ -49891,14 +50045,14 @@ function checkPage(path) {
49891
50045
  if (problems.length > 0) process.exitCode = 1;
49892
50046
  else if (layout !== null) console.log(` passes as a ${layout.name} page`);
49893
50047
  }
49894
- function run$4(args) {
50048
+ function run$5(args) {
49895
50049
  const [command, ...paths] = args;
49896
50050
  const [first, second] = paths;
49897
50051
  if (command === "build" && paths.length === 2 && first !== void 0 && second !== void 0) buildPage$1(first, second);
49898
50052
  else if (command === "check" && paths.length === 1 && first !== void 0) checkPage(first);
49899
- else throw new Error(usage$2);
50053
+ else throw new Error(usage$3);
49900
50054
  }
49901
- var kitFile, kitMark, gridMark, gridSize, filledSquare, emptySquare, voidTags, hiddenTags, rawTextTags, sentenceTags, space, wordMark, sentenceBreak, startTagName, attributePart, startTagEnd, cleanEndTag, looseEndTag, commentEnd, entityReference, namedEntities, windowsCharacters, replacement, firstScreenWords, chapterWords, chapterMostWords, shortSectionWords, shortSectionRows, mostSentences, doMostSteps, doStepWords, extraStyleLines, snippetLength, layouts, textLimits, noAskReasons, colourValue, paintAttributes, tokenPaint, declaration, pureColourProperties, colourShorthand, cssNamedColours, valueFunction, valueBreak, srcsetUrl, importantMark, imageTags, loadAttributes, documentTags, linkAttributes, webProtocols, pageAddresses, addressPadding, styleLoad, typeSetting, usage$2;
50055
+ var kitFile, kitMark, gridMark, gridSize, filledSquare, emptySquare, voidTags, hiddenTags, rawTextTags, sentenceTags, space, wordMark, sentenceBreak, startTagName, attributePart, startTagEnd, cleanEndTag, looseEndTag, commentEnd, entityReference, namedEntities, windowsCharacters, replacement, firstScreenWords, chapterWords, chapterMostWords, shortSectionWords, shortSectionRows, mostSentences, doMostSteps, doStepWords, extraStyleLines, snippetLength, layouts, textLimits, noAskReasons, colourValue, paintAttributes, tokenPaint, declaration, pureColourProperties, colourShorthand, cssNamedColours, valueFunction, valueBreak, srcsetUrl, importantMark, imageTags, loadAttributes, documentTags, linkAttributes, webProtocols, pageAddresses, addressPadding, styleLoad, typeSetting, usage$3;
49902
50056
  var init_report_page = __esmMin((() => {
49903
50057
  init_finding_style();
49904
50058
  init_finding_words();
@@ -50196,7 +50350,7 @@ var init_report_page = __esmMin((() => {
50196
50350
  addressPadding = /^[\0- ]+|[\t\n\r]/g;
50197
50351
  styleLoad = /@import\b[^;]*|url\(\s*(?!['"]?\s*(?:data:|#))[^)]*/gi;
50198
50352
  typeSetting = /\bfont(?:-family|-size)?\s*:/gi;
50199
- usage$2 = "Run it as: goose-staff harness report-page build <name>.src.html <name>.html, or goose-staff harness report-page check <name>.html";
50353
+ usage$3 = "Run it as: goose-staff harness report-page build <name>.src.html <name>.html, or goose-staff harness report-page check <name>.html";
50200
50354
  }));
50201
50355
  // src/harness/session-digest.ts
50202
50356
  var session_digest_exports = /* @__PURE__ */ __exportAll({
@@ -50204,7 +50358,7 @@ var session_digest_exports = /* @__PURE__ */ __exportAll({
50204
50358
  queuedHow: () => queuedHow,
50205
50359
  readSession: () => readSession,
50206
50360
  rejectedHow: () => rejectedHow,
50207
- run: () => run$3
50361
+ run: () => run$4
50208
50362
  });
50209
50363
  function readArguments$2(values) {
50210
50364
  const single = /* @__PURE__ */ new Map();
@@ -50220,20 +50374,20 @@ function readArguments$2(values) {
50220
50374
  for (let index = 0; index < values.length; index += 2) {
50221
50375
  const flag = String(values[index]);
50222
50376
  const value = values[index + 1];
50223
- if (value === void 0 || value === "" || value.startsWith("--")) throw new Error(`${flag} needs a value.\n${usage$1}`);
50377
+ if (value === void 0 || value === "" || value.startsWith("--")) throw new Error(`${flag} needs a value.\n${usage$2}`);
50224
50378
  if (flag === "--session") sessions.push(value);
50225
50379
  else if (flag === "--from") from.push(resolve(value));
50226
50380
  else if (singleFlags.has(flag)) {
50227
- if (single.has(flag)) throw new Error(`${flag} is given twice.\n${usage$1}`);
50381
+ if (single.has(flag)) throw new Error(`${flag} is given twice.\n${usage$2}`);
50228
50382
  single.set(flag, value);
50229
- } else throw new Error(`${flag} isn't an argument this takes.\n${usage$1}`);
50383
+ } else throw new Error(`${flag} isn't an argument this takes.\n${usage$2}`);
50230
50384
  }
50231
50385
  const transcripts = single.get("--transcripts");
50232
50386
  const out = single.get("--out");
50233
- if (transcripts === void 0 || out === void 0) throw new Error(`--transcripts and --out are both needed.\n${usage$1}`);
50387
+ if (transcripts === void 0 || out === void 0) throw new Error(`--transcripts and --out are both needed.\n${usage$2}`);
50234
50388
  const night = single.get("--night");
50235
50389
  if (night === void 0) {
50236
- if (sessions.length === 0 || single.size !== 2 || from.length > 0) throw new Error(`Give at least one --session, or --night with its own flags.\n${usage$1}`);
50390
+ if (sessions.length === 0 || single.size !== 2 || from.length > 0) throw new Error(`Give at least one --session, or --night with its own flags.\n${usage$2}`);
50237
50391
  return {
50238
50392
  mode: "sessions",
50239
50393
  transcripts: resolve(transcripts),
@@ -50243,7 +50397,7 @@ function readArguments$2(values) {
50243
50397
  }
50244
50398
  const timeZone = single.get("--time-zone");
50245
50399
  const skipUnder = single.get("--skip-under");
50246
- if (timeZone === void 0 || skipUnder === void 0 || from.length === 0 || sessions.length > 0) throw new Error(`--night needs --time-zone, --skip-under and at least one --from, and no --session.\n${usage$1}`);
50400
+ if (timeZone === void 0 || skipUnder === void 0 || from.length === 0 || sessions.length > 0) throw new Error(`--night needs --time-zone, --skip-under and at least one --from, and no --session.\n${usage$2}`);
50247
50401
  if (!nightPattern.test(night)) throw new Error(`--night ${night} isn't a YYYY-MM-DD date.`);
50248
50402
  return {
50249
50403
  mode: "night",
@@ -50793,7 +50947,7 @@ async function triageNight(ask) {
50793
50947
  const kept = triaged.filter((session) => session.isKept).length;
50794
50948
  console.log(`${file} lists ${String(triaged.length)} sessions touched that night; ${String(kept)} kept.`);
50795
50949
  }
50796
- async function run$3(args) {
50950
+ async function run$4(args) {
50797
50951
  const ask = readArguments$2(args);
50798
50952
  if (ask.mode === "night") {
50799
50953
  await triageNight(ask);
@@ -50806,10 +50960,10 @@ async function run$3(args) {
50806
50960
  mkdirSync(ask.out, { recursive: true });
50807
50961
  for (const { session, path } of found) writeDigest(session, path, await readSession(path), ask.out);
50808
50962
  }
50809
- var usage$1, nightPattern, privateTag, noLearnTag, steeredTyped, shortTyped, widestZoneMs, emailPattern, phonePattern, homeFolderPattern, otherComputer, noMessage, notSteered, sessionPattern$1, otherLineType, machineBlockPattern, commandNamePattern$1, commandArgsPattern, commandStarts, watchNoticePattern, helperNoticePattern, helperStartPattern, agentMessagePattern, restartPattern, restartWord, machineStarts, sessionCommands, machineTurns, shellTool, staffCommandPattern, staffOwnCommands, questionTool, answerNotices, interruptStart$1, rejectedKind, queuedHow, answeredHow, rejectedHow, rejectionWords, agentEndLimit, agentEndHead;
50963
+ var usage$2, nightPattern, privateTag, noLearnTag, steeredTyped, shortTyped, widestZoneMs, emailPattern, phonePattern, homeFolderPattern, otherComputer, noMessage, notSteered, sessionPattern$1, otherLineType, machineBlockPattern, commandNamePattern$1, commandArgsPattern, commandStarts, watchNoticePattern, helperNoticePattern, helperStartPattern, agentMessagePattern, restartPattern, restartWord, machineStarts, sessionCommands, machineTurns, shellTool, staffCommandPattern, staffOwnCommands, questionTool, answerNotices, interruptStart$1, rejectedKind, queuedHow, answeredHow, rejectedHow, rejectionWords, agentEndLimit, agentEndHead;
50810
50964
  var init_session_digest = __esmMin((() => {
50811
50965
  init_json_schema();
50812
- usage$1 = "Run it as: goose-staff harness session-digest --transcripts <Claude Code's projects folder> --out <folder> --session <id> [--session <id> ...], or for a whole day: goose-staff harness session-digest --transcripts <folder> --out <folder> --night <YYYY-MM-DD> --time-zone <IANA zone> --skip-under <folder> --from <folder> [--from <folder> ...]";
50966
+ usage$2 = "Run it as: goose-staff harness session-digest --transcripts <Claude Code's projects folder> --out <folder> --session <id> [--session <id> ...], or for a whole day: goose-staff harness session-digest --transcripts <folder> --out <folder> --night <YYYY-MM-DD> --time-zone <IANA zone> --skip-under <folder> --from <folder> [--from <folder> ...]";
50813
50967
  nightPattern = /^\d{4}-\d{2}-\d{2}$/;
50814
50968
  privateTag = "#private";
50815
50969
  noLearnTag = "#no-learn";
@@ -52248,7 +52402,7 @@ var init_run_story_read = __esmMin((() => {
52248
52402
  ]);
52249
52403
  }));
52250
52404
  // src/harness/run-story.ts
52251
- var run_story_exports = /* @__PURE__ */ __exportAll({ run: () => run$2 });
52405
+ var run_story_exports = /* @__PURE__ */ __exportAll({ run: () => run$3 });
52252
52406
  function readArguments$1(values) {
52253
52407
  const given = /* @__PURE__ */ new Map();
52254
52408
  let isUpload = false;
@@ -52258,20 +52412,20 @@ function readArguments$1(values) {
52258
52412
  isUpload = true;
52259
52413
  continue;
52260
52414
  }
52261
- if (!valueFlags.has(flag)) throw new Error(`${flag} isn't an argument run-story takes.\n${usage}`);
52262
- if (given.has(flag)) throw new Error(`${flag} is given twice.\n${usage}`);
52415
+ if (!valueFlags.has(flag)) throw new Error(`${flag} isn't an argument run-story takes.\n${usage$1}`);
52416
+ if (given.has(flag)) throw new Error(`${flag} is given twice.\n${usage$1}`);
52263
52417
  const value = values[index + 1];
52264
- if (value === void 0 || value === "" || value.startsWith("--")) throw new Error(`${flag} needs a value.\n${usage}`);
52418
+ if (value === void 0 || value === "" || value.startsWith("--")) throw new Error(`${flag} needs a value.\n${usage$1}`);
52265
52419
  given.set(flag, value);
52266
52420
  index += 1;
52267
52421
  }
52268
52422
  const session = given.get("--session");
52269
- if (session === void 0) throw new Error(`--session is needed.\n${usage}`);
52423
+ if (session === void 0) throw new Error(`--session is needed.\n${usage$1}`);
52270
52424
  for (const flag of ["--from", "--to"]) {
52271
52425
  const time = given.get(flag);
52272
52426
  if (time !== void 0 && !timePattern.test(time)) throw new Error(`${flag} ${time} isn't a UTC time like 2026-11-26T03:36Z.`);
52273
52427
  }
52274
- if (given.get("--run") !== void 0 && !isUpload) throw new Error(`--run only picks the run --upload saves to.\n${usage}`);
52428
+ if (given.get("--run") !== void 0 && !isUpload) throw new Error(`--run only picks the run --upload saves to.\n${usage$1}`);
52275
52429
  const read = (flag) => {
52276
52430
  const value = given.get(flag);
52277
52431
  return value === void 0 ? "" : value;
@@ -52379,7 +52533,7 @@ function uploadPage(page, runs, runId) {
52379
52533
  }, join(folder, `${name}-checkpoint.json`), []);
52380
52534
  console.log(`Saved it to run ${picked} as ${path}.`);
52381
52535
  }
52382
- async function run$2(args) {
52536
+ async function run$3(args) {
52383
52537
  const ask = readArguments$1(args);
52384
52538
  const { path, dream } = findTranscript(ask.session);
52385
52539
  const story = await readStory(path, dream, ask.window);
@@ -52400,14 +52554,14 @@ async function run$2(args) {
52400
52554
  console.log(file);
52401
52555
  if (ask.isUpload) uploadPage(file, listBrandRuns(story), ask.runId);
52402
52556
  }
52403
- var usage, valueFlags, timePattern;
52557
+ var usage$1, valueFlags, timePattern;
52404
52558
  var init_run_story = __esmMin((() => {
52405
52559
  init_checkout();
52406
52560
  init_json_schema();
52407
52561
  init_run_story_facts();
52408
52562
  init_run_story_page();
52409
52563
  init_run_story_read();
52410
- usage = "Run it as: goose-staff harness run-story --session <session file, session id, subagent id or a dream night's runs folder> [--out <file.html>] [--from <ISO time>] [--to <ISO time>] [--upload [--run <run id>]]";
52564
+ usage$1 = "Run it as: goose-staff harness run-story --session <session file, session id, subagent id or a dream night's runs folder> [--out <file.html>] [--from <ISO time>] [--to <ISO time>] [--upload [--run <run id>]]";
52411
52565
  valueFlags = /* @__PURE__ */ new Set([
52412
52566
  "--session",
52413
52567
  "--out",
@@ -52417,6 +52571,207 @@ var init_run_story = __esmMin((() => {
52417
52571
  ]);
52418
52572
  timePattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?Z$/;
52419
52573
  }));
52574
+ // src/harness/watch-band.ts
52575
+ var watch_band_exports = /* @__PURE__ */ __exportAll({ run: () => run$2 });
52576
+ function readDays(source, field) {
52577
+ const value = readField(source, field);
52578
+ if (!isFields$1(value)) throw new Error(`${field} should map each day to its number.`);
52579
+ return new Map(Object.entries(value).map(([day, amount]) => {
52580
+ if (!dayPattern.test(day)) throw new Error(`${field} holds ${day}, which isn't a day.`);
52581
+ if (typeof amount !== "number" || !Number.isFinite(amount)) throw new Error(`${field}'s ${day} should be a number; write 0 for a day with none.`);
52582
+ return [day, amount];
52583
+ }));
52584
+ }
52585
+ function readIsCount(source) {
52586
+ const value = readField(source, "isCount");
52587
+ if (typeof value !== "boolean") throw new Error("isCount should be true or false.");
52588
+ return value;
52589
+ }
52590
+ function toWindow(lastDay) {
52591
+ return {
52592
+ since: addDays$1(lastDay, -6),
52593
+ until: lastDay
52594
+ };
52595
+ }
52596
+ function toPrior(span) {
52597
+ return {
52598
+ since: addDays$1(span.since, -28),
52599
+ until: addDays$1(span.since, -1)
52600
+ };
52601
+ }
52602
+ function listMissing(series, spans) {
52603
+ return spans.flatMap((span) => listDays(span.since, span.until).filter((day) => !series.days.has(day) || series.under !== null && !series.under.has(day)));
52604
+ }
52605
+ function readAmount(days, day) {
52606
+ const amount = days.get(day);
52607
+ if (amount === void 0) throw new Error(`No number for ${day}.`);
52608
+ return amount;
52609
+ }
52610
+ function sumDays(days, span) {
52611
+ return listDays(span.since, span.until).reduce((sum, day) => sum + readAmount(days, day), 0);
52612
+ }
52613
+ function valueOf(series, span) {
52614
+ const top = sumDays(series.days, span);
52615
+ if (series.under === null) return top;
52616
+ const bottom = sumDays(series.under, span);
52617
+ return bottom === 0 ? null : top / bottom;
52618
+ }
52619
+ function ratioOf(series, span) {
52620
+ const value = valueOf(series, span);
52621
+ const prior = valueOf(series, toPrior(span));
52622
+ if (value === null || prior === null || prior === 0) return null;
52623
+ return value / prior;
52624
+ }
52625
+ function readWeeks(series, lastDays) {
52626
+ const spans = lastDays.map(toWindow);
52627
+ const complete = spans.filter((span) => listMissing(series, [span, toPrior(span)]).length === 0);
52628
+ return {
52629
+ isWhole: complete.length === spans.length,
52630
+ weeks: complete.map((span) => ({
52631
+ ...span,
52632
+ ratio: ratioOf(series, span)
52633
+ }))
52634
+ };
52635
+ }
52636
+ function median(values) {
52637
+ const sorted = values.toSorted((first, second) => first - second);
52638
+ const middle = Math.floor(sorted.length / 2);
52639
+ const upper = sorted.at(middle);
52640
+ const lower = sorted.at(sorted.length % 2 === 1 ? middle : middle - 1);
52641
+ if (upper === void 0 || lower === void 0) throw new Error("No numbers to take a median of.");
52642
+ return (lower + upper) / 2;
52643
+ }
52644
+ function listRatios(weeks) {
52645
+ return weeks.flatMap((week) => week.ratio === null ? [] : [week.ratio]);
52646
+ }
52647
+ function pickBand(series, lastDay) {
52648
+ const lastYear = readWeeks(series, Array.from({ length: weekCount }, (_slot, index) => addDays$1(lastDay, -364 - index * windowDays)));
52649
+ const ownWeek = lastYear.weeks.at(0)?.ratio;
52650
+ if (lastYear.isWhole && listRatios(lastYear.weeks).length >= leastWeeks) return {
52651
+ basis: "last_year",
52652
+ weeks: lastYear.weeks,
52653
+ expectedRatio: ownWeek === void 0 || ownWeek === null ? median(listRatios(lastYear.weeks)) : ownWeek
52654
+ };
52655
+ const thisYear = readWeeks(series, Array.from({ length: weekCount }, (_slot, index) => addDays$1(lastDay, -(index + 1) * windowDays)));
52656
+ const ratios = listRatios(thisYear.weeks);
52657
+ return {
52658
+ basis: "prior_28_days",
52659
+ weeks: thisYear.weeks,
52660
+ expectedRatio: ratios.length >= leastWeeks ? median(ratios) : null
52661
+ };
52662
+ }
52663
+ function listStoppedDays(lastDay) {
52664
+ return listDays(addDays$1(lastDay, -2), lastDay);
52665
+ }
52666
+ function isAtZero(series, lastDay) {
52667
+ return listStoppedDays(lastDay).every((day) => readAmount(series.days, day) === 0);
52668
+ }
52669
+ function isStopped(series, lastDay) {
52670
+ const recent = listStoppedDays(lastDay);
52671
+ const before = {
52672
+ since: addDays$1(lastDay, -30),
52673
+ until: addDays$1(lastDay, -3)
52674
+ };
52675
+ if (listMissing(series, [before]).length > 0) return false;
52676
+ const usual = median(listDays(before.since, before.until).map((day) => readAmount(series.days, day)));
52677
+ return usual > 0 && recent.every((day) => readAmount(series.days, day) < usual * stoppedShare);
52678
+ }
52679
+ function findWay(ratio, band) {
52680
+ if (ratio === null || band === null) return null;
52681
+ if (ratio < band.low) return "down";
52682
+ if (ratio > band.high) return "up";
52683
+ return null;
52684
+ }
52685
+ function describeNumber(value) {
52686
+ return value.toLocaleString("en-US", { maximumFractionDigits: Math.abs(value) < 1 ? 4 : 2 });
52687
+ }
52688
+ function describeBand(value, priorValue, range, basis) {
52689
+ if (range === null) return `Under ${leastWeeks} full weeks to compare against, so only a count that stopped can break.`;
52690
+ if (value === null || priorValue === null || priorValue === 0) return "The last 7 days or the 28 before had nothing to divide by, so only a count that stopped can break.";
52691
+ const basisWords = basis === "last_year" ? "last year's same 8 weeks" : "this year's 8 weeks before";
52692
+ return `Last 7 days ${describeNumber(value)}; normal range ${describeNumber(priorValue * range.low)} to ${describeNumber(priorValue * range.high)}, from ${basisWords}.`;
52693
+ }
52694
+ function judgeNode(file) {
52695
+ const input = readJson$1(file);
52696
+ const lastDay = readText$3(input, "lastDay");
52697
+ if (!dayPattern.test(lastDay)) throw new Error(`lastDay ${lastDay} isn't a day.`);
52698
+ const isCount = readIsCount(input);
52699
+ const series = {
52700
+ node: readText$3(input, "node"),
52701
+ days: readDays(input, "days"),
52702
+ under: readField(input, "under") === null ? null : readDays(input, "under")
52703
+ };
52704
+ if (isCount && series.under !== null) throw new Error("A count has no under: give under only for a rate, like orders per session.");
52705
+ const window = toWindow(lastDay);
52706
+ const prior = toPrior(window);
52707
+ const missing = listMissing(series, [window, prior]);
52708
+ if (missing.length > 0) throw new Error(`${series.node} has no number for ${missing.join(", ")}. Write 0 for a day that truly had none; when the source didn't answer for a day, save the node cant_run data_behind.`);
52709
+ const value = valueOf(series, window);
52710
+ const priorValue = valueOf(series, prior);
52711
+ const ratio = ratioOf(series, window);
52712
+ const band = pickBand(series, lastDay);
52713
+ const ratios = listRatios(band.weeks);
52714
+ const range = band.expectedRatio !== null && ratios.length >= leastWeeks ? {
52715
+ low: Math.min(...ratios),
52716
+ high: Math.max(...ratios)
52717
+ } : null;
52718
+ const stopped = isCount && isStopped(series, lastDay);
52719
+ const outsideWay = findWay(ratio, range);
52720
+ const expected = priorValue === null || band.expectedRatio === null ? null : priorValue * band.expectedRatio;
52721
+ const note = describeBand(value, priorValue, range, band.basis);
52722
+ const low = range === null ? null : range.low;
52723
+ const high = range === null ? null : range.high;
52724
+ return {
52725
+ node: series.node,
52726
+ window,
52727
+ value: value === null ? null : round(value, 4),
52728
+ prior: {
52729
+ ...prior,
52730
+ value: priorValue === null ? null : round(priorValue, 4)
52731
+ },
52732
+ ratio: ratio === null ? null : round(ratio, 4),
52733
+ basis: range === null ? null : band.basis,
52734
+ weeks: band.weeks.map((week) => ({
52735
+ ...week,
52736
+ ratio: week.ratio === null ? null : round(week.ratio, 4)
52737
+ })),
52738
+ band: low === null || high === null ? null : {
52739
+ low: round(low, 4),
52740
+ high: round(high, 4)
52741
+ },
52742
+ expected: expected === null ? null : round(expected, 4),
52743
+ allowed: low === null || high === null || priorValue === null ? null : {
52744
+ low: round(priorValue * low, 4),
52745
+ high: round(priorValue * high, 4)
52746
+ },
52747
+ isBreak: outsideWay !== null || stopped,
52748
+ way: stopped ? "down" : outsideWay,
52749
+ isStopped: stopped,
52750
+ isZeroCount: stopped && isAtZero(series, lastDay),
52751
+ note
52752
+ };
52753
+ }
52754
+ function run$2(args) {
52755
+ const [daysFile, outFile, ...rest] = args;
52756
+ if (daysFile === void 0 || outFile === void 0 || rest.length > 0) throw new Error(usage);
52757
+ const result = judgeNode(resolve(daysFile));
52758
+ const text = JSON.stringify(result, null, 2);
52759
+ const outPath = resolve(outFile);
52760
+ mkdirSync(dirname(outPath), { recursive: true });
52761
+ writeFileSync(outPath, `${text}\n`);
52762
+ console.log(text);
52763
+ }
52764
+ var weekCount, leastWeeks, windowDays, stoppedShare, dayPattern, usage;
52765
+ var init_watch_band = __esmMin((() => {
52766
+ init_json_schema();
52767
+ init_store_orders();
52768
+ weekCount = 8;
52769
+ leastWeeks = 4;
52770
+ windowDays = 7;
52771
+ stoppedShare = .25;
52772
+ dayPattern = /^\d{4}-\d{2}-\d{2}$/;
52773
+ usage = "Run it as: goose-staff harness watch-band <days file> <out file>";
52774
+ }));
52420
52775
  // src/harness/watch-gate.ts
52421
52776
  var watch_gate_exports = /* @__PURE__ */ __exportAll({ run: () => run$1 });
52422
52777
  function readNullableText(source, field) {
@@ -52712,6 +53067,21 @@ function gateSignal(signal, healths, groups, numbers) {
52712
53067
  function chunk(items, size) {
52713
53068
  return Array.from({ length: Math.ceil(items.length / size) }, (_slot, index) => items.slice(index * size, index * size + size));
52714
53069
  }
53070
+ function groupMapNodes(nodes) {
53071
+ return [...Map.groupBy(nodes.flatMap((node) => {
53072
+ const source = providerReadPattern.exec(node.read)?.[1];
53073
+ return source === void 0 ? [] : [{
53074
+ source,
53075
+ key: node.key
53076
+ }];
53077
+ }), (node) => node.source)].flatMap(([source, sourceNodes]) => chunk(sourceNodes.map((node) => node.key), mapGroupSize).map((keys) => ({
53078
+ source,
53079
+ nodes: keys
53080
+ }))).map((group, index) => ({
53081
+ id: `${keyNumberGroup}-${index + 1}`,
53082
+ ...group
53083
+ }));
53084
+ }
52715
53085
  function readNumbers(file) {
52716
53086
  const value = readJson$1(file);
52717
53087
  return new Map([...brandNumbers.keys()].map((need) => {
@@ -52867,11 +53237,13 @@ function writeGate(folder) {
52867
53237
  vendors: describeHealth(healths),
52868
53238
  cantRunSaves: chunk(cantRuns, saveSize),
52869
53239
  groups: readGroupsByKey,
52870
- mapNodes
53240
+ mapNodes,
53241
+ mapGroups: groupMapNodes(mapNodes)
52871
53242
  };
52872
53243
  writeFileSync(join(folder, "gate.json"), `${JSON.stringify(gate, null, 2)}\n`);
52873
53244
  const toRead = readGroupsByKey.reduce((sum, group) => sum + group.signals.length, 0);
52874
- console.log(`${cantRuns.length} can't run, in ${gate.cantRunSaves.length} saves; ${toRead} to read, in ${readGroupsByKey.length} groups: ${readGroupsByKey.map((group) => `${group.id} (${group.signals.length})`).join(", ")}; ${mapNodes.length} map nodes.`);
53245
+ const grouped = gate.mapGroups.reduce((sum, group) => sum + group.nodes.length, 0);
53246
+ console.log(`${cantRuns.length} can't run, in ${gate.cantRunSaves.length} saves; ${toRead} to read, in ${readGroupsByKey.length} groups: ${readGroupsByKey.map((group) => `${group.id} (${group.signals.length})`).join(", ")}; ${mapNodes.length} map nodes, ${grouped} in ${gate.mapGroups.length} map groups: ${gate.mapGroups.map((group) => `${group.id} ${group.source} (${group.nodes.length})`).join(", ")}.`);
52875
53247
  }
52876
53248
  function run$1(args) {
52877
53249
  const [mode, first, ...rest] = args;
@@ -52882,7 +53254,7 @@ function run$1(args) {
52882
53254
  else if (mode === "health" && hasOne) printHealth(resolve(first));
52883
53255
  else throw new Error("Run it as: goose-staff harness watch-gate list | probes <run folder> | gate <run folder> | health <brand_get answer file>");
52884
53256
  }
52885
- var groupSize, saveSize, settledNextDay, vendorLimit, answerLimit, unreadScopes, testOrder, retailerFolderKinds, testOrderReason, brandNumbers, slowSettleDays, goodWays;
53257
+ var groupSize, mapGroupSize, saveSize, providerReadPattern, settledNextDay, vendorLimit, answerLimit, unreadScopes, testOrder, retailerFolderKinds, testOrderReason, brandNumbers, slowSettleDays, goodWays;
52886
53258
  var init_watch_gate = __esmMin((() => {
52887
53259
  init_signal_map();
52888
53260
  init_watch_words();
@@ -52890,7 +53262,9 @@ var init_watch_gate = __esmMin((() => {
52890
53262
  init_checkout();
52891
53263
  init_stack();
52892
53264
  groupSize = 15;
53265
+ mapGroupSize = 8;
52893
53266
  saveSize = 15;
53267
+ providerReadPattern = /^provider_read ([a-z_]+) /;
52894
53268
  settledNextDay = 1;
52895
53269
  vendorLimit = 20;
52896
53270
  answerLimit = 300;
@@ -53492,6 +53866,13 @@ var init_commands$1 = __esmMin((() => {
53492
53866
  ],
53493
53867
  load: () => Promise.resolve().then(() => (init_session_digest(), session_digest_exports))
53494
53868
  }],
53869
+ ["watch-band", {
53870
+ subcommands: [],
53871
+ usage: "<days file> <out file>",
53872
+ about: "Says whether one key number broke its normal range, from its numbers by day: last 7 days against the 28 before, compared with last year's same weeks.",
53873
+ flags: [],
53874
+ load: () => Promise.resolve().then(() => (init_watch_band(), watch_band_exports))
53875
+ }],
53495
53876
  ["watch-gate", {
53496
53877
  subcommands: watchGateModes,
53497
53878
  usage: "list | probes <run folder> | gate <run folder> | health <brand_get answer file>",