@gooseworks/staff-cli 0.1.5 → 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 +1022 -527
  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,
@@ -15920,6 +15927,7 @@ var init_staff_findings = __esmMin((() => {
15920
15927
  undrafted: number$1().int().nonnegative().describe("Published findings no staff draft opened that this view lists beside its drafts, from listUndrafted: only for one brand's published or resolved drafts with no other filter, else 0. Not in counts, lanes or groups."),
15921
15928
  groups: array(object({
15922
15929
  key: string().nullable().describe("The brand id, the owner's user id, the tier as text or the label name. null for no owner or no label in the group."),
15930
+ name: string().nullable().describe("The brand's name or the owner's email, so a group shows before its rows load. null for priority, label and no-owner groups."),
15923
15931
  count: number$1().int().nonnegative(),
15924
15932
  money: queueMoney
15925
15933
  })).describe("When group is brand, owner, priority or label: every group among the drafts the filters match, in the order rows come, with how many and their money. Empty when group is null or lane.")
@@ -16377,13 +16385,14 @@ var init_audit_staff = __esmMin((() => {
16377
16385
  finishedAt: date$1().nullable(),
16378
16386
  givenAt: date$1().nullable(),
16379
16387
  archivedAt: date$1().nullable(),
16380
- rerunAuditId: uuid().nullable().describe("The newer audit staff started to run this failed one again, or null.")
16388
+ rerunAuditId: uuid().nullable().describe("The newer audit staff started to run this failed one again, or null."),
16389
+ failedTries: count$3.describe("On a failed audit: the failed tries of the same site for the same organization that day, itself included. Lists show only the newest of them. 0 otherwise.")
16381
16390
  });
16382
16391
  auditTotals = object({
16383
16392
  running: count$3,
16384
16393
  ready: count$3,
16385
16394
  toGive: count$3.describe("Finished staff-run audits nobody gave to a client yet."),
16386
- failed: count$3.describe("Failed audits nobody ran again yet."),
16395
+ failed: count$3.describe("Failed audits nobody ran again yet. A site's failed tries on one day count once."),
16387
16396
  ranAgain: count$3.describe("Failed audits staff already ran again."),
16388
16397
  spentUsd: number$1().nonnegative()
16389
16398
  }).describe("Across the list filtered by everything but stage. Only the first page carries them.");
@@ -17701,6 +17710,7 @@ var init_wiki = __esmMin((() => {
17701
17710
  summary: string(),
17702
17711
  writerKind: wikiWriterKind,
17703
17712
  writerLabel: string(),
17713
+ writerName: string().nullable().describe("The staffer whose AI app saved this version, or who restored it. null for refresh runs, audits and deleted accounts."),
17704
17714
  createdAt: datetime(),
17705
17715
  sizeBytes: number$1().int().min(1),
17706
17716
  isFromPublicPagesOnly: boolean(),
@@ -18840,7 +18850,7 @@ var init_staff_watch = __esmMin((() => {
18840
18850
  "done",
18841
18851
  "partial",
18842
18852
  "failed"
18843
- ]).describe("How the run went, the same on every staff screen and Slack alert. running and failed follow its status. done: it finished with nothing for staff to fix. partial: it finished, but a check failed or couldn't run because a tool is signed out, a permission is missing or the page browser didn't start. Ordinary skips (not_due, audit_only, not_applicable) and standing gaps (not_connected, no_read_guide, no_live_read, needs_number, data_behind) leave it done: the Accounts and All checks pages show those.");
18853
+ ]).describe("How the run went, the same on every staff screen and Slack alert. running and failed follow its status. done: it finished with nothing for staff to fix. partial: it finished, but a check failed or couldn't run because a tool is signed out or the page browser didn't start. Ordinary skips (not_due, audit_only, not_applicable) and standing gaps (not_connected, missing_permission, no_read_guide, no_live_read, needs_number, data_behind) leave it done: the Accounts and All checks pages show those.");
18844
18854
  watchDayStates = [
18845
18855
  "failed",
18846
18856
  "missed",
@@ -19047,7 +19057,7 @@ var init_staff_watch = __esmMin((() => {
19047
19057
  reason: string().min(1).max(2e3).describe("Why the verdict, or what ruled it out."),
19048
19058
  scores: watchScores.nullable().describe("The checker's three scores. null only for looks_fixed and muted, required otherwise."),
19049
19059
  ruledOut: array(measureText.max(500)).max(20).describe("Each other explanation the checker tested and what ruled it out, one line each. Empty when no checker judged it."),
19050
- proof: array(watchMeasure).max(20).describe("The numbers that show it: the reader's for the hit, then the checker's reruns. At least one on every flag with isMatched false."),
19060
+ proof: array(watchMeasure).max(20).describe("The numbers that show it: the reader's for the hit, then the checker's reruns. A rerun that reads the same as an earlier measure is saved once. At least one on every flag with isMatched false."),
19051
19061
  keyNumberBreak: watchKeyNumberBreak.nullable().describe("The break, on a key number check's own topic flag, muted included. null on every other flag."),
19052
19062
  isMatched: boolean().describe("true when the flag links an open draft or finding found before this check, false when this check made the draft."),
19053
19063
  draftId: uuid().nullable().describe("The draft it made or matched, from finding_draft_save or findings_list."),
@@ -19669,6 +19679,7 @@ var init_account_maps = __esmMin((() => {
19669
19679
  kind: _enum(["list", "segment"]),
19670
19680
  link: mapLink
19671
19681
  });
19682
+ `${String(100)}`;
19672
19683
  emailMap = object({
19673
19684
  kind: literal("email"),
19674
19685
  platform: literal("klaviyo"),
@@ -19825,10 +19836,11 @@ var init_account_maps = __esmMin((() => {
19825
19836
  "waiting",
19826
19837
  "missing_permission",
19827
19838
  "reads_failed",
19828
- "working",
19829
- "not_checked"
19839
+ "not_checked",
19840
+ "not_read",
19841
+ "working"
19830
19842
  ];
19831
- accountHealth = _enum(accountHealths).describe("How the account stands now. signed_out: Goose can't sign in to it. waiting: a Windsor connection waits for the brand to press Finish on Windsor's page. missing_permission: the sign-in or the daily checks lack access. reads_failed: every daily check that read it failed. working: daily checks read it. not_checked: no daily check read it last time.");
19843
+ accountHealth = _enum(accountHealths).describe("How the account stands now. signed_out: Goose can't sign in to it. waiting: a Windsor connection waits for the brand to press Finish on Windsor's page. missing_permission: the sign-in or the daily checks lack access. reads_failed: every daily check that read it failed. not_checked: daily checks cover it, but none read it last time. not_read: Goose has nothing read from it, because no daily check read it last time and its map has no saved read, or it has no map and no daily check reads it. working: daily checks read it last time, or its map has a saved read.");
19832
19844
  checkCauses = [
19833
19845
  "signed_out",
19834
19846
  "missing_permission",
@@ -19845,7 +19857,7 @@ var init_account_maps = __esmMin((() => {
19845
19857
  runDay: date().describe("The day of the run that checked it last."),
19846
19858
  reason: string(),
19847
19859
  permission: string().nullable().describe("The permission it lacked, for missing_permission."),
19848
- accounts: array(accountKey).describe("The brand's accounts it read. An account owns the check only when it's the only one.")
19860
+ accounts: array(accountKey).describe("The brand's accounts it read: the vendors the check named, or the watch list's vendors for it when it failed before naming any. Empty when it read no connected account, so it shows only under the brand.")
19849
19861
  });
19850
19862
  stoppedChecks = array(object({
19851
19863
  cause: checkCause,
@@ -19869,11 +19881,11 @@ var init_account_maps = __esmMin((() => {
19869
19881
  latest: mapLatest.nullable()
19870
19882
  }).nullable().describe("The account's map, with its newest saved read or null when it's not read yet. null when Goose keeps no map for it: it reads the account live only, in daily checks, or a Meta ad account has no live sign-in."),
19871
19883
  health: accountHealth.describe("How the account stands now."),
19872
- toFix: accountProblem.nullable().describe("Why it's an account to fix, from the same saved state the Brands list's accounts to fix, the AI app's count and the brand's Home count: signed_out or missing_permission. null when it isn't one. Its health is signed_out or missing_permission with it."),
19884
+ toFix: accountProblem.nullable().describe("The saved sign-in problem the AI app's count and the brand's Home count read: signed_out or missing_permission. null when there is none. Staff count accounts to fix from health instead, with isAccountToFix."),
19873
19885
  checkedAt: date$1().nullable().describe("When Goose last checked the account through its saved sign-in: a connect, a check, or a read that worked or was refused as signed out. A read moves it only once it's over 5 minutes old. The brand's Integrations page shows the same time. null for a Meta ad account Goose hasn't read since it began keeping this time."),
19874
- saved: savedDays.nullable().describe("What Goose saved from it before syncing stopped. null when it never synced."),
19875
- checks: stoppedChecks.describe("The daily checks that read this account alone and stopped."),
19876
- looks: array(mapLook).describe("Connection problems: signed out, Finish on Windsor, missing a permission, off in Meta, days not saved."),
19886
+ saved: savedDays.nullable().describe("What Goose saved from it before syncing stopped. null when it never synced, or Goose never read it: its map has no saved read, or it has no map and no daily check read it."),
19887
+ checks: stoppedChecks.describe("The daily checks that read this account and stopped."),
19888
+ looks: array(mapLook).describe("Connection problems: signed out, Finish on Windsor, missing a permission, off in Meta."),
19877
19889
  quiet: array(mapQuiet).describe("The account's own stopped daily checks, one line per cause."),
19878
19890
  lookCount: object({
19879
19891
  red: int().min(0),
@@ -19979,8 +19991,7 @@ var init_brand_console = __esmMin((() => {
19979
19991
  brandConsoleColumns = [
19980
19992
  "name",
19981
19993
  "atStake",
19982
- "open",
19983
- "drafts"
19994
+ "open"
19984
19995
  ];
19985
19996
  brandConsoleColumnSort = listSort(brandConsoleColumns).describe("The grid column to rank every brand by. It wins over sort when set; null ranks by sort.");
19986
19997
  brandConsoleScope = _enum(["all", "mine"]).describe("mine keeps the brands whose daily watch the caller owns.");
@@ -19989,7 +20000,7 @@ var init_brand_console = __esmMin((() => {
19989
20000
  "accounts",
19990
20001
  "watch",
19991
20002
  "setup"
19992
- ]).describe("What a brand waits on a person for. drafts: drafts wait for review. accounts: a connected account is signed out. watch: its newest watch day, skipping today while it's waiting, failed or was missed. setup: setup isn't finished.");
20003
+ ]).describe("What a brand waits on a person for. drafts: drafts wait for review. accounts: a connected account must be connected again or finished on Windsor. watch: its newest watch day, skipping today while it's waiting, failed or was missed. setup: setup isn't finished.");
19993
20004
  watchWeek = object({
19994
20005
  isOn: boolean().describe("True when both the brand's own watch and the daily watch for every brand are on."),
19995
20006
  days: array(object({
@@ -20351,7 +20362,7 @@ var init_staff = __esmMin((() => {
20351
20362
  surfaces: array(usageSurface).describe("Where they used Goose that day. Empty on a day unused."),
20352
20363
  aiApps: array(usageAiApp).describe("The AI apps they used Goose from that day.")
20353
20364
  });
20354
- useDays = array(useDay).length(30).describe("The last 30 days in US Eastern time, oldest first and today last.");
20365
+ useDays = array(useDay).min(1).max(30).describe("The last 30 days in US Eastern time, oldest first and today last. Fewer when Goose began saving use less than 30 days ago.");
20355
20366
  connectedAiApp = object({
20356
20367
  id: string(),
20357
20368
  app: _enum(AI_APP_IDS).nullable().describe("The checked AI app, or null when Goose can't tell."),
@@ -20378,13 +20389,13 @@ var init_staff = __esmMin((() => {
20378
20389
  days: array(object({
20379
20390
  day: date(),
20380
20391
  personCount: number$1().int().nonnegative()
20381
- })).length(30).describe("Members using Goose each of the last 30 days, oldest first and today last."),
20392
+ })).min(1).max(30).describe("Members using Goose each day of the same days as a person's use, oldest first and today last."),
20382
20393
  people: array(object({
20383
20394
  userId: uuid(),
20384
20395
  dayCount: number$1().int().min(1).max(30),
20385
20396
  surfaces: array(usageSurface),
20386
20397
  aiApps: array(usageAiApp)
20387
- })).describe("Members who used Goose in the last 30 days. A member missing here used it on none.")
20398
+ })).describe("Members who used Goose on those days. A member missing here used it on none.")
20388
20399
  });
20389
20400
  brandFields = {
20390
20401
  id: uuid(),
@@ -20443,7 +20454,7 @@ var init_staff = __esmMin((() => {
20443
20454
  draftsReady: number$1().int().nonnegative().describe("Waiting drafts in the Findings page's Ready to publish lane."),
20444
20455
  draftsAtStake: monthlyAtStake,
20445
20456
  oldestDraftAt: date$1().nullable().describe("When staff last touched the longest-waiting draft. null with no drafts waiting."),
20446
- accountsToFix: number$1().int().nonnegative().describe("Connected accounts to fix, each Meta ad account on its own: signed out, or missing a permission Goose needs. Someone must connect each again. The brand's Accounts page To fix tab lists the same accounts."),
20457
+ accountsToFix: number$1().int().nonnegative().describe("Connected accounts to fix, each Meta ad account on its own: signed out, missing a permission Goose needs, or a data account waiting for the brand to press Finish on Windsor. Someone must connect or finish each. The brand's Accounts page To fix tab lists the same accounts."),
20447
20458
  watch: watchWeek,
20448
20459
  needs: array(brandNeed).describe("What the brand waits on a person for, most pressing first.")
20449
20460
  });
@@ -20505,7 +20516,10 @@ var init_staff = __esmMin((() => {
20505
20516
  cancelRequestedAt: date$1().nullable(),
20506
20517
  stuck: stuckJobStage.nullable().describe("How the job is stuck, or null while it isn't.")
20507
20518
  });
20508
- jobWithTeam = staffJob.extend({ team: teamLabel.extend({ brands: teamBrandsSchema }) });
20519
+ jobWithTeam = staffJob.extend({
20520
+ team: teamLabel.extend({ brands: teamBrandsSchema }),
20521
+ brandName: string().nullable().describe("The brand the work was for. null for work with no brand, or a deleted brand.")
20522
+ });
20509
20523
  jobFilterInput = {
20510
20524
  brandId: uuid().nullable(),
20511
20525
  kind: jobKind.nullable()
@@ -20535,7 +20549,7 @@ var init_staff = __esmMin((() => {
20535
20549
  failureCount: number$1().int().positive(),
20536
20550
  runs: array(staffJob).min(1).max(20).describe("The group's newest failed runs, newest first. The first is the row itself."),
20537
20551
  ...retryFacts
20538
- }).describe("Failed runs of the same work, shown as their newest failed run. The same work is one organization and brand's video read of one video, site read of the brand, or competitor read of one competitor with the same question and page count. Every other run is its own work.");
20552
+ }).describe("Failed runs of the same work, shown as their newest failed run. The same work is one organization and brand's video read of one video, site read of the brand, competitor read of one competitor with the same question and page count, or check of one page, whatever its version. Every other run is its own work.");
20539
20553
  deletingTeam = object({
20540
20554
  id: uuid(),
20541
20555
  name: string(),
@@ -20717,9 +20731,50 @@ var init_staff = __esmMin((() => {
20717
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() }));
20718
20732
  }));
20719
20733
  // ../../packages/contract/src/staff-fix-check.ts
20734
+ function describeLeftClose(proof, note) {
20735
+ return `${proof} Still left: ${note}`;
20736
+ }
20720
20737
  function listVerdictsWith(part) {
20721
20738
  return fixCheckVerdict$1.options.filter((verdict) => lookNeeds[verdict][part] !== "none");
20722
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
+ }
20723
20778
  function listLookProblems(look) {
20724
20779
  const needs = lookNeeds[look.verdict];
20725
20780
  const missing = neededLookParts.filter((part) => needs[part] === "required" && look[part] === null).map((part) => ({
@@ -20737,7 +20792,9 @@ function listLookProblems(look) {
20737
20792
  return [
20738
20793
  ...missing,
20739
20794
  ...unwanted,
20740
- ...unclear
20795
+ ...unclear,
20796
+ ...listLeftProblems(look),
20797
+ ...listSureProblems(look)
20741
20798
  ];
20742
20799
  }
20743
20800
  function waitingList(item) {
@@ -20746,14 +20803,16 @@ function waitingList(item) {
20746
20803
  totalCount: count$1.describe("How many wait in all.")
20747
20804
  });
20748
20805
  }
20749
- 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, 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;
20750
20807
  var init_staff_fix_check = __esmMin((() => {
20751
20808
  init_zod();
20752
20809
  init_finding_checks();
20753
20810
  init_finding_style_text();
20754
20811
  init_finding_trail();
20812
+ init_finding_words();
20755
20813
  init_findings();
20756
20814
  init_signal_keys();
20815
+ init_staff_queue_filters();
20757
20816
  init_staff_watch();
20758
20817
  fixCheckRules = {
20759
20818
  listedDays: 60,
@@ -20764,7 +20823,8 @@ var init_staff_fix_check = __esmMin((() => {
20764
20823
  lookSaveLimit: 15,
20765
20824
  recentRunLimit: 8,
20766
20825
  pageLimit: 50,
20767
- waitingLimit: 20
20826
+ waitingLimit: 20,
20827
+ noProgressWeeks: 3
20768
20828
  };
20769
20829
  fixCheckLimits = {
20770
20830
  proof: 300,
@@ -20773,7 +20833,10 @@ var init_staff_fix_check = __esmMin((() => {
20773
20833
  note: 2e3,
20774
20834
  evidence: 1e3,
20775
20835
  fixDayNote: 500,
20776
- weekReason: 1e3
20836
+ weekReason: 1e3,
20837
+ closeReason: 2e3,
20838
+ partlyNote: 1500,
20839
+ serverNote: 498
20777
20840
  };
20778
20841
  count$1 = number$1().int().min(0);
20779
20842
  fixCheckPerson = object({
@@ -20811,7 +20874,7 @@ var init_staff_fix_check = __esmMin((() => {
20811
20874
  "closed",
20812
20875
  "reopened",
20813
20876
  "none"
20814
- ]).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.");
20815
20878
  fixCheckSaleKind = _enum([
20816
20879
  "black_friday",
20817
20880
  "storewide_discount",
@@ -20910,15 +20973,25 @@ var init_staff_fix_check = __esmMin((() => {
20910
20973
  source: fixCheckFixDaySource,
20911
20974
  note: string().trim().min(1).max(fixCheckLimits.fixDayNote).describe("What was seen, like the change-log line.")
20912
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.");
20913
20983
  fixCheckLookFields = object({
20914
20984
  findingId: uuid().describe("A finding on this run's list, from fix_check_run_start or fix_check_looks_read."),
20915
20985
  verdict: fixCheckVerdict$1,
20916
- 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."),
20917
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."),
20918
- 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.`),
20919
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."),
20920
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."),
20921
- 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.")
20922
20995
  });
20923
20996
  neededLookParts = [
20924
20997
  "proof",
@@ -20991,6 +21064,11 @@ var init_staff_fix_check = __esmMin((() => {
20991
21064
  fixedOn: "the day the fix went live, where that day comes from and what was seen",
20992
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"
20993
21066
  };
21067
+ sureVerdicts = /* @__PURE__ */ new Set([
21068
+ "fixed",
21069
+ "fix_held",
21070
+ "partly_fixed"
21071
+ ]);
20994
21072
  fixCheckLookInput = fixCheckLookFields.superRefine((look, context) => {
20995
21073
  for (const { path, message } of listLookProblems(look)) context.addIssue({
20996
21074
  code: "custom",
@@ -21019,6 +21097,9 @@ var init_staff_fix_check = __esmMin((() => {
21019
21097
  }).nullable().describe("The credit the look proposes for the fix. null when it proposes none."),
21020
21098
  fixedOn: fixCheckFixDay.nullable().describe("The fix day the look found, with its source. null when it found none."),
21021
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."),
21022
21103
  effect: fixCheckEffect,
21023
21104
  createdAt: date$1().describe("When the look was saved.")
21024
21105
  });
@@ -21029,6 +21110,9 @@ var init_staff_fix_check = __esmMin((() => {
21029
21110
  proof: true,
21030
21111
  note: true,
21031
21112
  fixedOn: true,
21113
+ sure: true,
21114
+ isLeftWorthSending: true,
21115
+ leftAmount: true,
21032
21116
  effect: true,
21033
21117
  createdAt: true
21034
21118
  });
@@ -21077,7 +21161,11 @@ var init_staff_fix_check = __esmMin((() => {
21077
21161
  "declined",
21078
21162
  "acted_on"
21079
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."),
21080
- 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."),
21081
21169
  decidedAt: date$1().describe("When it was decided."),
21082
21170
  heardHow: string().nullable().describe("How the Goose team heard it. null when the brand decided in Goose.")
21083
21171
  }).nullable().describe("The decision the finding holds. null when it holds none."),
@@ -21123,19 +21211,33 @@ var init_staff_fix_check = __esmMin((() => {
21123
21211
  waitingFindingId = uuid().describe("The finding's id.");
21124
21212
  waitingTitle = string().describe("The finding's title.");
21125
21213
  fixCheckVerdict$1.extract([
21214
+ "still_open",
21126
21215
  "partly_fixed",
21127
21216
  "fix_seen",
21128
21217
  "brand_decided",
21218
+ "fixed",
21219
+ "fix_held",
21129
21220
  "cant_check"
21130
21221
  ]);
21222
+ waitingLookNote = string().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.");
21131
21223
  fixCheckListedLook = object({
21132
21224
  findingId: waitingFindingId,
21133
21225
  title: waitingTitle,
21134
21226
  runWeek: date().describe("The run's week, its Monday in New York time."),
21135
- proof: string().nullable().describe("What the look saw fixed or clean. null on brand_decided and cant_check."),
21136
- note: string().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.")
21227
+ proof: string().nullable().describe("What the look saw fixed or clean. null on still_open, brand_decided and cant_check."),
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.")
21137
21239
  });
21138
- waitingLook = waitingList(fixCheckListedLook);
21240
+ waitingLook = waitingList(fixCheckListedLook.extend({ note: waitingLookNote }));
21139
21241
  fixCheckClose = object({
21140
21242
  findingId: waitingFindingId,
21141
21243
  title: waitingTitle,
@@ -21145,8 +21247,9 @@ var init_staff_fix_check = __esmMin((() => {
21145
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."),
21146
21248
  proposal: fixCheckLook.pick({
21147
21249
  credit: true,
21148
- fixedOn: true
21149
- }).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.")
21150
21253
  });
21151
21254
  fixCheckWaiting = object({
21152
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."),
@@ -21156,6 +21259,7 @@ var init_staff_fix_check = __esmMin((() => {
21156
21259
  runWeek: date().describe("The run's week, its Monday in New York time."),
21157
21260
  proof: string().describe("The look's proof line."),
21158
21261
  note: string().describe("The server's reason the look closed nothing."),
21262
+ sure: fixCheckLook.shape.sure,
21159
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.")
21160
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."),
21161
21265
  watchHits: waitingList(object({
@@ -21177,7 +21281,8 @@ var init_staff_fix_check = __esmMin((() => {
21177
21281
  title: waitingTitle,
21178
21282
  measureName: string().describe("The proposed measure's name.")
21179
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."),
21180
- 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.`),
21181
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."),
21182
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."),
21183
21288
  cantCheck: waitingLook.describe("The findings the brand's newest run couldn't check, each with why in note.")
@@ -21265,7 +21370,8 @@ var init_staff_reports = __esmMin((() => {
21265
21370
  reportBrand = object({
21266
21371
  teamId: uuid(),
21267
21372
  teamName: string(),
21268
- brandName: string()
21373
+ brandName: string(),
21374
+ brandTimeZone: string().describe("The brand's time zone. Staff screens show the report's times in it.")
21269
21375
  });
21270
21376
  reportBody = object({
21271
21377
  bodyMd: string().describe("The report in Markdown, or the page's words for an html report."),
@@ -21797,7 +21903,7 @@ var init_staff_agent = __esmMin((() => {
21797
21903
  });
21798
21904
  staffAgentContract = { staffAgent: {
21799
21905
  findBrands: staffRead().input(object({
21800
- search: string().trim().min(1).max(200).describe("The start of a brand's name, its slug or its id."),
21906
+ search: string().trim().min(1).max(200).describe("A brand's id, or words that each match the start of a word in the brand's name or slug."),
21801
21907
  cursor: encodedCursor.nullable(),
21802
21908
  limit: number$1().int().min(1).max(staffBrandLimit)
21803
21909
  })).output(object({
@@ -22148,7 +22254,7 @@ var init_staff_agent = __esmMin((() => {
22148
22254
  readFixCheckBrand: staffRead().input(brandInput).output(object({
22149
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."),
22150
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.`),
22151
- 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.")
22152
22258
  })),
22153
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.")),
22154
22260
  startFixCheckRun: staffChange().input(brandInput.extend({
@@ -22619,7 +22725,7 @@ var init_read_tools = __esmMin((() => {
22619
22725
  brandsFind = defineTool({
22620
22726
  name: "brands_find",
22621
22727
  title: "Find brands",
22622
- description: "Find customer brands by the start of their name, their slug or their id, with each brand's organization. Use it first to get the brandId every other tool takes. Pass cursor null, then the answer's nextCursor for more.",
22728
+ description: "Find customer brands by their id, or by words: each typed word must match the start of a word in the brand's name or slug, so 'blue co' finds Blue Bottle Coffee. Each brand comes with its organization. Use it first to get the brandId every other tool takes. Pass cursor null, then the answer's nextCursor for more.",
22623
22729
  effect: "read",
22624
22730
  input: getCallInput(calls$5.findBrands),
22625
22731
  run: (backend, input) => backend.findBrands(input)
@@ -22808,7 +22914,7 @@ Windsor builds a report it hasn't stored yet from Amazon, Amazon Ads or TikTok i
22808
22914
  fixCheckBrandRead = defineTool({
22809
22915
  name: "fix_check_brand_read",
22810
22916
  title: "Read a brand's fix check",
22811
- 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.`,
22812
22918
  effect: "read",
22813
22919
  input: getCallInput(calls$5.readFixCheckBrand),
22814
22920
  run: (backend, input) => backend.readFixCheckBrand(input)
@@ -22885,6 +22991,7 @@ function listLabelsByGroup() {
22885
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;
22886
22992
  var init_change_tools = __esmMin((() => {
22887
22993
  init_finding_reading();
22994
+ init_finding_words();
22888
22995
  init_staff_agent();
22889
22996
  init_staff_fix_check();
22890
22997
  init_staff_labels();
@@ -23311,7 +23418,7 @@ var init_change_tools = __esmMin((() => {
23311
23418
  fixCheckLookSave = defineTool({
23312
23419
  name: "fix_check_look_save",
23313
23420
  title: "Save fix check looks",
23314
- 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}`,
23315
23422
  effect: "change",
23316
23423
  input: getCallInput(calls$4.saveFixCheckLooks),
23317
23424
  run: (backend, input) => backend.saveFixCheckLooks(input)
@@ -24020,7 +24127,7 @@ var init_staff_rules = __esmMin((() => {
24020
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.",
24021
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.",
24022
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.",
24023
- "- 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.",
24024
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.",
24025
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.",
24026
24133
  "- Every call is logged with the staffer's name.",
@@ -25761,7 +25868,7 @@ function readTexts(source, field) {
25761
25868
  return item;
25762
25869
  });
25763
25870
  }
25764
- function listRepeated$1(values) {
25871
+ function listRepeated(values) {
25765
25872
  return [...new Set(values.filter((value, index) => values.indexOf(value) !== index))];
25766
25873
  }
25767
25874
  function toCanonical(value) {
@@ -25870,7 +25977,7 @@ function checkList(file, schema, value, path) {
25870
25977
  if (items === void 0) return problems;
25871
25978
  return [...problems, ...value.flatMap((item, index) => checkValue(file, items, item, `${path}[${index}]`))];
25872
25979
  }
25873
- function checkFields(file, schema, value, path) {
25980
+ function checkFields$1(file, schema, value, path) {
25874
25981
  const fields = Object.keys(value);
25875
25982
  const { names, others, minProperties } = schema;
25876
25983
  const missing = schema.required.filter((field) => !(field in value)).map((field) => `${path}.${field} is missing.`);
@@ -25899,7 +26006,7 @@ function checkValue(file, given, value, path) {
25899
26006
  if (typeof value === "string") problems.push(...checkText(schema, value, path));
25900
26007
  if (typeof value === "number") problems.push(...checkNumber(schema, value, path));
25901
26008
  if (Array.isArray(value)) problems.push(...checkList(file, schema, value, path));
25902
- if (isFields$1(value)) problems.push(...checkFields(file, schema, value, path));
26009
+ if (isFields$1(value)) problems.push(...checkFields$1(file, schema, value, path));
25903
26010
  return problems;
25904
26011
  }
25905
26012
  function checkAgainstSchema(schemaPath, value, name) {
@@ -26017,7 +26124,7 @@ function readClause(value, group) {
26017
26124
  function readStoreInputs(path, schemaFile, answerIds) {
26018
26125
  const file = resolve(path);
26019
26126
  const value = readJson$1(file);
26020
- const problems = checkAgainstSchema(join(harnessFolder$4, "schema", schemaFile), value, "inputs");
26127
+ const problems = checkAgainstSchema(join(harnessFolder$3, "schema", schemaFile), value, "inputs");
26021
26128
  if (problems.length > 0) throw new Error(`${file} isn't right:\n${problems.join("\n")}`);
26022
26129
  const window = readField(value, "window");
26023
26130
  const sources = readField(value, "orderSources");
@@ -26077,7 +26184,7 @@ function nameGroup(inputs, labels, hasVisit) {
26077
26184
  if (matched !== void 0) return matched;
26078
26185
  return hasVisit ? "other" : "no_visit";
26079
26186
  }
26080
- function readAmount$1(order, field) {
26187
+ function readAmount$2(order, field) {
26081
26188
  return toNumber(dig(order, [
26082
26189
  field,
26083
26190
  "shopMoney",
@@ -26093,16 +26200,16 @@ function readShippingTax(order) {
26093
26200
  ]), "A shipping tax line"), 0);
26094
26201
  }
26095
26202
  function readNet(order) {
26096
- const subtotal = readAmount$1(order, "subtotalPriceSet");
26097
- const taxNow = readAmount$1(order, "currentTotalTaxSet");
26098
- const refundedShipping = readAmount$1(order, "totalRefundedShippingSet");
26099
- 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;
26100
26207
  if (order.taxesIncluded === false) {
26101
- const refundedTax = readAmount$1(order, "totalTaxSet") - taxNow;
26208
+ const refundedTax = readAmount$2(order, "totalTaxSet") - taxNow;
26102
26209
  return Math.max(0, subtotal - Math.max(0, refundedBesidesShipping - refundedTax));
26103
26210
  }
26104
26211
  if (order.taxesIncluded !== true) throw new Error(`Order ${readText$3(order, "id")} doesn't say whether its prices include tax.`);
26105
- const shipping = readAmount$1(order, "totalShippingPriceSet");
26212
+ const shipping = readAmount$2(order, "totalShippingPriceSet");
26106
26213
  const shippingTaxNow = shipping > 0 ? readShippingTax(order) * Math.max(0, 1 - refundedShipping / shipping) : 0;
26107
26214
  return Math.max(0, subtotal - Math.max(0, refundedBesidesShipping) - (taxNow - shippingTaxNow));
26108
26215
  }
@@ -26112,7 +26219,7 @@ function nameLeftOut(inputs, order, day, source) {
26112
26219
  if (order.test === true) return "test";
26113
26220
  if (typeof order.cancelledAt === "string") return "cancelled";
26114
26221
  if (!paidStatuses.includes(readText$3(order, "displayFinancialStatus"))) return "notPaid";
26115
- if (readAmount$1(order, "totalPriceSet") <= 0) return "zeroDollar";
26222
+ if (readAmount$2(order, "totalPriceSet") <= 0) return "zeroDollar";
26116
26223
  if (inputs.outsideStore.includes(source)) return "outsideStore";
26117
26224
  }
26118
26225
  function readOrderIndex(row) {
@@ -26249,7 +26356,7 @@ function writeTable(folder, name, columns, rows) {
26249
26356
  columns
26250
26357
  };
26251
26358
  }
26252
- var ruledGroups, sourceGroups, clauseFields, netSalesFields, leftOutFields, leftOutBeforeWindow, paidStatuses, orderDefinitions, harnessFolder$4, dayLength$1;
26359
+ var ruledGroups, sourceGroups, clauseFields, netSalesFields, leftOutFields, leftOutBeforeWindow, paidStatuses, orderDefinitions, harnessFolder$3, dayLength$1;
26253
26360
  var init_store_orders = __esmMin((() => {
26254
26361
  init_json_schema();
26255
26362
  init_stack();
@@ -26296,7 +26403,7 @@ var init_store_orders = __esmMin((() => {
26296
26403
  netSales: "Subtotal after discounts, without tax and shipping, less what was refunded for the goods, never below zero for an order. A refund's shipping (totalRefundedShippingSet) and its tax (totalTaxSet less currentTotalTaxSet) are no part of what was refunded for the goods. Where the store's prices include tax (taxesIncluded), the tax still on the goods comes off as well: currentTotalTaxSet less the shipping line's tax that wasn't refunded. A refunded tip or duty counts as a refund of goods.",
26297
26404
  sourceGroups: "Each first order falls in the first group whose rule it matches, in the order tagged, meta_other, other_paid, email_sms, search, direct; then no_visit when the order has no first-visit record, else other."
26298
26405
  };
26299
- harnessFolder$4 = fromHarness();
26406
+ harnessFolder$3 = fromHarness();
26300
26407
  dayLength$1 = 864e5;
26301
26408
  }));
26302
26409
  // src/harness/customer-tables-shape.ts
@@ -26552,7 +26659,7 @@ var init_meta_tables_shape = __esmMin((() => {
26552
26659
  };
26553
26660
  }));
26554
26661
  // src/harness/check-calls.ts
26555
- var check_calls_exports = /* @__PURE__ */ __exportAll({ run: () => run$23 });
26662
+ var check_calls_exports = /* @__PURE__ */ __exportAll({ run: () => run$24 });
26556
26663
  function checkEntry(entry, name, provider) {
26557
26664
  const id = readText$3(entry, "id");
26558
26665
  const problems = [];
@@ -26574,7 +26681,7 @@ function checkFile(fileName) {
26574
26681
  };
26575
26682
  const path = join(callsFolder$1, fileName);
26576
26683
  const value = readJson$1(path);
26577
- const schemaProblems = checkAgainstSchema(schemaFile$4, value, fileName);
26684
+ const schemaProblems = checkAgainstSchema(schemaFile$3, value, fileName);
26578
26685
  if (schemaProblems.length > 0) return {
26579
26686
  calls: [],
26580
26687
  refused: [],
@@ -26588,7 +26695,7 @@ function checkFile(fileName) {
26588
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>.`]]
26589
26696
  };
26590
26697
  }
26591
- function run$23() {
26698
+ function run$24() {
26592
26699
  const files = readdirSync(callsFolder$1).filter((fileName) => fileName.endsWith(".json"));
26593
26700
  const checked = files.map(checkFile);
26594
26701
  const calls = checked.flatMap((file) => file.calls);
@@ -26609,15 +26716,15 @@ function run$23() {
26609
26716
  if (problems.length > 0) throw new Error(`The call library in catalog/calls has problems:\n${problems.join("\n")}`);
26610
26717
  console.log(`The call library holds ${String(calls.length)} calls and ${String(refused.length)} refused ones across ${String(files.length)} providers, each on its schema with no brand's own ids.`);
26611
26718
  }
26612
- var harnessFolder$3, callsFolder$1, schemaFile$4, providers, longNumber;
26719
+ var harnessFolder$2, callsFolder$1, schemaFile$3, providers, longNumber;
26613
26720
  var init_check_calls = __esmMin((() => {
26614
26721
  init_json_schema();
26615
26722
  init_customer_tables_shape();
26616
26723
  init_meta_tables_shape();
26617
26724
  init_stack();
26618
- harnessFolder$3 = fromHarness();
26619
- callsFolder$1 = join(harnessFolder$3, "catalog", "calls");
26620
- schemaFile$4 = join(harnessFolder$3, "schema", "calls.schema.json");
26725
+ harnessFolder$2 = fromHarness();
26726
+ callsFolder$1 = join(harnessFolder$2, "catalog", "calls");
26727
+ schemaFile$3 = join(harnessFolder$2, "schema", "calls.schema.json");
26621
26728
  providers = /* @__PURE__ */ new Map([
26622
26729
  ["meta", "meta"],
26623
26730
  ["shopify", "shopify"],
@@ -26629,12 +26736,12 @@ var init_check_calls = __esmMin((() => {
26629
26736
  longNumber = /[0-9]{7,}/u;
26630
26737
  }));
26631
26738
  // src/harness/check-generators.ts
26632
- var check_generators_exports = /* @__PURE__ */ __exportAll({ run: () => run$22 });
26633
- function run$22() {
26634
- const files = readdirSync(join(harnessFolder$2, "catalog", "generators")).filter((name) => name.endsWith(".md")).map((name) => basename(name, ".md"));
26739
+ var check_generators_exports = /* @__PURE__ */ __exportAll({ run: () => run$23 });
26740
+ function run$23() {
26741
+ const files = readdirSync(join(harnessFolder$1, "catalog", "generators")).filter((name) => name.endsWith(".md")).map((name) => basename(name, ".md"));
26635
26742
  const current = generatorNames;
26636
26743
  const retired = retiredGeneratorNames;
26637
- const direction = readJson$1(join(harnessFolder$2, "schema", "direction.schema.json"));
26744
+ const direction = readJson$1(join(harnessFolder$1, "schema", "direction.schema.json"));
26638
26745
  const unknownModes = readList$1([
26639
26746
  "$defs",
26640
26747
  "direction",
@@ -26655,12 +26762,12 @@ function run$22() {
26655
26762
  if (problems.length > 0) throw new Error(`The harness's ways of hunting no longer match @gooseworks/contract/finding-generators:\n${problems.join("\n")}`);
26656
26763
  console.log(`The contract names all ${String(files.length)} generators, ${String(retired.length)} retired, and every origin mode the Scout writes.`);
26657
26764
  }
26658
- var harnessFolder$2;
26765
+ var harnessFolder$1;
26659
26766
  var init_check_generators = __esmMin((() => {
26660
26767
  init_finding_generators();
26661
26768
  init_json_schema();
26662
26769
  init_stack();
26663
- harnessFolder$2 = fromHarness();
26770
+ harnessFolder$1 = fromHarness();
26664
26771
  }));
26665
26772
  // src/harness/dream-changes.ts
26666
26773
  function readGroup(change) {
@@ -26682,8 +26789,8 @@ function listChangeProblems$1(value) {
26682
26789
  const ids = changes.map((change) => change.id);
26683
26790
  const groups = new Set(changes.flatMap(({ group }) => group === null ? [] : [group]));
26684
26791
  return [
26685
- ...listRepeated$1(ids).map((id) => `The change ${id} is listed twice.`),
26686
- ...listRepeated$1(changes.flatMap((change) => change.commits)).map((commit) => `The commit ${commit} is listed twice.`),
26792
+ ...listRepeated(ids).map((id) => `The change ${id} is listed twice.`),
26793
+ ...listRepeated(changes.flatMap((change) => change.commits)).map((commit) => `The commit ${commit} is listed twice.`),
26687
26794
  ...ids.filter((id) => groups.has(id)).map((id) => `${id} names a change and a group.`)
26688
26795
  ];
26689
26796
  }
@@ -26769,7 +26876,7 @@ function parseLedger(text, name, stack) {
26769
26876
  }
26770
26877
  function listLedgerProblems(value) {
26771
26878
  const lessons = readLessons(value);
26772
- return [...listRepeated$1(lessons.map((lesson) => lesson.id)).map((id) => `The lesson ${id} is listed twice.`), ...lessons.flatMap(({ id, kind, rule }) => listRuleProblems(id, kind, rule))];
26879
+ return [...listRepeated(lessons.map((lesson) => lesson.id)).map((id) => `The lesson ${id} is listed twice.`), ...lessons.flatMap(({ id, kind, rule }) => listRuleProblems(id, kind, rule))];
26773
26880
  }
26774
26881
  function listRuleProblems(id, kind, rule) {
26775
26882
  if (!ruleKinds.includes(kind)) return rule === null ? [] : [`${id} is ${kind}, so its rule is null.`];
@@ -27037,7 +27144,7 @@ function listLoopProblems(ids, parents) {
27037
27144
  function listRateProblems(value, nodes) {
27038
27145
  const currency = readText$3(value, "currency");
27039
27146
  const rated = readList$1(value, "rates").map((rate) => readText$3(rate, "currency"));
27040
- const problems = listRepeated$1(rated).map((code) => `rates gives ${code} more than once.`);
27147
+ const problems = listRepeated(rated).map((code) => `rates gives ${code} more than once.`);
27041
27148
  if (rated.includes(currency)) problems.push(`rates gives ${currency}, the map's own currency, which takes no rate.`);
27042
27149
  for (const node of nodes) {
27043
27150
  const readCurrency = readField(node, "readCurrency");
@@ -27057,7 +27164,7 @@ function listWindowProblems$1(value) {
27057
27164
  function checkMoneyMap(value) {
27058
27165
  const nodes = readList$1(value, "nodes");
27059
27166
  const ids = nodes.map((node) => readText$3(node, "id"));
27060
- const problems = listRepeated$1(ids).map((id) => `Map node ${id} appears more than once.`);
27167
+ const problems = listRepeated(ids).map((id) => `Map node ${id} appears more than once.`);
27061
27168
  problems.push(...listRootProblems(nodes), ...listRateProblems(value, nodes));
27062
27169
  problems.push(...listWindowProblems$1(value));
27063
27170
  const parents = new Map(nodes.map((node) => [readText$3(node, "id"), readField(node, "parent")]));
@@ -27119,7 +27226,7 @@ function listUnderstandMapProblems(nodes) {
27119
27226
  });
27120
27227
  }
27121
27228
  function listMoneyMapProblems(value) {
27122
- const schemaProblems = checkAgainstSchema(schemaFile$3, value, "money-map");
27229
+ const schemaProblems = checkAgainstSchema(schemaFile$2, value, "money-map");
27123
27230
  return schemaProblems.length > 0 ? schemaProblems : checkMoneyMap(value);
27124
27231
  }
27125
27232
  function toSavedName(pairs, value) {
@@ -27277,11 +27384,11 @@ function readMoneyMapAnswer(answerFile, slug) {
27277
27384
  nodes: readList$1(map, "nodes").map(toFileNode)
27278
27385
  };
27279
27386
  }
27280
- var schemaFile$3, reachedBases, basisNames, visibilityNames;
27387
+ var schemaFile$2, reachedBases, basisNames, visibilityNames;
27281
27388
  var init_money_map_check = __esmMin((() => {
27282
27389
  init_json_schema();
27283
27390
  init_stack();
27284
- schemaFile$3 = fromHarness("schema", "money-map.schema.json");
27391
+ schemaFile$2 = fromHarness("schema", "money-map.schema.json");
27285
27392
  reachedBases = ["best-period", "best-segment"];
27286
27393
  basisNames = [
27287
27394
  ["best-period", "best_period"],
@@ -27296,7 +27403,7 @@ var init_money_map_check = __esmMin((() => {
27296
27403
  ];
27297
27404
  }));
27298
27405
  // src/harness/proof-line.ts
27299
- function listProofProblems(where, proof) {
27406
+ function listProofProblems$1(where, proof) {
27300
27407
  return listProofStyleProblems(proof).map((problem) => `${where}: ${problem}`);
27301
27408
  }
27302
27409
  var init_proof_line = __esmMin((() => {
@@ -34036,7 +34143,7 @@ var init_files = __esmMin((() => {
34036
34143
  recordPathPattern = /^([a-z0-9]+(?:-[a-z0-9]+)*)\/([a-z0-9]+(?:-[a-z0-9]+)*)\/([a-z0-9]+(?:-[a-z0-9]+)*)\/([a-z0-9]+(?:-[a-z0-9]+)*)\.yaml$/;
34037
34144
  }));
34038
34145
  // ../../packages/wiki/src/schema.ts
34039
- var idPattern, id, text, nullableText, pageAddressPattern, pageAddress$1, blockAddress$1, whoValues, who, endings$1, cardStatuses, answer, cardSchema, recordFieldKinds, recordField, recordValue, catalogRecordSchema, stage, stageEdge, formulaTerm, summaryBlock, keyNumberBlock, statusBlock, headingBlock, paragraphBlock, listBlock, calloutBlock, tableBlock, chartBlock, cardsBlock, formulaBlock, diagramBlock, flowBlock, imageBlock, stepsBlock, checklistBlock, questionTreeBlock, decisionBlock, catalogBlock, section, tabsBlock, accordionBlock, blockSchema, pageTypes, pageStatuses, day, pageSchema, budgets;
34146
+ var idPattern, id, text, nullableText, pageAddressPattern, pageAddress$1, blockAddress$1, whoValues, who, endings$1, cardStatuses, answer, cardSchema, recordFieldKinds, recordField, recordLinkSchema, recordValue, catalogRecordSchema, stage, stageEdge, formulaTerm, summaryBlock, keyNumberBlock, statusBlock, headingBlock, paragraphBlock, listBlock, calloutBlock, tableBlock, chartBlock, cardsBlock, formulaBlock, diagramBlock, flowBlock, imageBlock, stepsBlock, checklistBlock, questionTreeBlock, decisionBlock, catalogBlock, section, tabsBlock, accordionBlock, blockSchema, pageTypes, pageStatuses, day, pageSchema, budgets;
34040
34147
  var init_schema = __esmMin((() => {
34041
34148
  init_zod();
34042
34149
  idPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
@@ -34080,7 +34187,8 @@ var init_schema = __esmMin((() => {
34080
34187
  "texts",
34081
34188
  "number",
34082
34189
  "boolean",
34083
- "addresses"
34190
+ "addresses",
34191
+ "links"
34084
34192
  ];
34085
34193
  recordField = strictObject({
34086
34194
  name: id,
@@ -34088,9 +34196,14 @@ var init_schema = __esmMin((() => {
34088
34196
  kind: _enum(recordFieldKinds),
34089
34197
  is_required: boolean()
34090
34198
  });
34199
+ recordLinkSchema = strictObject({
34200
+ label: text,
34201
+ to: blockAddress$1
34202
+ });
34091
34203
  recordValue = union([
34092
34204
  text,
34093
34205
  array(text),
34206
+ array(recordLinkSchema),
34094
34207
  number$1(),
34095
34208
  boolean(),
34096
34209
  _null()
@@ -34777,6 +34890,60 @@ var init_address = __esmMin((() => {
34777
34890
  init_wiki_error();
34778
34891
  addressPattern = /^([a-z0-9]+(?:-[a-z0-9]+)*\/[a-z0-9]+(?:-[a-z0-9]+)*)(?:#([a-z0-9]+(?:-[a-z0-9]+)*))?$/;
34779
34892
  }));
34893
+ // ../../packages/wiki/src/home.ts
34894
+ function readLeverRecords(wiki) {
34895
+ const page = wiki.pages.get(homeAddress);
34896
+ if (page === void 0) return {
34897
+ levers: [],
34898
+ problems: [`The wiki has no ${homeAddress}, the page Knowledge opens on.`]
34899
+ };
34900
+ const catalog = listBlocks(page.page.blocks).find((block) => block.id === leverCatalogId);
34901
+ if (catalog === void 0 || catalog.type !== "catalog") return {
34902
+ levers: [],
34903
+ problems: [`${homeAddress} has no catalog ${leverCatalogId}, the levers Knowledge opens on.`]
34904
+ };
34905
+ const problems = [];
34906
+ const levers = [...readCatalogRecords(page, leverCatalogId).values()].flatMap((record) => {
34907
+ const fields = leverFields.safeParse(record.value.fields);
34908
+ if (!fields.success) {
34909
+ problems.push(...fields.error.issues.map((issue) => `${record.path}${issue.path.length === 0 ? "" : ` at ${issue.path.join(".")}`}: ${issue.message}`));
34910
+ return [];
34911
+ }
34912
+ return [{
34913
+ id: record.value.id,
34914
+ title: record.value.title,
34915
+ summary: record.value.summary,
34916
+ order: fields.data.order,
34917
+ guides: fields.data.guides
34918
+ }];
34919
+ });
34920
+ const orders = levers.map((lever) => lever.order);
34921
+ for (const lever of levers) if (orders.indexOf(lever.order) !== orders.lastIndexOf(lever.order)) problems.push(`${homeAddress}#${lever.id} shares its order ${String(lever.order)}.`);
34922
+ return {
34923
+ levers: levers.toSorted((one, other) => one.order - other.order).map((lever) => ({
34924
+ id: lever.id,
34925
+ title: lever.title,
34926
+ summary: lever.summary,
34927
+ guides: lever.guides
34928
+ })),
34929
+ problems: [...new Set(problems)]
34930
+ };
34931
+ }
34932
+ function listHomeProblems(wiki) {
34933
+ return readLeverRecords(wiki).problems;
34934
+ }
34935
+ var homeAddress, leverCatalogId, leverFields;
34936
+ var init_home = __esmMin((() => {
34937
+ init_zod();
34938
+ init_load();
34939
+ init_schema();
34940
+ homeAddress = "start/index";
34941
+ leverCatalogId = "levers";
34942
+ leverFields = strictObject({
34943
+ order: number$1().int().positive(),
34944
+ guides: array(recordLinkSchema)
34945
+ });
34946
+ }));
34780
34947
  // ../../packages/wiki/src/fill.ts
34781
34948
  function countWords$1(value) {
34782
34949
  if (typeof value === "string") return value.split(/\s+/).filter((word) => word !== "").length;
@@ -34804,7 +34971,7 @@ function measureTrees(page, blocks) {
34804
34971
  }
34805
34972
  function countTextWords(value) {
34806
34973
  if (typeof value === "string") return value.split(/\s+/).filter((word) => word !== "").length;
34807
- if (Array.isArray(value)) return value.reduce((sum, item) => sum + countTextWords(item), 0);
34974
+ if (Array.isArray(value)) return value.reduce((sum, item) => sum + (typeof item === "string" ? countTextWords(item) : 0), 0);
34808
34975
  return 0;
34809
34976
  }
34810
34977
  function countRecordWords(record, proseFields) {
@@ -35013,7 +35180,7 @@ function renderRecord(catalog, record, context) {
35013
35180
  ...catalog.fields.map((field) => {
35014
35181
  const value = readRecordField(record, field.name);
35015
35182
  if (value === void 0 || value === null) return `- ${field.label} (${field.name}): none`;
35016
- if (Array.isArray(value)) return `- ${field.label} (${field.name}): ${value.length === 0 ? "none" : value.map((item) => `\`${item}\``).join(", ")}`;
35183
+ if (Array.isArray(value)) return `- ${field.label} (${field.name}): ${value.length === 0 ? "none" : value.map((item) => typeof item === "string" ? `\`${item}\`` : `${item.label} (\`${item.to}\`)`).join(", ")}`;
35017
35184
  return `- ${field.label} (${field.name}): ${String(value)}`;
35018
35185
  })
35019
35186
  ].join("\n");
@@ -35141,7 +35308,7 @@ function matchesRecord(rules, record) {
35141
35308
  if (rule.values.includes("*")) return true;
35142
35309
  if (rule.key === "id") return rule.values.includes(record.id);
35143
35310
  const value = readRecordField(record, rule.key);
35144
- if (Array.isArray(value)) return value.some((item) => rule.values.includes(item));
35311
+ if (Array.isArray(value)) return value.some((item) => rule.values.includes(typeof item === "string" ? item : item.to));
35145
35312
  return rule.values.includes(String(value));
35146
35313
  });
35147
35314
  }
@@ -35507,7 +35674,17 @@ function isKind$1(field, value) {
35507
35674
  if (field.kind === "text") return typeof value === "string";
35508
35675
  if (field.kind === "number") return typeof value === "number";
35509
35676
  if (field.kind === "boolean") return typeof value === "boolean";
35510
- return Array.isArray(value);
35677
+ if (!Array.isArray(value)) return false;
35678
+ return field.kind === "links" ? value.every((item) => typeof item === "object") : value.every((item) => typeof item === "string");
35679
+ }
35680
+ function listFieldAddresses(field, value) {
35681
+ if (!Array.isArray(value)) return [];
35682
+ if (field.kind === "addresses") return value.filter((item) => typeof item === "string");
35683
+ if (field.kind !== "links") return [];
35684
+ return value.flatMap((item) => {
35685
+ const link = recordLinkSchema.safeParse(item);
35686
+ return link.success ? [link.data.to] : [];
35687
+ });
35511
35688
  }
35512
35689
  function listCatalogProblems(wiki, page, catalog) {
35513
35690
  const names = catalog.fields.map((field) => field.name);
@@ -35517,8 +35694,7 @@ function listCatalogProblems(wiki, page, catalog) {
35517
35694
  const value = readRecordField(record.value, field.name);
35518
35695
  if (value === void 0 || value === null) return field.is_required ? [`${where} needs the field ${field.name}.`] : [];
35519
35696
  if (!isKind$1(field, value)) return [`${where} field ${field.name} must be ${field.kind}.`];
35520
- if (field.kind !== "addresses" || !Array.isArray(value)) return [];
35521
- return value.filter((address) => !canResolve(wiki, address)).map((address) => `${where} field ${field.name} names ${address}, which doesn't resolve.`);
35697
+ return listFieldAddresses(field, value).filter((address) => !canResolve(wiki, address)).map((address) => `${where} field ${field.name} names ${address}, which doesn't resolve.`);
35522
35698
  })];
35523
35699
  });
35524
35700
  }
@@ -35628,7 +35804,8 @@ function checkLoaded(wiki) {
35628
35804
  problems: [
35629
35805
  ...wiki.problems,
35630
35806
  ...wiki.commented.map((path) => `${path} holds a YAML comment, which an edit would drop. Move its words into a field.`),
35631
- ...pages.flatMap((page) => checkPage$1(wiki, page))
35807
+ ...pages.flatMap((page) => checkPage$1(wiki, page)),
35808
+ ...listHomeProblems(wiki)
35632
35809
  ],
35633
35810
  pages: pages.length,
35634
35811
  cards: pages.reduce((sum, page) => sum + [...page.cards.values()].reduce((inner, cards) => inner + cards.size, 0), 0),
@@ -35642,6 +35819,7 @@ var rawHtml, blockKeys;
35642
35819
  var init_check = __esmMin((() => {
35643
35820
  init_address();
35644
35821
  init_hash();
35822
+ init_home();
35645
35823
  init_load();
35646
35824
  init_read();
35647
35825
  init_record_field();
@@ -36194,6 +36372,7 @@ var init_src = __esmMin((() => {
36194
36372
  init_edit();
36195
36373
  init_fill();
36196
36374
  init_files();
36375
+ init_home();
36197
36376
  init_load();
36198
36377
  init_read();
36199
36378
  init_render();
@@ -36330,9 +36509,8 @@ function splitCardAddress(address) {
36330
36509
  }
36331
36510
  function readProblems() {
36332
36511
  return listCatalogRecords(readMapWiki(), problemsAddress).map((record) => {
36333
- const trees = record.fields.trees;
36334
- const mustRead = record.fields["must-read"];
36335
- if (!Array.isArray(trees) || !Array.isArray(mustRead)) throw new Error(`${problemsAddress} record ${record.id} holds no trees or must-read list.`);
36512
+ const trees = readTexts(record.fields, "trees");
36513
+ const mustRead = readTexts(record.fields, "must-read");
36336
36514
  return {
36337
36515
  key: record.id,
36338
36516
  trees: trees.map(readSlug),
@@ -36669,7 +36847,7 @@ function listWalkRuleProblems(file, value) {
36669
36847
  return [
36670
36848
  ...listEndLineProblems(value),
36671
36849
  ...shapeProblems.length > 0 ? shapeProblems : [...listCardListProblems(walk), ...listPassedProblems(walk)],
36672
- ...listRepeated$1(knownIds).map((id) => `known holds ${id} twice, here or in run.json.`),
36850
+ ...listRepeated(knownIds).map((id) => `known holds ${id} twice, here or in run.json.`),
36673
36851
  ...readField(value, "note") === null === isPickUp ? [] : ["note is null on a pick-up walk and on no other."],
36674
36852
  ...readList$1(value, "items").flatMap((item, index) => listItemProblems(walk, item, index, known)),
36675
36853
  ...listCausesProblems(walk, knownIds),
@@ -36944,7 +37122,7 @@ function listUpFrontProblems(run, parts) {
36944
37122
  return [
36945
37123
  ...wanted.filter((name) => !held.includes(name)).map((name) => `upFront has no row for ${name}.`),
36946
37124
  ...held.filter((name) => !wanted.includes(name)).map((name) => `upFront holds ${name}, which the run's files don't show.`),
36947
- ...listRepeated$1(held).map((name) => `upFront holds ${name} twice.`),
37125
+ ...listRepeated(held).map((name) => `upFront holds ${name} twice.`),
36948
37126
  ...rows.filter((row) => upFrontWithNextRead.includes(readText$3(row, "kind")) && readField(row, "nextRead") === null).map((row) => `An upFront row of the kind ${readText$3(row, "kind")} has no next read.`)
36949
37127
  ];
36950
37128
  }
@@ -37027,7 +37205,7 @@ function listPickedProblems(value, problem) {
37027
37205
  if (!isSplitPick) return [];
37028
37206
  const picked = readTexts(value, "picked");
37029
37207
  const partTrees = listPartTrees();
37030
- return [...picked.filter((tree) => !partTrees.includes(tree)).map((tree) => `picked holds ${tree}, which is no part tree.`), ...listRepeated$1(picked).map((tree) => `picked holds ${tree} twice.`)];
37208
+ return [...picked.filter((tree) => !partTrees.includes(tree)).map((tree) => `picked holds ${tree}, which is no part tree.`), ...listRepeated(picked).map((tree) => `picked holds ${tree} twice.`)];
37031
37209
  }
37032
37210
  function listProblemTrees(value, problem) {
37033
37211
  const trees = readTexts(problem, "trees");
@@ -37057,7 +37235,7 @@ function listRunRowProblems(file, value, problem) {
37057
37235
  ...parts.filter((part) => readField(part, "ofProblem") !== problemTrees.includes(readText$3(part, "tree"))).map((part) => `${readText$3(part, "tree")}'s ofProblem doesn't match the problem's trees in meta-ads/problems, or picked.`),
37058
37236
  ...isSplitOnly ? listSplitOnlyProblems(parts) : [],
37059
37237
  ...ran.length === 0 && !isSplitOnly ? ["No tree ran."] : [],
37060
- ...listRepeated$1(readList$1(value, "known").map((row) => readText$3(row, "id"))).map((id) => `known holds ${id} twice.`),
37238
+ ...listRepeated(readList$1(value, "known").map((row) => readText$3(row, "id"))).map((id) => `known holds ${id} twice.`),
37061
37239
  ...listKnownReadProblems(file, value)
37062
37240
  ];
37063
37241
  }
@@ -37174,7 +37352,7 @@ var init_tree_walk_check = __esmMin((() => {
37174
37352
  walkTrees = /* @__PURE__ */ new Map();
37175
37353
  }));
37176
37354
  // src/harness/check-handoff.ts
37177
- var check_handoff_exports = /* @__PURE__ */ __exportAll({ run: () => run$21 });
37355
+ var check_handoff_exports = /* @__PURE__ */ __exportAll({ run: () => run$22 });
37178
37356
  function checkKind(kind, value) {
37179
37357
  return checkAgainstSchema(join(schemaFolder$1, `${kind}.schema.json`), value, kind);
37180
37358
  }
@@ -37190,7 +37368,7 @@ function countDays(window) {
37190
37368
  const { since, until } = readWindowEnds(window);
37191
37369
  return (Date.parse(until) - Date.parse(since)) / dayLength + 1;
37192
37370
  }
37193
- function readAmount(source, field) {
37371
+ function readAmount$1(source, field) {
37194
37372
  const value = readField(source, field);
37195
37373
  if (typeof value !== "number") throw new Error(`${field} should be a number.`);
37196
37374
  return value;
@@ -37222,7 +37400,7 @@ function checkDirections(file, value) {
37222
37400
  const nodes = new Set(mapNodes.keys());
37223
37401
  problems.push(...listDoublingProblems(readField(value, "doubling"), mapNodes));
37224
37402
  problems.push(...listNoteProblems(readList$1(value, "notes")));
37225
- problems.push(...listRepeated$1(directions.map((direction) => readText$3(direction, "id"))).map((id) => `${id} is used by more than one direction.`), ...listRankProblems(directions));
37403
+ problems.push(...listRepeated(directions.map((direction) => readText$3(direction, "id"))).map((id) => `${id} is used by more than one direction.`), ...listRankProblems(directions));
37226
37404
  for (const direction of directions) {
37227
37405
  const id = readText$3(direction, "id");
37228
37406
  const origin = readField(direction, "origin");
@@ -37320,7 +37498,7 @@ function checkStreamKinds(streams, placements) {
37320
37498
  if (ofKind("leaks").length > 2) problems.push(`A cycle has at most 2 leaks streams, not ${ofKind("leaks").length}.`);
37321
37499
  if (ofKind("signals").length > 1) problems.push("A cycle has at most one signals stream.");
37322
37500
  if (ofKind("backlog").length > 1) problems.push("A cycle has at most one backlog stream.");
37323
- problems.push(...listRepeated$1(streams.map((stream) => readText$3(stream, "id"))).map((id) => `Stream id ${id} is used more than once.`));
37501
+ problems.push(...listRepeated(streams.map((stream) => readText$3(stream, "id"))).map((id) => `Stream id ${id} is used more than once.`));
37324
37502
  for (const stream of ofKind("deep")) {
37325
37503
  const held = readTexts(stream, "directions");
37326
37504
  if (held.length !== 1) problems.push(`Deep stream ${readText$3(stream, "id")} holds ${held.length} directions, not 1.`);
@@ -37736,6 +37914,10 @@ function readGroupKeys(file, group) {
37736
37914
  const gateFile = join(dirname(file), "..", "gate.json");
37737
37915
  if (!existsSync(gateFile)) return void 0;
37738
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
+ }
37739
37921
  const entry = readList$1(readJson$1(gateFile), "groups").find((candidate) => readText$3(candidate, "id") === group);
37740
37922
  if (entry === void 0) return [];
37741
37923
  return readList$1(entry, "signals").map((signal) => readText$3(signal, "key"));
@@ -37763,7 +37945,7 @@ function listOpenFlagProblems(key, check) {
37763
37945
  if (readField(open, "stillSeen") === true) return [];
37764
37946
  const where = `${key}'s openFlags[${index}]`;
37765
37947
  const note = readField(open, "note");
37766
- const noteProblems = typeof note === "string" ? listProofProblems(`${where}.note`, note) : [`${where} is stillSeen false with no note proving it's gone.`];
37948
+ const noteProblems = typeof note === "string" ? listProofProblems$1(`${where}.note`, note) : [`${where} is stillSeen false with no note proving it's gone.`];
37767
37949
  if (noteProblems.length === 0) return [];
37768
37950
  return [...noteProblems, `Fix ${where}'s note, or write it stillSeen true when no read proves it's gone.`];
37769
37951
  });
@@ -37793,8 +37975,8 @@ function checkWatchVerdict(value) {
37793
37975
  const verdict = readText$3(value, "verdict");
37794
37976
  const draft = readField(value, "draft");
37795
37977
  const scores = readField(value, "scores");
37796
- const sureItsReal = readAmount(scores, "sureItsReal");
37797
- const sureOfCause = readAmount(scores, "sureOfCause");
37978
+ const sureItsReal = readAmount$1(scores, "sureItsReal");
37979
+ const sureOfCause = readAmount$1(scores, "sureOfCause");
37798
37980
  if (verdict !== "leak" && verdict !== "know") return draft === null ? [] : [`A ${verdict} verdict has no draft; set draft to null.`];
37799
37981
  const problems = [];
37800
37982
  if (draft === null) problems.push(`A ${verdict} verdict needs its draft.`);
@@ -37805,8 +37987,8 @@ function checkWatchVerdict(value) {
37805
37987
  "sureOfCause",
37806
37988
  "sureOfSize"
37807
37989
  ]) {
37808
- const given = readAmount(scores, score);
37809
- 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}.`);
37810
37992
  }
37811
37993
  problems.push(...checkTrail("draft", draft));
37812
37994
  problems.push(...listShownFirstProblems(readList$1(draft, "evidence")));
@@ -37838,7 +38020,7 @@ function listMeasureProblems(where, opening) {
37838
38020
  const weeks = readList$1(opening, "beforeWeeks");
37839
38021
  const starts = weeks.map((week) => readText$3(week, "weekStart"));
37840
38022
  const lastYears = weeks.map((week) => readField(week, "lastYear")).filter((lastYear) => lastYear !== null);
37841
- const problems = [...starts.filter((start) => !isMonday(start)).map((start) => `${where}.beforeWeeks names ${start}, which isn't a Monday. Name each before week by its Monday.`), ...listRepeated$1(starts).map((start) => `${where}.beforeWeeks names ${start} twice. Name each before week once.`)];
38023
+ const problems = [...starts.filter((start) => !isMonday(start)).map((start) => `${where}.beforeWeeks names ${start}, which isn't a Monday. Name each before week by its Monday.`), ...listRepeated(starts).map((start) => `${where}.beforeWeeks names ${start} twice. Name each before week once.`)];
37842
38024
  if (!isOldestFirst(starts)) problems.push(`${where}.beforeWeeks should run oldest first.`);
37843
38025
  if (weeks.some((week) => readField(week, "comparisonValue") !== null !== hasComparison)) problems.push(hasComparison ? `${where} has a comparisonRead, so every before week needs its comparisonValue.` : `${where} has no comparisonRead, so every before week takes comparisonValue null.`);
37844
38026
  if (lastYears.length > 0 && !hasLastYear) problems.push(`${where} has no lastYearRead, so every before week takes lastYear null.`);
@@ -37858,10 +38040,10 @@ function listShownFirstProblems(evidence) {
37858
38040
  }
37859
38041
  function checkWatchConfirm(value) {
37860
38042
  if (readText$3(value, "verdict") !== "fixed") return [];
37861
- return listProofProblems("proof", readText$3(value, "proof"));
38043
+ return listProofProblems$1("proof", readText$3(value, "proof"));
37862
38044
  }
37863
38045
  function listReverifyWordProblems(value) {
37864
- return [...listClientNoteStyleProblems(readText$3(value, "reason")).map((problem) => `reason: ${problem}`), ...listProofProblems("proof", readText$3(value, "proof"))];
38046
+ return [...listClientNoteStyleProblems(readText$3(value, "reason")).map((problem) => `reason: ${problem}`), ...listProofProblems$1("proof", readText$3(value, "proof"))];
37865
38047
  }
37866
38048
  function listRerunProblems(reruns) {
37867
38049
  return reruns.flatMap((rerun, index) => {
@@ -37880,7 +38062,7 @@ function listSizeProblems(size) {
37880
38062
  }
37881
38063
  function listUpdateProblems(update, facts) {
37882
38064
  const moved = readTexts(update, "moved");
37883
- const problems = listRepeated$1(moved).map((part) => `update.moved names ${part} twice.`);
38065
+ const problems = listRepeated(moved).map((part) => `update.moved names ${part} twice.`);
37884
38066
  const parts = [[
37885
38067
  "numbers",
37886
38068
  facts.hasMovedNumber,
@@ -37894,14 +38076,14 @@ function listUpdateProblems(update, facts) {
37894
38076
  if (moved.includes("cause") && readField(facts.size, "cause") === null) problems.push("update.moved holds cause, so size.cause names the cause now.");
37895
38077
  const money = readField(update, "monthlyDollars");
37896
38078
  if (moved.includes("size") && money === null) problems.push("update.moved holds size, so update.monthlyDollars holds the new money.");
37897
- 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.");
37898
38080
  for (const score of [
37899
38081
  "sureItsReal",
37900
38082
  "sureOfCause",
37901
38083
  "sureOfSize"
37902
38084
  ]) {
37903
- const given = readAmount(facts.scores, score);
37904
- 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}.`);
37905
38087
  }
37906
38088
  return problems;
37907
38089
  }
@@ -37911,7 +38093,7 @@ function checkReverifyVerdict(value) {
37911
38093
  const update = readField(value, "update");
37912
38094
  const reruns = readList$1(value, "reruns");
37913
38095
  const readsOn = reruns.map((rerun) => readText$3(rerun, "on"));
37914
- const isUnderBar = readAmount(scores, "sureItsReal") < 75 || readAmount(scores, "sureOfCause") < 75;
38096
+ const isUnderBar = readAmount$1(scores, "sureItsReal") < 75 || readAmount$1(scores, "sureOfCause") < 75;
37915
38097
  const ownReads = reruns.filter((rerun) => readText$3(rerun, "on") !== "today" && readField(rerun, "was") !== null);
37916
38098
  const hasMovedNumber = ownReads.some((rerun) => readField(rerun, "isSame") === false);
37917
38099
  const size = readField(value, "size");
@@ -37964,7 +38146,7 @@ function listMondaysBefore(day, count) {
37964
38146
  return Array.from({ length: count }, (_slot, index) => addDays(monday, -7 * (count - index)));
37965
38147
  }
37966
38148
  function isDay(value) {
37967
- return typeof value === "string" && dayPattern.test(value) && isRealDay(value);
38149
+ return typeof value === "string" && dayPattern$1.test(value) && isRealDay(value);
37968
38150
  }
37969
38151
  function readRunStart(startFile) {
37970
38152
  const start = readJson$1(startFile);
@@ -37978,7 +38160,7 @@ function readRunStart(startFile) {
37978
38160
  };
37979
38161
  }
37980
38162
  function checkFixCheckList(value) {
37981
- return listRepeated$1(readList$1(value, "findings").map((finding) => readText$3(finding, "findingId"))).map((id) => `${id} is listed more than once. List each finding once.`);
38163
+ return listRepeated(readList$1(value, "findings").map((finding) => readText$3(finding, "findingId"))).map((id) => `${id} is listed more than once. List each finding once.`);
37982
38164
  }
37983
38165
  function listJobVerdicts(job) {
37984
38166
  return job === "find_fix" ? [
@@ -38060,7 +38242,7 @@ function listLookPartProblems(value) {
38060
38242
  function listLookProofProblems(value, entry) {
38061
38243
  const proofKind = readField(value, "proofKind");
38062
38244
  const proof = readField(value, "proof");
38063
- const problems = typeof proof === "string" ? listProofProblems("proof", proof) : [];
38245
+ const problems = typeof proof === "string" ? listProofProblems$1("proof", proof) : [];
38064
38246
  if (readText$3(value, "verdict") === "cant_check" !== (proofKind === null)) problems.push("proofKind is null on cant_check, and only there. On every other verdict name state or numbers.");
38065
38247
  if (readField(entry, "isTest") === true && proofKind === "numbers") problems.push("This finding is a test, so its proofKind is state: a read shows whether the change it names is live.");
38066
38248
  return problems;
@@ -38120,7 +38302,7 @@ function listProofWeekProblems(value, start, entry) {
38120
38302
  const week = readField(value, "week");
38121
38303
  if (week === null) {
38122
38304
  const verdict = readText$3(value, "verdict");
38123
- 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.`] : [];
38124
38306
  }
38125
38307
  const weekStart = readText$3(week, "weekStart");
38126
38308
  const weekEnd = readText$3(week, "weekEnd");
@@ -38128,15 +38310,15 @@ function listProofWeekProblems(value, start, entry) {
38128
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.`];
38129
38311
  const fixDay = readProofFixDay(value, entry);
38130
38312
  const problems = [];
38131
- 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.");
38132
- 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.`);
38133
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.`);
38134
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.`);
38135
38317
  return problems;
38136
38318
  }
38137
38319
  function listGoneProblems(verdict, value, results) {
38138
38320
  const problems = [];
38139
- 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.`);
38140
38322
  if (readList$1(value, "stillThere").length === 0) problems.push(`A ${verdict} verdict lists in stillThere each try to find the problem still there.`);
38141
38323
  if (readList$1(value, "touched").length === 0) problems.push(`A ${verdict} verdict lists in touched each thing the fix touched, as checked.`);
38142
38324
  return problems;
@@ -38154,8 +38336,7 @@ function readJudgedWeeks(runFolder) {
38154
38336
  return judged;
38155
38337
  }
38156
38338
  function isActingOnNumbers(value) {
38157
- const verdict = readText$3(value, "verdict");
38158
- return (verdict === "fixed" || verdict === "fix_not_held") && readField(value, "proofKind") === "numbers";
38339
+ return numbersActingVerdicts.has(readText$3(value, "verdict")) && readField(value, "proofKind") === "numbers";
38159
38340
  }
38160
38341
  function listJudgedWeekProblems(value, start, judged, isSending) {
38161
38342
  const week = readField(value, "week");
@@ -38169,6 +38350,30 @@ function listJudgedWeekProblems(value, start, judged, isSending) {
38169
38350
  if (!isSending || isSaleWeek === false || !isActingOnNumbers(value)) return [];
38170
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.`];
38171
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
+ }
38172
38377
  function listLookRerunProblems(value, entry) {
38173
38378
  const verdict = readText$3(value, "verdict");
38174
38379
  const watchRerun = readField(value, "watchRerun");
@@ -38178,17 +38383,34 @@ function listLookRerunProblems(value, entry) {
38178
38383
  const isGone = verdict === "fixed" || verdict === "fix_held";
38179
38384
  const hasRuledOut = readList$1(value, "ruledOut").length > 0;
38180
38385
  const needsWatchRerun = readField(entry, "watchHit") !== null && (verdict === "fix_held" || verdict === "fix_not_held");
38386
+ const sure = readSure(value);
38181
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));
38182
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.");
38183
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.");
38184
38392
  if (!isBack && hasRuledOut) problems.push("ruledOut holds lines only when a rerun reads still_there. Empty it.");
38185
- 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.");
38186
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.");
38187
- 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.");
38188
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));
38189
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.");
38190
38400
  return problems;
38191
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
+ }
38192
38414
  function listReturningDraftProblems(returning, returningDraft) {
38193
38415
  const use = readText$3(returning, "use");
38194
38416
  if (returningDraft === null) return use === "new" ? [] : ["This finding has no returningDraft, so returning.use is new."];
@@ -38218,8 +38440,8 @@ function listLookDraftProblems(value, entry) {
38218
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."];
38219
38441
  if (draft === null) return [];
38220
38442
  const measure = readField(draft, "measure");
38221
- const sureItsReal = readAmount(readField(draft, "sureItsReal"), "score");
38222
- 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");
38223
38445
  const problems = [
38224
38446
  ...checkTrail("draft", draft),
38225
38447
  ...listShownFirstProblems(readList$1(draft, "evidence")),
@@ -38249,6 +38471,7 @@ function checkFixCheckVerdict(file, value) {
38249
38471
  ...listProofWeekProblems(value, start, entry),
38250
38472
  ...listJudgedWeekProblems(value, start, readJudgedWeeks(runFolder), false),
38251
38473
  ...listLookRerunProblems(value, entry),
38474
+ ...listPartlyLeftProblems(value, "leftWorthSending"),
38252
38475
  ...listReturningProblems(value, entry),
38253
38476
  ...listLookDraftProblems(value, entry)
38254
38477
  ];
@@ -38323,12 +38546,18 @@ function listLookDraftIds(source, entry, handBackFile) {
38323
38546
  function listBuiltLookProblems(where, look, source) {
38324
38547
  const problems = [];
38325
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.`);
38326
- 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
+ }
38327
38553
  const expected = [
38328
38554
  ["proof", readField(source, "proof")],
38329
38555
  ["credit", toLookCredit(readField(source, "credit"))],
38330
38556
  ["fixedOn", readField(source, "fixedOn")],
38331
- ["note", readField(source, "note")]
38557
+ ["note", readField(source, "note")],
38558
+ ["sure", readField(source, "sure")],
38559
+ ["isLeftWorthSending", readField(source, "leftWorthSending")],
38560
+ ["leftAmount", readField(source, "leftAmount")]
38332
38561
  ];
38333
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.`)];
38334
38563
  }
@@ -38339,9 +38568,12 @@ function listLookSourceProblems(look, sources) {
38339
38568
  const where = `The look for ${findingId}`;
38340
38569
  const entry = entries.find((candidate) => readText$3(candidate, "findingId") === findingId);
38341
38570
  if (entry === void 0) return [`${where} names a finding that isn't in list.json.`];
38342
- const parts = listLookPartProblems(look).map((problem) => `${where}: ${problem}`);
38571
+ const parts = [...listLookPartProblems(look), ...listPartlyLeftProblems(look, "isLeftWorthSending")].map((problem) => `${where}: ${problem}`);
38343
38572
  const checked = readCheckerFile(join(runFolder, "checks", `${findingId}.json`));
38344
- 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
+ }
38345
38577
  const source = checked.value;
38346
38578
  const written = readText$3(source, "verdict");
38347
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.`];
@@ -38370,7 +38602,7 @@ function checkFixCheckLooks(file, value) {
38370
38602
  };
38371
38603
  return [
38372
38604
  ...readText$3(value, "runId") === runId ? [] : [`runId isn't ${runId}, the run start.json opened. Send looks to that run.`],
38373
- ...listRepeated$1(looks.map((look) => readText$3(look, "findingId"))).map((findingId) => `${findingId} has two looks in this save. Send each finding's look once.`),
38605
+ ...listRepeated(looks.map((look) => readText$3(look, "findingId"))).map((findingId) => `${findingId} has two looks in this save. Send each finding's look once.`),
38374
38606
  ...looks.flatMap((look) => listLookSourceProblems(look, sources))
38375
38607
  ];
38376
38608
  }
@@ -38428,7 +38660,7 @@ function listWeekSumProblems(value) {
38428
38660
  const days = readList$1(value, "days");
38429
38661
  const names = days.map((day) => readText$3(day, "day"));
38430
38662
  const sales = new Map(days.map((day) => [readText$3(day, "day"), readNumber(day, "netSales")]));
38431
- const problems = listRepeated$1(names).map((day) => `days holds ${day} twice. List each day once.`);
38663
+ const problems = listRepeated(names).map((day) => `days holds ${day} twice. List each day once.`);
38432
38664
  if (!isOldestFirst(names)) problems.push("days should run oldest first.");
38433
38665
  return [...problems, ...readList$1(value, "weeks").flatMap((week) => {
38434
38666
  const netSales = readField(week, "netSales");
@@ -38460,7 +38692,7 @@ function checkFixCheckWeeks(file, value) {
38460
38692
  const problems = [
38461
38693
  ...asked.filter((weekStart) => !starts.includes(weekStart)).map((weekStart) => `weeks leaves out the week of ${weekStart}, which the brief asks for.`),
38462
38694
  ...starts.filter((weekStart) => !asked.includes(weekStart)).map((weekStart) => `weeks holds the week of ${weekStart}, which the brief doesn't ask for.`),
38463
- ...listRepeated$1(starts).map((weekStart) => `weeks holds the week of ${weekStart} twice.`)
38695
+ ...listRepeated(starts).map((weekStart) => `weeks holds the week of ${weekStart} twice.`)
38464
38696
  ];
38465
38697
  if (!isOldestFirst(starts)) problems.push("weeks should run oldest first.");
38466
38698
  return [
@@ -38485,7 +38717,7 @@ function listReadJobProblems(value, briefFile) {
38485
38717
  const problems = [
38486
38718
  ...asked.filter((weekStart) => !named.includes(weekStart)).map((weekStart) => `The brief asks for the week of ${weekStart}: put it in reads, or in gaps with why.`),
38487
38719
  ...named.filter((weekStart) => !asked.includes(weekStart)).map((weekStart) => `The brief doesn't ask for the week of ${weekStart}. Take it out.`),
38488
- ...listRepeated$1(named).map((weekStart) => `reads and gaps name the week of ${weekStart} twice. Name each week once.`),
38720
+ ...listRepeated(named).map((weekStart) => `reads and gaps name the week of ${weekStart} twice. Name each week once.`),
38489
38721
  ...listUncalledProblems(value, readWeeks)
38490
38722
  ];
38491
38723
  if (readField(value, "opening") !== null || readField(value, "notMeasurable") !== null) problems.push("A read job proposes nothing: set opening and notMeasurable to null.");
@@ -38635,7 +38867,7 @@ function checkWatchBreaks(file, value) {
38635
38867
  nodes,
38636
38868
  breaksByNode: new Map(breaks.map((brokenNode) => [readText$3(brokenNode, "nodeId"), brokenNode]))
38637
38869
  };
38638
- const problems = listRepeated$1(breaks.map((brokenNode) => readText$3(brokenNode, "nodeId"))).map((node) => `${node} breaks twice; one node has one break a day.`);
38870
+ const problems = listRepeated(breaks.map((brokenNode) => readText$3(brokenNode, "nodeId"))).map((node) => `${node} breaks twice; one node has one break a day.`);
38639
38871
  problems.push(...listWindowProblems(breaks, leftover));
38640
38872
  for (const brokenNode of breaks) {
38641
38873
  const mapNode = nodes.get(readText$3(brokenNode, "nodeId"));
@@ -38712,7 +38944,7 @@ function listRoomFiles(folder) {
38712
38944
  function checkManifest(file, value) {
38713
38945
  const entries = readList$1(value, "files");
38714
38946
  const listed = entries.map((entry) => readText$3(entry, "file"));
38715
- const problems = listRepeated$1(listed).map((name) => `${name} is listed twice.`);
38947
+ const problems = listRepeated(listed).map((name) => `${name} is listed twice.`);
38716
38948
  problems.push(...entries.flatMap(listCallProblems));
38717
38949
  const room = readRoomFolder(file);
38718
38950
  if (!existsSync(room)) return problems;
@@ -38767,7 +38999,7 @@ function checkDreamCandidates(value) {
38767
38999
  const sessions = new Set(readTexts(value, "sessions"));
38768
39000
  const candidates = readList$1(value, "candidates");
38769
39001
  return [
38770
- ...listRepeated$1(candidates.map((candidate) => readText$3(candidate, "id"))).map((id) => `The candidate ${id} is listed twice.`),
39002
+ ...listRepeated(candidates.map((candidate) => readText$3(candidate, "id"))).map((id) => `The candidate ${id} is listed twice.`),
38771
39003
  ...candidates.filter((candidate) => !sessions.has(readText$3(candidate, "session"))).map((candidate) => `${readText$3(candidate, "id")} names a session this reader wasn't given.`),
38772
39004
  ...readTexts(value, "briefs").filter((session) => !sessions.has(session)).map((session) => `The brief ${session} is a session this reader wasn't given.`)
38773
39005
  ];
@@ -38809,13 +39041,13 @@ function listFileProblems$1(kind, file, answerPath) {
38809
39041
  const schemaProblems = checkKind("money-map", value);
38810
39042
  return schemaProblems.length > 0 ? schemaProblems : checkScoutMap(value, resolve(answerPath));
38811
39043
  }
38812
- 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);
38813
39045
  const schemaProblems = checkKind(kind, value);
38814
39046
  return schemaProblems.length > 0 ? schemaProblems : checkRules(kind, file, value);
38815
39047
  }
38816
- function run$21(args) {
39048
+ function run$22(args) {
38817
39049
  const [kind, path, answerPath] = args;
38818
- 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);
38819
39051
  const file = resolve(path);
38820
39052
  const problems = listFileProblems$1(kind, file, answerPath);
38821
39053
  if (problems.length > 0) {
@@ -38824,7 +39056,7 @@ function run$21(args) {
38824
39056
  process.exitCode = 1;
38825
39057
  } else console.log(`${file} passes as ${kind}.`);
38826
39058
  }
38827
- 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;
38828
39060
  var init_check_handoff = __esmMin((() => {
38829
39061
  init_finding_words();
38830
39062
  init_finding_style_text();
@@ -38847,7 +39079,7 @@ var init_check_handoff = __esmMin((() => {
38847
39079
  numbersReadDays = 31;
38848
39080
  dayLength = 864e5;
38849
39081
  uuidPattern$1 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
38850
- dayPattern = /^\d{4}-\d{2}-\d{2}$/;
39082
+ dayPattern$1 = /^\d{4}-\d{2}-\d{2}$/;
38851
39083
  generatorFolder = fromHarness("catalog", "generators");
38852
39084
  investigationFolder = fromHarness("catalog", "investigations");
38853
39085
  nodelessCats = [
@@ -38926,6 +39158,11 @@ var init_check_handoff = __esmMin((() => {
38926
39158
  ]);
38927
39159
  shortNoteLimit = 500;
38928
39160
  widestZoneLead = 504e5;
39161
+ numbersActingVerdicts = /* @__PURE__ */ new Set([
39162
+ "fixed",
39163
+ "partly_fixed",
39164
+ "fix_not_held"
39165
+ ]);
38929
39166
  callFields = /* @__PURE__ */ new Map([["numbers_read", [
38930
39167
  "brandId",
38931
39168
  "table",
@@ -38952,7 +39189,7 @@ var init_check_handoff = __esmMin((() => {
38952
39189
  "window",
38953
39190
  "rates"
38954
39191
  ];
38955
- 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>`;
38956
39193
  }));
38957
39194
  // ../../packages/contract/src/signal-map/signals.json
38958
39195
  var signals_default = {
@@ -43244,7 +43481,7 @@ var init_brand_marks = __esmMin((() => {
43244
43481
  }));
43245
43482
  // src/harness/leak-library.ts
43246
43483
  function readRecords(address) {
43247
- return listCatalogRecords(wiki, address);
43484
+ return listCatalogRecords(wiki$1, address);
43248
43485
  }
43249
43486
  function readId(record, field) {
43250
43487
  const id = readText$3(record.fields, field);
@@ -43312,22 +43549,28 @@ function findTierPlace(entry) {
43312
43549
  if (place < 0) throw new Error(`${entry.id} has the tier ${entry.tier}, which isn't a tier.`);
43313
43550
  return place;
43314
43551
  }
43552
+ function readOptionalText$1(fields, field) {
43553
+ const value = readField(fields, field);
43554
+ if (value === void 0 || value === null) return null;
43555
+ if (typeof value !== "string") throw new Error(`${field} should be text.`);
43556
+ return value;
43557
+ }
43315
43558
  function readWikiMapLinks() {
43316
- return [...mapPages].map(([map, page]) => ({
43559
+ return mapPages.map(({ map, page, catalog, rule }) => ({
43317
43560
  map,
43318
43561
  file: `wiki/${page}.yaml`,
43319
- entries: readRecords(`${page}#links`).map((record) => ({
43562
+ entries: readRecords(`${page}#${catalog}`).map((record) => ({
43320
43563
  id: readId(record, "entry"),
43321
43564
  tier: readText$3(record.fields, "tier"),
43322
43565
  title: record.title,
43323
- rule: readField(record.fields, "rule"),
43566
+ rule: readOptionalText$1(record.fields, rule),
43324
43567
  same: readTexts(record.fields, "same"),
43325
43568
  dig: readTexts(record.fields, "dig"),
43326
43569
  differs: readTexts(record.fields, "differs")
43327
43570
  })).toSorted((one, other) => findTierPlace(one) - findTierPlace(other))
43328
43571
  }));
43329
43572
  }
43330
- var leakLibraryAddress, tierOrder, mapPages, wiki;
43573
+ var leakLibraryAddress, tierOrder, mapPages, wiki$1;
43331
43574
  var init_leak_library = __esmMin((() => {
43332
43575
  init_src();
43333
43576
  init_wiki_folder();
@@ -43338,11 +43581,21 @@ var init_leak_library = __esmMin((() => {
43338
43581
  "first",
43339
43582
  "deep"
43340
43583
  ];
43341
- mapPages = /* @__PURE__ */ new Map([["meta", "meta-ads/leak-links"]]);
43342
- wiki = loadWiki(readWikiFiles(readWikiFolder()));
43584
+ mapPages = [{
43585
+ map: "meta",
43586
+ page: "meta-ads/leak-links",
43587
+ catalog: "links",
43588
+ rule: "rule"
43589
+ }, {
43590
+ map: "retention",
43591
+ page: "retention/map",
43592
+ catalog: "questions",
43593
+ rule: "dig-when"
43594
+ }];
43595
+ wiki$1 = loadWiki(readWikiFiles(readWikiFolder()));
43343
43596
  }));
43344
43597
  // src/harness/check-leaks.ts
43345
- var check_leaks_exports = /* @__PURE__ */ __exportAll({ run: () => run$20 });
43598
+ var check_leaks_exports = /* @__PURE__ */ __exportAll({ run: () => run$21 });
43346
43599
  function readSignals$2() {
43347
43600
  return readList$1(signals_default, "signals").map((signal) => ({
43348
43601
  key: readText$3(signal, "key"),
@@ -43361,8 +43614,8 @@ function listStageProblems(stage) {
43361
43614
  ...id.startsWith(prefix) ? [] : [`${id} is in ${name}, so its id should start with ${prefix}.`],
43362
43615
  ...role === "risk" && (hasSize || !hasRisk) ? [`${id} is in the risk stage ${name}, so it holds a risk and no size.`] : [],
43363
43616
  ...role !== "risk" && (!hasSize || hasRisk) ? [`${id} is in the ${role} stage ${name}, so it holds a size and no risk.`] : [],
43364
- ...listRepeated$1(readTexts(leak, "sources")).map((source) => `${id} lists the source ${source} twice.`),
43365
- ...listRepeated$1(readTexts(leak, "gates")).map((gate) => `${id} lists the gate ${gate} twice.`)
43617
+ ...listRepeated(readTexts(leak, "sources")).map((source) => `${id} lists the source ${source} twice.`),
43618
+ ...listRepeated(readTexts(leak, "gates")).map((gate) => `${id} lists the gate ${gate} twice.`)
43366
43619
  ];
43367
43620
  }), ...findBrandMarks(JSON.stringify(stage.value)).map((mark) => `${name} holds ${mark.found}, ${mark.name}. The library holds no brand's ids or findings.`)];
43368
43621
  }
@@ -43385,11 +43638,11 @@ function listSignalProblems(leaks, signals) {
43385
43638
  return [
43386
43639
  ...linked.filter((link) => !signalKeys.includes(link.signal)).map((link) => `${link.id} names the signal ${link.signal}, which isn't on the signal map.`),
43387
43640
  ...linked.filter((link) => offKeys.includes(link.signal)).map((link) => `${link.id} names the signal ${link.signal}, which is switched off and checks nothing.`),
43388
- ...listRepeated$1(linked.map((link) => link.signal)).map((signal) => `Two leaks name the signal ${signal}; a signal watches one leak.`)
43641
+ ...listRepeated(linked.map((link) => link.signal)).map((signal) => `Two leaks name the signal ${signal}; a signal watches one leak.`)
43389
43642
  ];
43390
43643
  }
43391
43644
  function checkStage(value) {
43392
- const problems = checkAgainstSchema(schemaFile$2, value, value.stage);
43645
+ const problems = checkAgainstSchema(schemaFile$1, value, value.stage);
43393
43646
  return {
43394
43647
  stage: {
43395
43648
  name: value.stage,
@@ -43399,7 +43652,7 @@ function checkStage(value) {
43399
43652
  problems
43400
43653
  };
43401
43654
  }
43402
- function run$20() {
43655
+ function run$21() {
43403
43656
  const library = readLeakStages();
43404
43657
  if (library.length === 0) throw new Error(`${leakLibraryAddress} holds no stage.`);
43405
43658
  const checked = library.map(checkStage);
@@ -43410,25 +43663,25 @@ function run$20() {
43410
43663
  const problems = [
43411
43664
  ...stages.flatMap(listStageProblems),
43412
43665
  ...listOrderProblems$1(stages),
43413
- ...listRepeated$1(stages.map((stage) => readText$3(stage.value, "prefix"))).map((prefix) => `Two stages use the prefix ${prefix}.`),
43414
- ...listRepeated$1(leaks.map((leak) => readText$3(leak, "id"))).map((id) => `${id} is the id of two leaks.`),
43666
+ ...listRepeated(stages.map((stage) => readText$3(stage.value, "prefix"))).map((prefix) => `Two stages use the prefix ${prefix}.`),
43667
+ ...listRepeated(leaks.map((leak) => readText$3(leak, "id"))).map((id) => `${id} is the id of two leaks.`),
43415
43668
  ...listSignalProblems(leaks, readSignals$2()),
43416
- ...listRepeated$1(readSignalChecks().map((check) => String(check.order))).map((order) => `Two signal checks have the order ${order}.`)
43669
+ ...listRepeated(readSignalChecks().map((check) => String(check.order))).map((order) => `Two signal checks have the order ${order}.`)
43417
43670
  ];
43418
43671
  if (problems.length > 0) throw new Error(`The leak library in ${leakLibraryAddress} has problems:\n${problems.join("\n")}`);
43419
43672
  const count = (field, value) => String(leaks.filter((leak) => readField(leak, field) === value).length);
43420
43673
  console.log(`${leakLibraryAddress} holds ${String(leaks.length)} leaks in ${String(stages.length)} stages: ${count("lane", "sure")} sure things, ${count("lane", "check")} quick checks and ${count("lane", "dig")} deep digs. ${String(leaks.filter((leak) => readField(leak, "isPlay") === true).length)} are missing plays and ${String(leaks.filter((leak) => readField(leak, "signal") !== null).length)} link a signal, with every id, prefix, signal and stage order resolved and no brand's own ids.`);
43421
43674
  }
43422
- var schemaFile$2;
43675
+ var schemaFile$1;
43423
43676
  var init_check_leaks = __esmMin((() => {
43424
43677
  init_brand_marks();
43425
43678
  init_json_schema();
43426
43679
  init_leak_library();
43427
43680
  init_stack();
43428
- schemaFile$2 = join(fromHarness(), "schema", "leaks.schema.json");
43681
+ schemaFile$1 = join(fromHarness(), "schema", "leaks.schema.json");
43429
43682
  }));
43430
43683
  // src/harness/check-limits.ts
43431
- var check_limits_exports = /* @__PURE__ */ __exportAll({ run: () => run$19 });
43684
+ var check_limits_exports = /* @__PURE__ */ __exportAll({ run: () => run$20 });
43432
43685
  function listStepLimits(schema, sourcePath) {
43433
43686
  return [
43434
43687
  {
@@ -43642,7 +43895,7 @@ function listMeasureShapeProblems() {
43642
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.`);
43643
43896
  });
43644
43897
  }
43645
- function run$19() {
43898
+ function run$20() {
43646
43899
  const sums = listSums();
43647
43900
  const shapeProblems = [...listOptionProblems(), ...listMeasureShapeProblems()];
43648
43901
  const drifted = [
@@ -43952,252 +44205,270 @@ var init_check_limits = __esmMin((() => {
43952
44205
  ];
43953
44206
  }));
43954
44207
  // src/harness/check-map.ts
43955
- var check_map_exports = /* @__PURE__ */ __exportAll({ run: () => run$18 });
43956
- function has(entry, field) {
43957
- return isFields$1(entry) && field in entry;
43958
- }
43959
- function readFields(source, field) {
43960
- const value = readField(source, field);
43961
- if (!isFields$1(value)) throw new Error(`${field} should be an object.`);
44208
+ var check_map_exports = /* @__PURE__ */ __exportAll({ run: () => run$19 });
44209
+ function has(record, field) {
44210
+ const value = record.fields[field];
44211
+ return value !== void 0 && value !== null;
44212
+ }
44213
+ function readValue$1(record, field) {
44214
+ if (!has(record, field)) throw new Error(`${record.id} has no ${field}.`);
44215
+ return record.fields[field];
44216
+ }
44217
+ function readWord$1(record, field) {
44218
+ const value = readValue$1(record, field);
44219
+ if (typeof value !== "string") throw new Error(`${record.id}'s ${field} should be text.`);
43962
44220
  return value;
43963
44221
  }
43964
- function readDeclarations(value) {
43965
- const layers = readFields(value, "layers");
43966
- const builder = readField(value, "tableBuilder");
43967
- if (builder !== null && typeof builder !== "string") throw new Error("tableBuilder should be text or null.");
43968
- return {
43969
- layers: new Map(Object.keys(layers).map((layer) => [layer, readText$3(layers, layer)])),
43970
- counts: Object.keys(readFields(readField(value, "words"), "counts")),
43971
- tables: Object.keys(readFields(value, "tables")),
43972
- builder,
43973
- sources: readTexts(value, "sources")
43974
- };
43975
- }
43976
- function listRepeated(names) {
43977
- return [...new Set(names.filter((name, index) => names.indexOf(name) !== index))];
43978
- }
43979
- function listDeclarationProblems(fileName, declarations) {
43980
- return [...listRepeated([...declarations.layers.values()]).map((letter) => `${fileName} gives the letter ${letter} to two layers.`), ...listRepeated(declarations.sources).map((source) => `${fileName} lists the source ${source} twice.`)];
43981
- }
43982
- function listTableMismatches(name, builder, tables, built) {
43983
- return [...tables.filter((table) => !built.includes(table)).map((table) => `${name} declares the table ${table}, which goose-staff harness ${builder} doesn't build. It builds ${built.join(", ")}.`), ...built.filter((table) => !tables.includes(table)).map((table) => `goose-staff harness ${builder} builds the table ${table}, which ${name} doesn't declare.`)];
44222
+ function readWords$1(record, field) {
44223
+ if (!has(record, field)) return [];
44224
+ const value = readValue$1(record, field);
44225
+ if (!Array.isArray(value)) throw new Error(`${record.id}'s ${field} should be a list.`);
44226
+ return value.map((item) => {
44227
+ if (typeof item !== "string") throw new Error(`${record.id}'s ${field} should hold text.`);
44228
+ return item;
44229
+ });
43984
44230
  }
43985
- function listBuilderProblems(fileName, declarations) {
43986
- const { builder, tables } = declarations;
43987
- if (builder === null) return [];
43988
- const built = tableBuilders.get(builder);
43989
- if (built === void 0) return [`${fileName} names the table builder ${builder}, which is no goose-staff harness command. The builders are ${[...tableBuilders.keys()].join(", ")}.`];
43990
- return listTableMismatches(fileName, builder, tables, built);
44231
+ function readPlace(record) {
44232
+ const value = readValue$1(record, "place");
44233
+ if (typeof value !== "number") throw new Error(`${record.id}'s place should be a number.`);
44234
+ return value;
43991
44235
  }
43992
- function readWikiTables() {
43993
- const { target } = resolveAddress(loadWiki(readWikiFiles(readWikiFolder())), wikiTablesAddress);
43994
- if (target.kind !== "block" || target.block.type !== "table") throw new Error(`${wikiTablesAddress} isn't a table block.`);
44236
+ function readTableRows(address) {
44237
+ const { target } = resolveAddress(wiki, address);
44238
+ if (target.kind !== "block" || target.block.type !== "table") throw new Error(`${address} isn't a table block.`);
43995
44239
  return target.block.rows.map((row) => {
43996
- const [name] = row;
43997
- if (name === void 0) throw new Error(`${wikiTablesAddress} holds an empty row.`);
43998
- return name;
44240
+ const [name, value] = row;
44241
+ if (name === void 0 || value === void 0) throw new Error(`${address} holds a row with fewer than 2 cells.`);
44242
+ return [name, value];
43999
44243
  });
44000
44244
  }
44001
- function listCallIds() {
44002
- return readdirSync(callsFolder).filter((fileName) => fileName.endsWith(".json")).flatMap((fileName) => readList$1(readJson$1(join(callsFolder, fileName)), "calls")).map((call) => readText$3(call, "id"));
44245
+ function readListItems(address) {
44246
+ const { target } = resolveAddress(wiki, address);
44247
+ if (target.kind !== "block" || target.block.type !== "list") throw new Error(`${address} isn't a list block.`);
44248
+ return target.block.items;
44003
44249
  }
44004
- function listFieldProblems(entry) {
44005
- const id = readText$3(entry, "id");
44006
- const tier = readText$3(entry, "tier");
44007
- const fields = tierFields.get(tier);
44008
- if (fields === void 0) throw new Error(`${id} has the tier ${tier}, which has no field list.`);
44009
- const problems = [...fields.required.filter((field) => !has(entry, field)).map((field) => `${id} is a ${fields.name} with no ${field}.`), ...fields.barred.filter((field) => has(entry, field)).map((field) => `${id} is a ${fields.name}, which holds no ${field}.`)];
44010
- if (tier === "deep" && has(entry, "status") === has(entry, "noStatus")) problems.push(`${id} should hold status rules or noStatus, and never both.`);
44011
- return problems;
44250
+ function readDeclarations() {
44251
+ return {
44252
+ layers: new Map(readTableRows(`${wordsAddress}#layers`)),
44253
+ counts: readTableRows(`${wordsAddress}#counts`).map(([name]) => name),
44254
+ tables: readTableRows(`${wordsAddress}#tables`).map(([name]) => name),
44255
+ sources: readListItems(`${wordsAddress}#sources`)
44256
+ };
44012
44257
  }
44013
- function listBranches(entry) {
44014
- if (has(entry, "branches")) return readList$1(entry, "branches");
44015
- return has(entry, "dig") ? readList$1(readField(entry, "dig"), "branches") : [];
44258
+ function listTableMismatches(address, builder, tables, built) {
44259
+ return [...tables.filter((table) => !built.includes(table)).map((table) => `${address} declares the table ${table}, which goose-staff harness ${builder} doesn't build. It builds ${built.join(", ")}.`), ...built.filter((table) => !tables.includes(table)).map((table) => `goose-staff harness ${builder} builds the table ${table}, which ${address} doesn't declare.`)];
44016
44260
  }
44017
- function listTargetProblems(entry, ids) {
44018
- const id = readText$3(entry, "id");
44019
- const needs = has(entry, "needs") ? readTexts(entry, "needs") : [];
44020
- const nexts = listBranches(entry).flatMap((branch) => readTexts(branch, "next"));
44261
+ function listDeclarationProblems(declarations) {
44021
44262
  return [
44022
- ...needs.filter((need) => !ids.includes(need)).map((need) => `${id} needs ${need}, which is no entry.`),
44023
- ...nexts.filter((next) => !ids.includes(next)).map((next) => `${id} has a branch to ${next}, which is no entry.`),
44024
- ...needs.includes(id) ? [`${id} needs itself.`] : []
44263
+ ...listRepeated([...declarations.layers.values()]).map((letter) => `${wordsAddress}#layers gives the letter ${letter} to two layers.`),
44264
+ ...[...declarations.layers.values()].filter((letter) => !/^[A-Z]$/u.test(letter)).map((letter) => `${wordsAddress}#layers gives ${letter}, which isn't one capital letter.`),
44265
+ ...listRepeated(declarations.sources).map((source) => `${wordsAddress}#sources lists the source ${source} twice.`),
44266
+ ...listRepeated(declarations.counts).map((count) => `${wordsAddress}#counts lists the count ${count} twice.`),
44267
+ ...listTableMismatches(`${wordsAddress}#tables`, retentionBuilder, declarations.tables, tableNames$1)
44025
44268
  ];
44026
44269
  }
44027
- function listReads$1(entry) {
44028
- return [...has(entry, "check") ? readTexts(readField(entry, "check"), "calls") : [], ...has(entry, "calls") ? readTexts(entry, "calls") : []];
44029
- }
44030
- function listTableProblems(id, read, declarations) {
44031
- const { builder, tables } = declarations;
44032
- if (!tables.includes(read.slice(6))) return [`${id} reads ${read}, which is no table this map declares. Its tables are ${tables.join(", ")}.`];
44033
- return builder === null ? [`${id} reads ${read}, but the map names no tableBuilder yet, so no table is built.`] : [];
44270
+ function listCallIds() {
44271
+ return readdirSync(callsFolder).filter((fileName) => fileName.endsWith(".json")).flatMap((fileName) => readList$1(readJson$1(join(callsFolder, fileName)), "calls")).map((call) => readText$3(call, "id"));
44034
44272
  }
44035
- function listReadProblems(entry, callIds, declarations) {
44036
- const id = readText$3(entry, "id");
44037
- return listReads$1(entry).flatMap((read) => {
44038
- if (read.startsWith(tablePrefix)) return listTableProblems(id, read, declarations);
44039
- return callIds.includes(read) ? [] : [`${id} reads ${read}, which is no call in catalog/calls. Name a call that has run, or list the read under callsToProve.`];
44040
- });
44273
+ function readLeakLibrary() {
44274
+ const leaks = readLeakStages().flatMap((stage) => stage.leaks);
44275
+ const signals = readList$1(signals_default, "signals");
44276
+ return {
44277
+ leakIds: leaks.map((leak) => leak.id),
44278
+ strictSignal: new Map(leaks.flatMap((leak) => typeof leak.signal === "string" ? [[leak.signal, leak.id]] : [])),
44279
+ signalKeys: signals.map((signal) => readText$3(signal, "key")),
44280
+ offKeys: signals.filter((signal) => readText$3(signal, "scope") === "off").map((signal) => readText$3(signal, "key"))
44281
+ };
44041
44282
  }
44042
- function findStatusRules(entry) {
44043
- const tier = readText$3(entry, "tier");
44044
- if (tier === "deep") return has(entry, "status") ? readField(entry, "status") : void 0;
44045
- if (tier === "ground" && readField(entry, "givesStatus") !== true) return void 0;
44046
- return readField(entry, "check");
44283
+ function readQuestionId(address) {
44284
+ const prefix = `${mapAddress}#`;
44285
+ return address.startsWith(prefix) ? address.slice(prefix.length) : null;
44047
44286
  }
44048
- function listStatusProblems(entry) {
44049
- const id = readText$3(entry, "id");
44050
- const rules = findStatusRules(entry);
44051
- if (rules === void 0) return [];
44052
- const problems = ["healthyWhen", "digWhen"].filter((field) => !number.test(readText$3(rules, field))).map((field) => `${id}'s ${field} holds no number.`);
44053
- if (!has(entry, "countOn")) problems.push(`${id} gives a status and names no count in countOn.`);
44054
- return problems;
44287
+ function listAddressProblems(where, addresses, context) {
44288
+ return addresses.filter((address) => {
44289
+ const id = readQuestionId(address);
44290
+ return id === null || !context.questions.has(id);
44291
+ }).map((address) => `${where} names ${address}, which is no question of ${mapAddress}.`);
44055
44292
  }
44056
- function listCostTestProblems(entry) {
44057
- if (!has(entry, "check")) return [];
44058
- const id = readText$3(entry, "id");
44059
- const check = readField(entry, "check");
44060
- const isRequired = readField(check, "costTestRequired") === true;
44061
- const branches = has(check, "costTestExempt") ? readList$1(check, "costTestExempt").map((exempt) => readText$3(exempt, "branch")) : [];
44062
- const problems = [];
44063
- if (isRequired && readText$3(entry, "tier") === "ground" && readField(entry, "givesStatus") !== true) problems.push(`${id} gives no status, so it can't require a cost test.`);
44064
- if (!isRequired && branches.length > 0) problems.push(`${id} requires no cost test, so it lists no exempt branches.`);
44065
- if (new Set(branches).size !== branches.length) problems.push(`${id} lists an exempt branch twice.`);
44066
- return problems;
44067
- }
44068
- function listCountProblems(entry, counts) {
44069
- if (!has(entry, "countOn")) return [];
44070
- const id = readText$3(entry, "id");
44071
- const countOn = readField(entry, "countOn");
44072
- const named = readTexts(countOn, "counts");
44073
- return [...named.length === 0 && !has(countOn, "note") ? [`${id} reads no count and has no note saying so.`] : [], ...named.filter((count) => !counts.includes(count)).map((count) => `${id} counts on ${count}, which is no count in words.counts. The counts are ${counts.join(", ")}.`)];
44293
+ function listFieldProblems(question) {
44294
+ const { entry, record } = question;
44295
+ const tier = readWord$1(record, "tier");
44296
+ const fields = tierFields.get(tier);
44297
+ if (fields === void 0) return [`${entry} has the tier ${tier}, which is no tier.`];
44298
+ return [
44299
+ ...fields.required.filter((field) => !has(record, field)).map((field) => `${entry} is a ${fields.name} with no ${field}.`),
44300
+ ...fields.barred.filter((field) => has(record, field)).map((field) => `${entry} is a ${fields.name}, which holds no ${field}.`),
44301
+ ...nonEmptyLists.filter((field) => has(record, field) && readWords$1(record, field).length === 0).map((field) => `${entry}'s ${field} is an empty list; give at least one.`),
44302
+ ...tier === "deep" && has(record, "healthy-when") === has(record, "no-status") ? [`${entry} should hold status rules or no-status, and never both.`] : []
44303
+ ];
44074
44304
  }
44075
- function listLayerProblems(entry, layers) {
44076
- const id = readText$3(entry, "id");
44077
- const layer = readText$3(entry, "layer");
44305
+ function listLayerProblems(question, layers) {
44306
+ const { entry, record } = question;
44307
+ const layer = readWord$1(record, "layer");
44078
44308
  const letter = layers.get(layer);
44079
- if (letter === void 0) return [`${id} is in the layer ${layer}, which the map doesn't declare. Its layers are ${[...layers.keys()].join(", ")}.`];
44080
- return id.startsWith(letter) ? [] : [`${id} is in the layer ${layer}, so its id should start with ${letter}.`];
44081
- }
44082
- function listSourceProblems(entry, sources) {
44083
- if (!has(entry, "callsToProve")) return [];
44084
- const id = readText$3(entry, "id");
44085
- return readList$1(entry, "callsToProve").map((proof) => readText$3(proof, "provider")).filter((provider) => !sources.includes(provider)).map((provider) => `${id} has a call to prove on ${provider}, which is no source this map declares. Its sources are ${sources.join(", ")}.`);
44309
+ if (letter === void 0) return [`${entry} is in the layer ${layer}, which ${wordsAddress}#layers doesn't declare. Its layers are ${[...layers.keys()].join(", ")}.`];
44310
+ return entry.startsWith(letter) ? [] : [`${entry} is in the layer ${layer}, so its id should start with ${letter}.`];
44086
44311
  }
44087
- function listOrderProblems(entries) {
44088
- const rules = entries.filter((entry) => readText$3(entry, "tier") === "ground").toSorted((one, other) => readNumber(one, "order") - readNumber(other, "order"));
44089
- return rules.flatMap((rule, index) => {
44090
- const id = readText$3(rule, "id");
44091
- const earlier = rules.slice(0, index).map((before) => readText$3(before, "id"));
44092
- const groundIds = rules.map((each) => readText$3(each, "id"));
44093
- return [...readNumber(rule, "order") === index + 1 ? [] : [`${id} has the order ${String(readNumber(rule, "order"))}, where ${String(index + 1)} comes next.`], ...readTexts(rule, "needs").filter((need) => groundIds.includes(need) && !earlier.includes(need)).map((need) => `${id} needs ${need}, which runs after it.`)];
44312
+ function listReadProblems(question, context) {
44313
+ return readWords$1(question.record, "calls").flatMap((read) => {
44314
+ if (read.startsWith(tablePrefix)) return context.declarations.tables.includes(read.slice(6)) ? [] : [`${question.entry} reads ${read}, which is no table ${wordsAddress}#tables declares. Its tables are ${context.declarations.tables.join(", ")}.`];
44315
+ return context.callIds.includes(read) ? [] : [`${question.entry} reads ${read}, which is no call in catalog/calls. Name a call that has run, or add it to ${mapAddress}#reads-to-prove.`];
44094
44316
  });
44095
44317
  }
44096
- function readLeakLibrary() {
44097
- const leaks = readLeakStages().flatMap((stage) => stage.leaks);
44098
- const signals = readList$1(signals_default, "signals");
44099
- return {
44100
- leakIds: leaks.map((leak) => readText$3(leak, "id")),
44101
- strictSignal: new Map(leaks.flatMap((leak) => {
44102
- const signal = readField(leak, "signal");
44103
- return typeof signal === "string" ? [[signal, readText$3(leak, "id")]] : [];
44104
- })),
44105
- signalKeys: signals.map((signal) => readText$3(signal, "key")),
44106
- offKeys: signals.filter((signal) => readText$3(signal, "scope") === "off").map((signal) => readText$3(signal, "key"))
44107
- };
44318
+ function hasStatusRules(record) {
44319
+ if (readWord$1(record, "tier") === "ground" && readValue$1(record, "gives-status") !== true) return false;
44320
+ return has(record, "healthy-when");
44108
44321
  }
44109
- function listLeakMapProblems(entry, library) {
44110
- if (!has(entry, "leakMap")) return [];
44111
- const id = readText$3(entry, "id");
44112
- const links = readField(entry, "leakMap");
44113
- const same = readTexts(links, "same");
44114
- const dig = readTexts(links, "dig");
44115
- const differs = has(links, "differs") ? readTexts(links, "differs") : [];
44322
+ function listStatusProblems(question) {
44323
+ const { entry, record } = question;
44324
+ if (!hasStatusRules(record)) return [];
44325
+ return [
44326
+ ...["healthy-when", "dig-when"].filter((field) => !number.test(readWord$1(record, field))).map((field) => `${entry}'s ${field} holds no number.`),
44327
+ ...["cost-test", "not-read"].filter((field) => !has(record, field)).map((field) => `${entry} gives a status and has no ${field}.`),
44328
+ ...has(record, "counts") ? [] : [`${entry} gives a status and names no counts.`]
44329
+ ];
44330
+ }
44331
+ function listCostTestProblems(question, context) {
44332
+ const { entry, record } = question;
44333
+ if (!has(record, "cost-test-required")) return [];
44334
+ const isRequired = readValue$1(record, "cost-test-required") === true;
44335
+ const exempt = context.exempts.filter((item) => item.fields.question === question.id);
44336
+ return [...isRequired && readWord$1(record, "tier") === "ground" && readValue$1(record, "gives-status") !== true ? [`${entry} gives no status, so it can't require a cost test.`] : [], ...!isRequired && exempt.length > 0 ? [`${entry} requires no cost test, so it has no dig branches exempt from one.`] : []];
44337
+ }
44338
+ function listCountProblems(question, counts) {
44339
+ const { entry, record } = question;
44340
+ if (!has(record, "counts")) return has(record, "count-note") ? [`${entry} has a count note and no counts.`] : [];
44341
+ const named = readWords$1(record, "counts");
44342
+ return [...named.length === 0 && !has(record, "count-note") ? [`${entry} reads no count and has no count note saying so.`] : [], ...named.filter((count) => !counts.includes(count)).map((count) => `${entry} counts on ${count}, which ${wordsAddress}#counts doesn't declare. The counts are ${counts.join(", ")}.`)];
44343
+ }
44344
+ function listOutputProblems(question) {
44345
+ return readWords$1(question.record, "output-kinds").filter((kind) => !outputKinds.includes(kind)).map((kind) => `${question.entry} files ${kind}, which is none of ${outputKinds.join(", ")}.`);
44346
+ }
44347
+ function listLinkProblems(question, library) {
44348
+ const { entry, record } = question;
44349
+ const same = readWords$1(record, "same");
44350
+ const dig = readWords$1(record, "dig");
44351
+ const differs = readWords$1(record, "differs");
44116
44352
  const firstPass = [...same, ...differs];
44117
44353
  return [
44118
- ...firstPass.length + dig.length === 0 ? [`${id} has a leakMap with no links; leave it out instead.`] : [],
44119
- ...readText$3(entry, "tier") === "deep" && firstPass.length > 0 ? [`${id} is a deep question, so it links leaks as dig, never same or differs.`] : [],
44120
- ...firstPass.filter((link) => dig.includes(link)).map((link) => `${id} links ${link} as both a check and dig.`),
44121
- ...same.filter((link) => differs.includes(link)).map((link) => `${id} links ${link} as both same and differs.`),
44354
+ ...readWord$1(record, "tier") === "deep" && firstPass.length > 0 ? [`${entry} is a deep question, so it links leaks as dig, never same or differs.`] : [],
44355
+ ...firstPass.filter((link) => dig.includes(link)).map((link) => `${entry} links ${link} as both a check and dig.`),
44356
+ ...same.filter((link) => differs.includes(link)).map((link) => `${entry} links ${link} as both same and differs.`),
44122
44357
  ...[
44123
44358
  ...listRepeated(same),
44124
44359
  ...listRepeated(dig),
44125
44360
  ...listRepeated(differs)
44126
- ].map((link) => `${id} links ${link} twice in one list.`),
44361
+ ].map((link) => `${entry} links ${link} twice in one list.`),
44127
44362
  ...[...firstPass, ...dig].flatMap((link) => {
44128
- if (leakId.test(link)) return library.leakIds.includes(link) ? [] : [`${id} links the leak ${link}, which isn't in ${leakLibraryAddress}.`];
44129
- if (!library.signalKeys.includes(link)) return [`${id} links the signal ${link}, which isn't on the signal map.`];
44130
- if (library.offKeys.includes(link)) return [`${id} links the signal ${link}, which is switched off.`];
44363
+ if (leakId.test(link)) return library.leakIds.includes(link) ? [] : [`${entry} links the leak ${link}, which isn't in ${leakLibraryAddress}.`];
44364
+ if (!library.signalKeys.includes(link)) return [`${entry} links the signal ${link}, which isn't on the signal map.`];
44365
+ if (library.offKeys.includes(link)) return [`${entry} links the signal ${link}, which is switched off.`];
44131
44366
  const leak = library.strictSignal.get(link);
44132
- return leak === void 0 ? [] : [`${id} links the signal ${link}; link the leak ${leak}, which owns it.`];
44367
+ return leak === void 0 ? [] : [`${entry} links the signal ${link}; link the leak ${leak}, which owns it.`];
44133
44368
  })
44134
44369
  ];
44135
44370
  }
44136
- function listBrandProblems(fileName) {
44137
- return findBrandMarks(readFileSync(join(mapsFolder$1, fileName), "utf8")).map((mark) => `${fileName} holds ${mark.found}, ${mark.name}. A map holds no brand's ids or findings.`);
44371
+ function listQuestionProblems(question, context) {
44372
+ const { entry, record } = question;
44373
+ const fieldProblems = listFieldProblems(question);
44374
+ if (fieldProblems.length > 0) return fieldProblems;
44375
+ const needs = readWords$1(record, "needs");
44376
+ return [
44377
+ ...questionId.test(entry) ? [] : [`${entry} isn't a layer's letter and a number.`],
44378
+ ...listLayerProblems(question, context.declarations.layers),
44379
+ ...listAddressProblems(`${entry}'s needs`, needs, context),
44380
+ ...needs.includes(`${mapAddress}#${question.id}`) ? [`${entry} needs itself.`] : [],
44381
+ ...context.branches.some((branch) => branch.fields.question === question.id) ? [] : [`${entry} has no branch in ${mapAddress}#branches.`],
44382
+ ...listReadProblems(question, context),
44383
+ ...listStatusProblems(question),
44384
+ ...listCostTestProblems(question, context),
44385
+ ...listCountProblems(question, context.declarations.counts),
44386
+ ...listOutputProblems(question),
44387
+ ...listLinkProblems(question, context.library)
44388
+ ];
44389
+ }
44390
+ function listOwnerProblems(catalog, records, context) {
44391
+ return records.filter((record) => {
44392
+ const owner = record.fields.question;
44393
+ return typeof owner !== "string" || !context.questions.has(owner);
44394
+ }).map((record) => `${mapAddress}#${record.id} in ${catalog} belongs to no question of the map.`);
44395
+ }
44396
+ function listPlaceProblems(catalog, records) {
44397
+ return [...Map.groupBy(records, (record) => readWord$1(record, "question"))].flatMap(([owner, held]) => {
44398
+ const places = held.map(readPlace).toSorted((one, other) => one - other);
44399
+ return places.every((place, index) => place === index + 1) ? [] : [`${owner}'s ${catalog} are placed ${places.join(", ")}; number them from 1 with no gaps.`];
44400
+ });
44401
+ }
44402
+ function listBranchProblems(context) {
44403
+ return context.branches.flatMap((branch) => listAddressProblems(`${mapAddress}#${branch.id}`, readWords$1(branch, "next"), context));
44404
+ }
44405
+ function listProofProblems(context) {
44406
+ return context.proofs.map((proof) => readWord$1(proof, "provider")).filter((provider) => !context.declarations.sources.includes(provider)).map((provider) => `A read to prove names ${provider}, which ${wordsAddress}#sources doesn't list. Its sources are ${context.declarations.sources.join(", ")}.`);
44407
+ }
44408
+ function listOrderProblems(questions) {
44409
+ const rules = questions.filter((question) => readWord$1(question.record, "tier") === "ground").map((question) => {
44410
+ const order = readValue$1(question.record, "order");
44411
+ if (typeof order !== "number") throw new Error(`${question.entry}'s order should be a number.`);
44412
+ return {
44413
+ question,
44414
+ order
44415
+ };
44416
+ }).toSorted((one, other) => one.order - other.order);
44417
+ const ruleIds = rules.map((rule) => `${mapAddress}#${rule.question.id}`);
44418
+ return rules.flatMap((rule, index) => [...rule.order === index + 1 ? [] : [`${rule.question.entry} has the order ${String(rule.order)}, where ${String(index + 1)} comes next.`], ...readWords$1(rule.question.record, "needs").filter((need) => ruleIds.includes(need) && !ruleIds.slice(0, index).includes(need)).map((need) => `${rule.question.entry} needs ${need}, which runs after it.`)]);
44138
44419
  }
44139
- function checkMap(fileName, callIds, library) {
44140
- const value = readJson$1(join(mapsFolder$1, fileName));
44141
- const schemaProblems = checkAgainstSchema(schemaFile$1, value, fileName);
44142
- if (schemaProblems.length > 0) return {
44143
- entries: [],
44144
- problems: schemaProblems
44145
- };
44146
- const entries = readList$1(value, "entries");
44147
- const fieldProblems = entries.flatMap(listFieldProblems);
44148
- if (fieldProblems.length > 0) return {
44149
- entries: [],
44150
- problems: fieldProblems
44151
- };
44152
- const declarations = readDeclarations(value);
44153
- const ids = entries.map((entry) => readText$3(entry, "id"));
44154
- const name = basename(fileName, ".json");
44155
- return {
44156
- entries,
44157
- problems: [
44158
- ...readText$3(value, "map") === name ? [] : [`${fileName} should say its map is ${name}.`],
44159
- ...listDeclarationProblems(fileName, declarations),
44160
- ...listBuilderProblems(fileName, declarations),
44161
- ...listRepeated(ids).map((id) => `${id} is the id of two entries.`),
44162
- ...entries.flatMap((entry) => [
44163
- ...listLayerProblems(entry, declarations.layers),
44164
- ...listTargetProblems(entry, ids),
44165
- ...listReadProblems(entry, callIds, declarations),
44166
- ...listSourceProblems(entry, declarations.sources),
44167
- ...listStatusProblems(entry),
44168
- ...listCostTestProblems(entry),
44169
- ...listCountProblems(entry, declarations.counts),
44170
- ...listLeakMapProblems(entry, library)
44171
- ]),
44172
- ...listOrderProblems(entries),
44173
- ...listBrandProblems(fileName)
44174
- ]
44175
- };
44420
+ function listBrandProblems() {
44421
+ return [...readWikiFiles(readWikiFolder())].filter(([path]) => path.startsWith("retention/")).flatMap(([path, text]) => findBrandMarks(text).map((mark) => `${path} holds ${mark.found}, ${mark.name}. A map holds no brand's ids or findings.`));
44176
44422
  }
44177
- function countTier(entries, tier) {
44178
- return String(entries.filter((entry) => readText$3(entry, "tier") === tier).length);
44423
+ function readMetaTables() {
44424
+ return readTableRows(metaTablesAddress).map(([name]) => name);
44179
44425
  }
44180
- function describeMap(fileName, entries) {
44181
- const calls = new Set(entries.flatMap(listReads$1).filter((read) => !read.startsWith(tablePrefix)));
44182
- const toProve = entries.flatMap((entry) => has(entry, "callsToProve") ? readList$1(entry, "callsToProve") : []);
44183
- return `catalog/maps/${fileName} holds ${countTier(entries, "ground")} ground rules, ${countTier(entries, "first")} first-pass checks and ${countTier(entries, "deep")} deep questions. They name ${String(calls.size)} calls from catalog/calls and list ${String(toProve.length)} reads still to prove, with every id, layer, count, table and source resolved and no brand's own ids.`;
44426
+ function countTier(questions, tier) {
44427
+ return String(questions.filter((question) => readWord$1(question.record, "tier") === tier).length);
44184
44428
  }
44185
- function run$18() {
44186
- const callIds = listCallIds();
44187
- const library = readLeakLibrary();
44188
- const files = readdirSync(mapsFolder$1).filter((fileName) => fileName.endsWith(".json"));
44189
- if (files.length === 0) throw new Error("catalog/maps holds no map.");
44190
- const checked = files.map((fileName) => ({
44191
- fileName,
44192
- ...checkMap(fileName, callIds, library)
44193
- }));
44194
- const wikiTables = readWikiTables();
44195
- const problems = [...checked.flatMap((map) => map.problems), ...listTableMismatches(wikiTablesAddress, "meta-tables", wikiTables, tableNames)];
44196
- if (problems.length > 0) throw new Error(`The maps in catalog/maps have problems:\n${problems.join("\n")}`);
44197
- for (const map of checked) console.log(describeMap(map.fileName, map.entries));
44198
- console.log(`${wikiTablesAddress} names the ${String(wikiTables.length)} tables goose-staff harness meta-tables builds.`);
44429
+ function describeMap(questions, context) {
44430
+ const calls = new Set(questions.flatMap((question) => readWords$1(question.record, "calls")).filter((read) => !read.startsWith(tablePrefix)));
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.`;
44199
44432
  }
44200
- var harnessFolder$1, mapsFolder$1, callsFolder, tableBuilders, schemaFile$1, leakId, tablePrefix, wikiTablesAddress, number, tierFields;
44433
+ function run$19() {
44434
+ const questions = listCatalogRecords(wiki, `${mapAddress}#questions`).map((record) => ({
44435
+ id: record.id,
44436
+ entry: readWord$1(record, "entry"),
44437
+ record
44438
+ }));
44439
+ const context = {
44440
+ questions: new Map(questions.map((question) => [question.id, question])),
44441
+ declarations: readDeclarations(),
44442
+ callIds: listCallIds(),
44443
+ library: readLeakLibrary(),
44444
+ branches: listCatalogRecords(wiki, `${mapAddress}#branches`),
44445
+ exempts: listCatalogRecords(wiki, `${mapAddress}#exempt-branches`),
44446
+ proofs: listCatalogRecords(wiki, `${mapAddress}#reads-to-prove`)
44447
+ };
44448
+ const benchmarks = listCatalogRecords(wiki, `${mapAddress}#benchmarks`);
44449
+ const metaTables = readMetaTables();
44450
+ const problems = [
44451
+ ...questions.filter((question) => question.id !== question.entry.toLowerCase()).map((question) => `${mapAddress}#${question.id} holds the entry ${question.entry}; they should match.`),
44452
+ ...listDeclarationProblems(context.declarations),
44453
+ ...questions.flatMap((question) => listQuestionProblems(question, context)),
44454
+ ...listOwnerProblems("branches", context.branches, context),
44455
+ ...listOwnerProblems("benchmarks", benchmarks, context),
44456
+ ...listOwnerProblems("reads-to-prove", context.proofs, context),
44457
+ ...listOwnerProblems("exempt-branches", context.exempts, context),
44458
+ ...listPlaceProblems("branches", context.branches),
44459
+ ...listPlaceProblems("benchmarks", benchmarks),
44460
+ ...listPlaceProblems("reads-to-prove", context.proofs),
44461
+ ...listBranchProblems(context),
44462
+ ...listProofProblems(context),
44463
+ ...listOrderProblems(questions),
44464
+ ...listBrandProblems(),
44465
+ ...listTableMismatches(metaTablesAddress, "meta-tables", metaTables, tableNames)
44466
+ ];
44467
+ if (problems.length > 0) throw new Error(`The retention map has problems:\n${problems.join("\n")}`);
44468
+ console.log(describeMap(questions, context));
44469
+ console.log(`${metaTablesAddress} names the ${String(metaTables.length)} tables goose-staff harness meta-tables builds.`);
44470
+ }
44471
+ var callsFolder, mapAddress, wordsAddress, metaTablesAddress, retentionBuilder, leakId, questionId, tablePrefix, number, outputKinds, checkFields, digFields, nonEmptyLists, tierFields, wiki;
44201
44472
  var init_check_map = __esmMin((() => {
44202
44473
  init_src();
44203
44474
  init_wiki_folder();
@@ -44207,85 +44478,97 @@ var init_check_map = __esmMin((() => {
44207
44478
  init_leak_library();
44208
44479
  init_meta_tables_shape();
44209
44480
  init_stack();
44210
- harnessFolder$1 = fromHarness();
44211
- mapsFolder$1 = join(harnessFolder$1, "catalog", "maps");
44212
- callsFolder = join(harnessFolder$1, "catalog", "calls");
44213
- tableBuilders = /* @__PURE__ */ new Map([["meta-tables", tableNames], ["customer-tables", tableNames$1]]);
44214
- schemaFile$1 = join(harnessFolder$1, "schema", "map.schema.json");
44481
+ callsFolder = join(fromHarness(), "catalog", "calls");
44482
+ mapAddress = "retention/map";
44483
+ wordsAddress = "retention/words";
44484
+ metaTablesAddress = "meta-ads/counts-and-tables#tables";
44485
+ retentionBuilder = "customer-tables";
44215
44486
  leakId = /^[A-Z]{2}[0-9]{1,2}$/u;
44487
+ questionId = /^[A-Z][0-9]{1,2}$/u;
44216
44488
  tablePrefix = "table:";
44217
- wikiTablesAddress = "meta-ads/counts-and-tables#tables";
44218
44489
  number = /[0-9]/u;
44490
+ outputKinds = [
44491
+ "fact",
44492
+ "finding:leak",
44493
+ "finding:test",
44494
+ "finding:know",
44495
+ "ask"
44496
+ ];
44497
+ checkFields = [
44498
+ "calls",
44499
+ "healthy-when",
44500
+ "dig-when",
44501
+ "cost-test",
44502
+ "cost-test-required",
44503
+ "not-read"
44504
+ ];
44505
+ digFields = [
44506
+ "steps",
44507
+ "controls",
44508
+ "stop-when"
44509
+ ];
44510
+ nonEmptyLists = [
44511
+ "reads",
44512
+ "writes",
44513
+ "calls",
44514
+ "method",
44515
+ "traps",
44516
+ "steps"
44517
+ ];
44219
44518
  tierFields = /* @__PURE__ */ new Map([
44220
44519
  ["ground", {
44221
44520
  name: "ground rule",
44222
44521
  required: [
44223
44522
  "order",
44224
- "givesStatus",
44225
- "needs",
44226
- "countOn",
44227
- "minData",
44523
+ "gives-status",
44524
+ "counts",
44525
+ "min-data",
44228
44526
  "writes",
44229
44527
  "rule",
44230
- "check",
44528
+ ...checkFields,
44231
44529
  "memory",
44232
- "dig",
44233
- "sizeHow",
44234
- "output"
44530
+ ...digFields,
44531
+ "size-how"
44235
44532
  ],
44236
- barred: [
44237
- "calls",
44238
- "method",
44239
- "branches",
44240
- "controls",
44241
- "stopWhen",
44242
- "status",
44243
- "noStatus"
44244
- ]
44533
+ barred: ["method", "no-status"]
44245
44534
  }],
44246
44535
  ["first", {
44247
44536
  name: "first-pass check",
44248
44537
  required: [
44249
- "needs",
44250
- "countOn",
44251
- "minData",
44252
- "check",
44538
+ "counts",
44539
+ "min-data",
44540
+ ...checkFields,
44253
44541
  "memory",
44254
- "dig",
44255
- "sizeHow",
44256
- "output"
44542
+ ...digFields,
44543
+ "size-how"
44257
44544
  ],
44258
44545
  barred: [
44259
44546
  "order",
44260
- "givesStatus",
44547
+ "gives-status",
44261
44548
  "writes",
44262
44549
  "rule",
44263
- "calls",
44264
44550
  "method",
44265
- "branches",
44266
- "controls",
44267
- "stopWhen",
44268
- "status",
44269
- "noStatus"
44551
+ "no-status"
44270
44552
  ]
44271
44553
  }],
44272
44554
  ["deep", {
44273
44555
  name: "deep question",
44274
- required: ["method", "branches"],
44556
+ required: ["method"],
44275
44557
  barred: [
44276
44558
  "order",
44277
- "givesStatus",
44559
+ "gives-status",
44278
44560
  "writes",
44279
44561
  "rule",
44280
- "check",
44281
- "dig",
44282
- "memory"
44562
+ "cost-test-required",
44563
+ "memory",
44564
+ "steps"
44283
44565
  ]
44284
44566
  }]
44285
44567
  ]);
44568
+ wiki = loadWiki(readWikiFiles(readWikiFolder()));
44286
44569
  }));
44287
44570
  // src/harness/check-skills.ts
44288
- var check_skills_exports = /* @__PURE__ */ __exportAll({ run: () => run$17 });
44571
+ var check_skills_exports = /* @__PURE__ */ __exportAll({ run: () => run$18 });
44289
44572
  function showPath$2(path) {
44290
44573
  return relative(stackRoot, path);
44291
44574
  }
@@ -44551,7 +44834,7 @@ function checkReference(path) {
44551
44834
  ...checkLinks(page)
44552
44835
  ];
44553
44836
  }
44554
- function run$17() {
44837
+ function run$18() {
44555
44838
  const skills = readFolder(skillsFolder);
44556
44839
  if (skills.folders.length === 0) throw new Error(`${showPath$2(skillsFolder)} holds no skill.`);
44557
44840
  const agents = readFolder(agentsFolder);
@@ -45154,7 +45437,7 @@ var init_signal_map = __esmMin((() => {
45154
45437
  new Map(signalMap.signals.map((signal) => [signal.key, signal]));
45155
45438
  }));
45156
45439
  // src/harness/check-watch-list.ts
45157
- var check_watch_list_exports = /* @__PURE__ */ __exportAll({ run: () => run$16 });
45440
+ var check_watch_list_exports = /* @__PURE__ */ __exportAll({ run: () => run$17 });
45158
45441
  function checkGuides(groups) {
45159
45442
  const vendors = groups.flatMap((group) => group.vendors);
45160
45443
  const named = new Set(vendors.flatMap((vendor) => vendor.guide === null ? [] : [vendor.guide]));
@@ -45168,7 +45451,7 @@ function checkGuides(groups) {
45168
45451
  }
45169
45452
  return problems;
45170
45453
  }
45171
- function run$16() {
45454
+ function run$17() {
45172
45455
  const problems = checkGuides(signalMap.groups);
45173
45456
  if (problems.length > 0) {
45174
45457
  console.error(`The signal map's groups don't fit the harness:\n${problems.map((problem) => `- ${problem}`).join("\n")}`);
@@ -45208,7 +45491,7 @@ var init_leak_rules = __esmMin((() => {
45208
45491
  ];
45209
45492
  }));
45210
45493
  // src/harness/check-words.ts
45211
- var check_words_exports = /* @__PURE__ */ __exportAll({ run: () => run$15 });
45494
+ var check_words_exports = /* @__PURE__ */ __exportAll({ run: () => run$16 });
45212
45495
  function readCallInput(call) {
45213
45496
  const input = call["~orpc"].inputSchema;
45214
45497
  if (input === void 0) throw new Error("This contract call takes no input.");
@@ -45307,7 +45590,7 @@ function checkConfirmProof(verdict, proof) {
45307
45590
  check: []
45308
45591
  };
45309
45592
  return {
45310
- mustFix: verdict === "fixed" ? listProofProblems("proof", proof) : applyRules(leakRules, "The proof", proof),
45593
+ mustFix: verdict === "fixed" ? listProofProblems$1("proof", proof) : applyRules(leakRules, "The proof", proof),
45311
45594
  check: []
45312
45595
  };
45313
45596
  }
@@ -45346,7 +45629,7 @@ function listLines(problems) {
45346
45629
  function isKind(name) {
45347
45630
  return wordKinds.some((kind) => kind === name);
45348
45631
  }
45349
- function run$15(args) {
45632
+ function run$16(args) {
45350
45633
  const [kind, path] = args;
45351
45634
  if (kind === void 0 || path === void 0 || !isKind(kind)) throw new Error(`Run it as: goose-staff harness check-words <${wordKinds.join("|")}> <file>`);
45352
45635
  const { file, text } = readFile$2(path);
@@ -45379,7 +45662,7 @@ var init_check_words = __esmMin((() => {
45379
45662
  };
45380
45663
  }));
45381
45664
  // src/harness/customer-tables.ts
45382
- var customer_tables_exports = /* @__PURE__ */ __exportAll({ run: () => run$14 });
45665
+ var customer_tables_exports = /* @__PURE__ */ __exportAll({ run: () => run$15 });
45383
45666
  function toPhone(value) {
45384
45667
  return value.replaceAll(/\D/gu, "");
45385
45668
  }
@@ -45751,7 +46034,7 @@ function buildCohorts$1(inputs, orders, storeDays, customers, personOf) {
45751
46034
  });
45752
46035
  }).toSorted((one, other) => toCohortKey(one).localeCompare(toCohortKey(other)));
45753
46036
  }
45754
- function describeBand(stage, gaps) {
46037
+ function describeBand$1(stage, gaps) {
45755
46038
  if (gaps === void 0) return {};
45756
46039
  const band = (/* @__PURE__ */ new Map([
45757
46040
  ["active", [void 0, gaps.median]],
@@ -45779,12 +46062,12 @@ function buildStages(customers, summaries) {
45779
46062
  customers: members.length,
45780
46063
  share: divide(members.length, inStep.length, 4),
45781
46064
  renewing: members.filter((customer) => typeof customer.last_renewal_day === "string" && customer.last_renewal_day > readCell(customer, "last_order_day")).length,
45782
- ...step === "all" ? {} : describeBand(stage, summaries.get(step))
46065
+ ...step === "all" ? {} : describeBand$1(stage, summaries.get(step))
45783
46066
  };
45784
46067
  });
45785
46068
  });
45786
46069
  }
45787
- function run$14(args) {
46070
+ function run$15(args) {
45788
46071
  const [inputsPath, outputPath] = args;
45789
46072
  if (inputsPath === void 0 || outputPath === void 0) throw new Error("Run it as: goose-staff harness customer-tables <inputs file> <output folder>");
45790
46073
  const { inputs, joinsNothing } = readInputs$1(inputsPath);
@@ -46583,7 +46866,7 @@ var init_rule_history = __esmMin((() => {
46583
46866
  // src/harness/rule-date.ts
46584
46867
  var rule_date_exports = /* @__PURE__ */ __exportAll({
46585
46868
  historyVariable: () => historyVariable,
46586
- run: () => run$13
46869
+ run: () => run$14
46587
46870
  });
46588
46871
  function readArguments$7(args) {
46589
46872
  const { values, positionals } = parseArgs({
@@ -46598,7 +46881,7 @@ function readArguments$7(args) {
46598
46881
  strict: true,
46599
46882
  allowPositionals: true
46600
46883
  });
46601
- 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);
46602
46885
  return {
46603
46886
  words: values.words.map((text) => requireRuleWords(text)),
46604
46887
  checkout: values.checkout
@@ -46622,7 +46905,7 @@ function printDates(words, history) {
46622
46905
  }
46623
46906
  }
46624
46907
  }
46625
- function run$13(args) {
46908
+ function run$14(args) {
46626
46909
  const { words, checkout } = readArguments$7(args);
46627
46910
  if (checkout === void 0) {
46628
46911
  printDates(words, findHistory());
@@ -46637,16 +46920,16 @@ function run$13(args) {
46637
46920
  rmSync(folder, { recursive: true });
46638
46921
  }
46639
46922
  }
46640
- var historyVariable, usage$7;
46923
+ var historyVariable, usage$8;
46641
46924
  var init_rule_date = __esmMin((() => {
46642
46925
  init_rule_history();
46643
46926
  init_rule_words();
46644
46927
  init_stack();
46645
46928
  historyVariable = "GOOSESTACK_RULE_HISTORY";
46646
- 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>]";
46647
46930
  }));
46648
46931
  // src/harness/dream-run.ts
46649
- var dream_run_exports = /* @__PURE__ */ __exportAll({ run: () => run$12 });
46932
+ var dream_run_exports = /* @__PURE__ */ __exportAll({ run: () => run$13 });
46650
46933
  function readArguments$6(values) {
46651
46934
  const found = /* @__PURE__ */ new Map();
46652
46935
  const from = [];
@@ -46658,18 +46941,18 @@ function readArguments$6(values) {
46658
46941
  continue;
46659
46942
  }
46660
46943
  const value = values[index + 1];
46661
- 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}`);
46662
46945
  index += 1;
46663
46946
  if (flag === "--from") {
46664
46947
  from.push(resolve(value));
46665
46948
  continue;
46666
46949
  }
46667
- if (!valueFlags$1.has(flag)) throw new Error(`${flag} isn't an argument this takes.\n${usage$6}`);
46668
- 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}`);
46669
46952
  found.set(flag, value);
46670
46953
  }
46671
46954
  const missing = [...valueFlags$1].filter((flag) => !found.has(flag));
46672
- 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}`);
46673
46956
  const get = (flag) => String(found.get(flag));
46674
46957
  const timeZone = get("--time-zone");
46675
46958
  const budgetUsd = Number(get("--budget-usd"));
@@ -47083,7 +47366,7 @@ function setAside(options, error) {
47083
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`);
47084
47367
  appendFileSync(join(options.dreamRoot, "costs.md"), `- ${options.night}: failed, see ${join(failed, "failure.md")}\n`);
47085
47368
  }
47086
- function run$12(args) {
47369
+ function run$13(args) {
47087
47370
  const options = readArguments$6(args);
47088
47371
  const stack = readStackFolder();
47089
47372
  const unlanded = options.isLanding ? findUnlanded(options) : void 0;
@@ -47227,7 +47510,7 @@ function recordNight(options, runFolder, heldStack, kept, cost, { summary, nextL
47227
47510
  appendFileSync(join(options.dreamRoot, "costs.md"), `- ${options.night}: $${cost.toFixed(2)}, ${String(kept)} sessions, ${String(built.landed.length)} changes\n`);
47228
47511
  console.log(`${join(runFolder, "summary.md")} holds the morning summary.`);
47229
47512
  }
47230
- 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;
47231
47514
  var init_dream_run = __esmMin((() => {
47232
47515
  init_dream_branches();
47233
47516
  init_dream_changes();
@@ -47239,7 +47522,7 @@ var init_dream_run = __esmMin((() => {
47239
47522
  init_rule_date();
47240
47523
  init_rule_history();
47241
47524
  init_stack();
47242
- 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]";
47243
47526
  valueFlags$1 = /* @__PURE__ */ new Set([
47244
47527
  "--night",
47245
47528
  "--time-zone",
@@ -47429,9 +47712,9 @@ var init_build_agents = __esmMin((() => {
47429
47712
  ];
47430
47713
  }));
47431
47714
  // src/harness/install.ts
47432
- var install_exports = /* @__PURE__ */ __exportAll({ run: () => run$11 });
47715
+ var install_exports = /* @__PURE__ */ __exportAll({ run: () => run$12 });
47433
47716
  function readFolderFlag(value, flag) {
47434
- 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}`);
47435
47718
  const folder = resolve(value);
47436
47719
  if (!existsSync(folder) || !statSync(folder).isDirectory()) throw new Error(`${flag} names ${folder}, which isn't a folder. Make it first.`);
47437
47720
  return folder;
@@ -47448,7 +47731,7 @@ function readArguments$5(args) {
47448
47731
  strict: true,
47449
47732
  allowPositionals: true
47450
47733
  });
47451
- if (positionals.length > 0) throw new Error(usage$5);
47734
+ if (positionals.length > 0) throw new Error(usage$6);
47452
47735
  return {
47453
47736
  folders: {
47454
47737
  claudeDir: readFolderFlag(values["claude-dir"], "--claude-dir"),
@@ -47558,7 +47841,7 @@ function applyPlan(plan) {
47558
47841
  writeFileSync(file.path, file.text);
47559
47842
  }
47560
47843
  }
47561
- function run$11(args) {
47844
+ function run$12(args) {
47562
47845
  const { folders, isCheck } = readArguments$5(args);
47563
47846
  const { plan, skillCount, agentCount } = makePlan(folders);
47564
47847
  refuseBlocked(plan);
@@ -47575,11 +47858,11 @@ function run$11(args) {
47575
47858
  applyPlan(plan);
47576
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.`);
47577
47860
  }
47578
- var usage$5;
47861
+ var usage$6;
47579
47862
  var init_install = __esmMin((() => {
47580
47863
  init_build_agents();
47581
47864
  init_stack();
47582
- 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]";
47583
47866
  }));
47584
47867
  // src/harness/leak-selector.ts
47585
47868
  function lower(text) {
@@ -47897,31 +48180,7 @@ function readGroups$1() {
47897
48180
  return new Map(readList$1(signal_groups_default, "groups").map((group) => [readText$3(group, "key"), readList$1(group, "vendors").map((vendor) => readText$3(vendor, "key"))]));
47898
48181
  }
47899
48182
  function readMaps() {
47900
- const files = readdirSync(mapsFolder).filter((fileName) => fileName.endsWith(".json")).map((fileName) => ({
47901
- map: basename(fileName, ".json"),
47902
- file: `harness/catalog/maps/${fileName}`,
47903
- entries: readList$1(readJson$1(join(mapsFolder, fileName)), "entries").map((entry) => {
47904
- const links = readOptional(entry, "leakMap");
47905
- const check = readOptional(entry, "check");
47906
- return {
47907
- id: readText$3(entry, "id"),
47908
- tier: readText$3(entry, "tier"),
47909
- title: readText$3(entry, "title"),
47910
- rule: check === null ? null : readOptionalText(check, "digWhen"),
47911
- same: links === null ? [] : readTexts(links, "same"),
47912
- dig: links === null ? [] : readTexts(links, "dig"),
47913
- differs: links === null || readOptional(links, "differs") === null ? [] : readTexts(links, "differs")
47914
- };
47915
- })
47916
- }));
47917
- const pages = readWikiMapLinks().map((page) => ({
47918
- ...page,
47919
- entries: page.entries.map((entry) => ({
47920
- ...entry,
47921
- rule: readOptionalText(entry, "rule")
47922
- }))
47923
- }));
47924
- return [...files, ...pages].toSorted((one, other) => one.map.localeCompare(other.map));
48183
+ return readWikiMapLinks().toSorted((one, other) => one.map.localeCompare(other.map));
47925
48184
  }
47926
48185
  function readConfigValue() {
47927
48186
  const value = readJson$1(configFile);
@@ -48111,7 +48370,7 @@ function buildLeakMap() {
48111
48370
  if (finder.id !== expected) problems.push(`${finder.id} should be ${expected}, after its lowest signal number.`);
48112
48371
  }
48113
48372
  for (const signal of signals) if (!placed.has(signal.key)) problems.push(`The signal ${signal.key} isn't on the leak map: add it to a leak's overlaps or to signalFinders.`);
48114
- problems.push(...listRepeated$1(config.signalFinders.map((finder) => finder.id)).map((id) => `${id} is the id of two signal finders.`));
48373
+ problems.push(...listRepeated(config.signalFinders.map((finder) => finder.id)).map((id) => `${id} is the id of two signal finders.`));
48115
48374
  const foldedInto = /* @__PURE__ */ new Map();
48116
48375
  for (const fold of config.folds) {
48117
48376
  if (!leakById.has(fold.into)) problems.push(`A fold goes into ${fold.into}, which isn't in ${leakLibraryAddress}.`);
@@ -48159,7 +48418,7 @@ function buildLeakMap() {
48159
48418
  });
48160
48419
  links.set(finderId, list);
48161
48420
  }
48162
- problems.push(...listRepeated$1(config.overlaps.map((overlap) => overlap.leak)).map((id) => `${id} has two overlaps entries; give it one.`), ...listRepeated$1(config.settled.map((item) => item.leak)).map((id) => `${id} has two settled notes; give it one.`), ...listRepeated$1(config.folds.map((fold) => fold.into)).map((id) => `${id} takes in leaks in two folds; give it one.`));
48421
+ problems.push(...listRepeated(config.overlaps.map((overlap) => overlap.leak)).map((id) => `${id} has two overlaps entries; give it one.`), ...listRepeated(config.settled.map((item) => item.leak)).map((id) => `${id} has two settled notes; give it one.`), ...listRepeated(config.folds.map((fold) => fold.into)).map((id) => `${id} takes in leaks in two folds; give it one.`));
48163
48422
  for (const { map } of maps) if (!config.mapNames.has(map)) problems.push(`The map ${map} has no name in mapNames.`);
48164
48423
  const knownIds = new Set(leakById.keys());
48165
48424
  for (const item of config.settled) {
@@ -48343,20 +48602,19 @@ function buildLeakMap() {
48343
48602
  else if (result.finders.length === 0) problems.push(`The preset ${preset.key} picks no finder.`);
48344
48603
  if ("preset" in parseSelector(preset.select).tokens) problems.push(`The preset ${preset.key} names another preset.`);
48345
48604
  }
48346
- problems.push(...listRepeated$1(config.presets.map((preset) => preset.key)).map((key) => `${key} is the key of two presets.`));
48605
+ problems.push(...listRepeated(config.presets.map((preset) => preset.key)).map((key) => `${key} is the key of two presets.`));
48347
48606
  return {
48348
48607
  problems,
48349
48608
  map
48350
48609
  };
48351
48610
  }
48352
- var harnessFolder, mapsFolder, configFile, schemaFile, leaksSchemaFile, lanes, vendorSources, publicSources, howToRun;
48611
+ var harnessFolder, configFile, schemaFile, leaksSchemaFile, lanes, vendorSources, publicSources, howToRun;
48353
48612
  var init_leak_map_build = __esmMin((() => {
48354
48613
  init_json_schema();
48355
48614
  init_leak_library();
48356
48615
  init_leak_selector();
48357
48616
  init_stack();
48358
48617
  harnessFolder = fromHarness();
48359
- mapsFolder = join(harnessFolder, "catalog", "maps");
48360
48618
  configFile = join(harnessFolder, "catalog", "leak-map.json");
48361
48619
  schemaFile = join(harnessFolder, "schema", "leak-map.schema.json");
48362
48620
  leaksSchemaFile = join(harnessFolder, "schema", "leaks.schema.json");
@@ -48416,7 +48674,7 @@ var init_leak_map_build = __esmMin((() => {
48416
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."];
48417
48675
  }));
48418
48676
  // src/harness/leak-map.ts
48419
- var leak_map_exports = /* @__PURE__ */ __exportAll({ run: () => run$10 });
48677
+ var leak_map_exports = /* @__PURE__ */ __exportAll({ run: () => run$11 });
48420
48678
  async function selectorScript() {
48421
48679
  const { build } = await import("rolldown");
48422
48680
  const [chunk] = (await build({
@@ -48469,7 +48727,7 @@ function readCurrent(name) {
48469
48727
  if (!existsSync(file)) return null;
48470
48728
  return readFileSync(file, "utf8");
48471
48729
  }
48472
- async function run$10(args) {
48730
+ async function run$11(args) {
48473
48731
  const isCheck = args.includes("--check");
48474
48732
  const { problems, map } = buildLeakMap();
48475
48733
  if (map === null || problems.length > 0) throw new Error(`The leak map has problems:\n${problems.join("\n")}`);
@@ -48508,7 +48766,7 @@ var init_leak_map = __esmMin((() => {
48508
48766
  selectorMark = "<script data-leak-selector><\/script>";
48509
48767
  }));
48510
48768
  // src/harness/leak-select.ts
48511
- var leak_select_exports = /* @__PURE__ */ __exportAll({ run: () => run$9 });
48769
+ var leak_select_exports = /* @__PURE__ */ __exportAll({ run: () => run$10 });
48512
48770
  function readLeakMap() {
48513
48771
  const { problems, map } = buildLeakMap();
48514
48772
  if (map === null || problems.length > 0) throw new Error(`The leak map has problems, so it can't select:\n${problems.join("\n")}`);
@@ -48567,7 +48825,7 @@ function block(finder) {
48567
48825
  for (const other of finder.related) lines.push(`- **Related ${other.id}:** ${other.why}`);
48568
48826
  return lines.join("\n");
48569
48827
  }
48570
- function run$9(args) {
48828
+ function run$10(args) {
48571
48829
  const selector = args.filter((arg) => !arg.startsWith("--")).join(" ");
48572
48830
  if (args.includes("--presets")) for (const preset of map.presets) {
48573
48831
  const picked = selectFinders(map, `preset=${preset.key}`).finders.length;
@@ -48607,10 +48865,10 @@ var init_leak_select = __esmMin((() => {
48607
48865
  laneNames = new Map(Object.entries(map.lanes).map(([lane, about]) => [lane, about.name]));
48608
48866
  }));
48609
48867
  // src/harness/make-video.ts
48610
- var make_video_exports = /* @__PURE__ */ __exportAll({ run: () => run$8 });
48868
+ var make_video_exports = /* @__PURE__ */ __exportAll({ run: () => run$9 });
48611
48869
  function readArguments$4(args) {
48612
48870
  const [stepsFile, video, ...extra] = args;
48613
- 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);
48614
48872
  const videoFile = resolve(video);
48615
48873
  if (extname(videoFile).toLowerCase() !== ".mp4") throw new Error(`${videoFile} must end in .mp4.`);
48616
48874
  return {
@@ -48801,10 +49059,10 @@ async function makeVideo({ stepsFile, video }) {
48801
49059
  });
48802
49060
  }
48803
49061
  }
48804
- async function run$8(args) {
49062
+ async function run$9(args) {
48805
49063
  await makeVideo(readArguments$4(args));
48806
49064
  }
48807
- 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;
48808
49066
  var init_make_video = __esmMin((() => {
48809
49067
  init_zod();
48810
49068
  frameWidth = 1280;
@@ -48820,7 +49078,7 @@ var init_make_video = __esmMin((() => {
48820
49078
  [".jpeg", "image/jpeg"],
48821
49079
  [".webp", "image/webp"]
48822
49080
  ]);
48823
- 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.";
48824
49082
  stepsSchema = strictObject({
48825
49083
  title: string().trim().min(1).max(90),
48826
49084
  steps: array(strictObject({
@@ -48844,7 +49102,7 @@ html, body { width: ${String(frameWidth)}px; height: ${String(frameHeight)}px; o
48844
49102
  `;
48845
49103
  }));
48846
49104
  // src/harness/meta-tables.ts
48847
- var meta_tables_exports = /* @__PURE__ */ __exportAll({ run: () => run$7 });
49105
+ var meta_tables_exports = /* @__PURE__ */ __exportAll({ run: () => run$8 });
48848
49106
  function readInputs(path) {
48849
49107
  const { value, inputs } = readStoreInputs(path, "meta-tables-inputs.schema.json", [requiredAnswers, optionalAnswers].flatMap((group) => Object.values(group)));
48850
49108
  return {
@@ -49107,7 +49365,7 @@ function buildAds(inputs) {
49107
49365
  function listEmptyColumns(columns, rows) {
49108
49366
  return columns.filter((column) => rows.every((row) => row[column] === void 0));
49109
49367
  }
49110
- function run$7(args) {
49368
+ function run$8(args) {
49111
49369
  const [inputsPath, outputPath] = args;
49112
49370
  if (inputsPath === void 0 || outputPath === void 0) throw new Error("Run it as: goose-staff harness meta-tables <inputs file> <output folder>");
49113
49371
  const inputs = readInputs(inputsPath);
@@ -49182,7 +49440,7 @@ var init_meta_tables = __esmMin((() => {
49182
49440
  ]);
49183
49441
  }));
49184
49442
  // src/harness/money-map.ts
49185
- var money_map_exports = /* @__PURE__ */ __exportAll({ run: () => run$6 });
49443
+ var money_map_exports = /* @__PURE__ */ __exportAll({ run: () => run$7 });
49186
49444
  function failOnProblems(heading, problems) {
49187
49445
  if (problems.length === 0) return;
49188
49446
  const lines = problems.map((problem) => `- ${problem}`).join("\n");
@@ -49211,7 +49469,7 @@ function writeMapFile(answerFile, slug, out) {
49211
49469
  writeJson(out, file);
49212
49470
  console.log(`${out} holds Goose's money map for cycle ${readText$3(file, "cycle")}.`);
49213
49471
  }
49214
- function run$6(args) {
49472
+ function run$7(args) {
49215
49473
  const [mode, source, second, out] = args;
49216
49474
  if (mode === "save-input" && source !== void 0 && second !== void 0 && out !== void 0) writeSaveInput(source, second, out);
49217
49475
  else if (mode === "file" && source !== void 0 && second !== void 0 && out !== void 0) writeMapFile(source, second, out);
@@ -49225,18 +49483,18 @@ var init_money_map = __esmMin((() => {
49225
49483
  slugPattern = /^[a-z0-9][a-z0-9-]*$/;
49226
49484
  }));
49227
49485
  // src/harness/render-figure.ts
49228
- var render_figure_exports = /* @__PURE__ */ __exportAll({ run: () => run$5 });
49486
+ var render_figure_exports = /* @__PURE__ */ __exportAll({ run: () => run$6 });
49229
49487
  function readWidth(flags) {
49230
49488
  if (flags.length === 0) return defaultWidth;
49231
49489
  const [flag, value] = flags;
49232
- 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);
49233
49491
  const width = Number(value);
49234
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)}.`);
49235
49493
  return width;
49236
49494
  }
49237
49495
  function readArguments$3(args) {
49238
49496
  const [page, picture, ...flags] = args;
49239
- 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);
49240
49498
  const pageFile = resolve(page);
49241
49499
  if (!existsSync(pageFile)) throw new Error(`${pageFile} doesn't exist.`);
49242
49500
  if (extname(pageFile).toLowerCase() !== ".html") throw new Error(`${pageFile} isn't an HTML file.`);
@@ -49296,10 +49554,10 @@ async function renderFigure({ page, picture, width }) {
49296
49554
  if (statSync(picture).size > byteLimit) throw new Error(`${picture} is over 20 MB. Draw the figure smaller.`);
49297
49555
  console.log(`Rendered ${picture} at ${String(width)} pixels wide, ${String(pixelRatio)}x sharp. Upload it with goose-staff finding picture upload --upload ${picture}.`);
49298
49556
  }
49299
- async function run$5(args) {
49557
+ async function run$6(args) {
49300
49558
  await renderFigure(readArguments$3(args));
49301
49559
  }
49302
- var defaultWidth, smallestWidth, largestWidth, pixelRatio, byteLimit, settleTime$1, usage$3, refused;
49560
+ var defaultWidth, smallestWidth, largestWidth, pixelRatio, byteLimit, settleTime$1, usage$4, refused;
49303
49561
  var init_render_figure = __esmMin((() => {
49304
49562
  defaultWidth = 720;
49305
49563
  smallestWidth = 320;
@@ -49307,11 +49565,11 @@ var init_render_figure = __esmMin((() => {
49307
49565
  pixelRatio = 2;
49308
49566
  byteLimit = 2e7;
49309
49567
  settleTime$1 = 300;
49310
- 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.";
49311
49569
  refused = [];
49312
49570
  }));
49313
49571
  // src/harness/report-page.ts
49314
- var report_page_exports = /* @__PURE__ */ __exportAll({ run: () => run$4 });
49572
+ var report_page_exports = /* @__PURE__ */ __exportAll({ run: () => run$5 });
49315
49573
  function readSource(path) {
49316
49574
  if (!existsSync(path)) throw new Error(`${path} doesn't exist.`);
49317
49575
  return readFileSync(path, "utf8").replaceAll(/\r\n?/g, "\n");
@@ -49787,14 +50045,14 @@ function checkPage(path) {
49787
50045
  if (problems.length > 0) process.exitCode = 1;
49788
50046
  else if (layout !== null) console.log(` passes as a ${layout.name} page`);
49789
50047
  }
49790
- function run$4(args) {
50048
+ function run$5(args) {
49791
50049
  const [command, ...paths] = args;
49792
50050
  const [first, second] = paths;
49793
50051
  if (command === "build" && paths.length === 2 && first !== void 0 && second !== void 0) buildPage$1(first, second);
49794
50052
  else if (command === "check" && paths.length === 1 && first !== void 0) checkPage(first);
49795
- else throw new Error(usage$2);
50053
+ else throw new Error(usage$3);
49796
50054
  }
49797
- 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;
49798
50056
  var init_report_page = __esmMin((() => {
49799
50057
  init_finding_style();
49800
50058
  init_finding_words();
@@ -50092,7 +50350,7 @@ var init_report_page = __esmMin((() => {
50092
50350
  addressPadding = /^[\0- ]+|[\t\n\r]/g;
50093
50351
  styleLoad = /@import\b[^;]*|url\(\s*(?!['"]?\s*(?:data:|#))[^)]*/gi;
50094
50352
  typeSetting = /\bfont(?:-family|-size)?\s*:/gi;
50095
- 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";
50096
50354
  }));
50097
50355
  // src/harness/session-digest.ts
50098
50356
  var session_digest_exports = /* @__PURE__ */ __exportAll({
@@ -50100,7 +50358,7 @@ var session_digest_exports = /* @__PURE__ */ __exportAll({
50100
50358
  queuedHow: () => queuedHow,
50101
50359
  readSession: () => readSession,
50102
50360
  rejectedHow: () => rejectedHow,
50103
- run: () => run$3
50361
+ run: () => run$4
50104
50362
  });
50105
50363
  function readArguments$2(values) {
50106
50364
  const single = /* @__PURE__ */ new Map();
@@ -50116,20 +50374,20 @@ function readArguments$2(values) {
50116
50374
  for (let index = 0; index < values.length; index += 2) {
50117
50375
  const flag = String(values[index]);
50118
50376
  const value = values[index + 1];
50119
- 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}`);
50120
50378
  if (flag === "--session") sessions.push(value);
50121
50379
  else if (flag === "--from") from.push(resolve(value));
50122
50380
  else if (singleFlags.has(flag)) {
50123
- 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}`);
50124
50382
  single.set(flag, value);
50125
- } 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}`);
50126
50384
  }
50127
50385
  const transcripts = single.get("--transcripts");
50128
50386
  const out = single.get("--out");
50129
- 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}`);
50130
50388
  const night = single.get("--night");
50131
50389
  if (night === void 0) {
50132
- 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}`);
50133
50391
  return {
50134
50392
  mode: "sessions",
50135
50393
  transcripts: resolve(transcripts),
@@ -50139,7 +50397,7 @@ function readArguments$2(values) {
50139
50397
  }
50140
50398
  const timeZone = single.get("--time-zone");
50141
50399
  const skipUnder = single.get("--skip-under");
50142
- 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}`);
50143
50401
  if (!nightPattern.test(night)) throw new Error(`--night ${night} isn't a YYYY-MM-DD date.`);
50144
50402
  return {
50145
50403
  mode: "night",
@@ -50689,7 +50947,7 @@ async function triageNight(ask) {
50689
50947
  const kept = triaged.filter((session) => session.isKept).length;
50690
50948
  console.log(`${file} lists ${String(triaged.length)} sessions touched that night; ${String(kept)} kept.`);
50691
50949
  }
50692
- async function run$3(args) {
50950
+ async function run$4(args) {
50693
50951
  const ask = readArguments$2(args);
50694
50952
  if (ask.mode === "night") {
50695
50953
  await triageNight(ask);
@@ -50702,10 +50960,10 @@ async function run$3(args) {
50702
50960
  mkdirSync(ask.out, { recursive: true });
50703
50961
  for (const { session, path } of found) writeDigest(session, path, await readSession(path), ask.out);
50704
50962
  }
50705
- 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;
50706
50964
  var init_session_digest = __esmMin((() => {
50707
50965
  init_json_schema();
50708
- 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> ...]";
50709
50967
  nightPattern = /^\d{4}-\d{2}-\d{2}$/;
50710
50968
  privateTag = "#private";
50711
50969
  noLearnTag = "#no-learn";
@@ -52144,7 +52402,7 @@ var init_run_story_read = __esmMin((() => {
52144
52402
  ]);
52145
52403
  }));
52146
52404
  // src/harness/run-story.ts
52147
- var run_story_exports = /* @__PURE__ */ __exportAll({ run: () => run$2 });
52405
+ var run_story_exports = /* @__PURE__ */ __exportAll({ run: () => run$3 });
52148
52406
  function readArguments$1(values) {
52149
52407
  const given = /* @__PURE__ */ new Map();
52150
52408
  let isUpload = false;
@@ -52154,20 +52412,20 @@ function readArguments$1(values) {
52154
52412
  isUpload = true;
52155
52413
  continue;
52156
52414
  }
52157
- if (!valueFlags.has(flag)) throw new Error(`${flag} isn't an argument run-story takes.\n${usage}`);
52158
- 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}`);
52159
52417
  const value = values[index + 1];
52160
- 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}`);
52161
52419
  given.set(flag, value);
52162
52420
  index += 1;
52163
52421
  }
52164
52422
  const session = given.get("--session");
52165
- 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}`);
52166
52424
  for (const flag of ["--from", "--to"]) {
52167
52425
  const time = given.get(flag);
52168
52426
  if (time !== void 0 && !timePattern.test(time)) throw new Error(`${flag} ${time} isn't a UTC time like 2026-11-26T03:36Z.`);
52169
52427
  }
52170
- 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}`);
52171
52429
  const read = (flag) => {
52172
52430
  const value = given.get(flag);
52173
52431
  return value === void 0 ? "" : value;
@@ -52275,7 +52533,7 @@ function uploadPage(page, runs, runId) {
52275
52533
  }, join(folder, `${name}-checkpoint.json`), []);
52276
52534
  console.log(`Saved it to run ${picked} as ${path}.`);
52277
52535
  }
52278
- async function run$2(args) {
52536
+ async function run$3(args) {
52279
52537
  const ask = readArguments$1(args);
52280
52538
  const { path, dream } = findTranscript(ask.session);
52281
52539
  const story = await readStory(path, dream, ask.window);
@@ -52296,14 +52554,14 @@ async function run$2(args) {
52296
52554
  console.log(file);
52297
52555
  if (ask.isUpload) uploadPage(file, listBrandRuns(story), ask.runId);
52298
52556
  }
52299
- var usage, valueFlags, timePattern;
52557
+ var usage$1, valueFlags, timePattern;
52300
52558
  var init_run_story = __esmMin((() => {
52301
52559
  init_checkout();
52302
52560
  init_json_schema();
52303
52561
  init_run_story_facts();
52304
52562
  init_run_story_page();
52305
52563
  init_run_story_read();
52306
- 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>]]";
52307
52565
  valueFlags = /* @__PURE__ */ new Set([
52308
52566
  "--session",
52309
52567
  "--out",
@@ -52313,6 +52571,207 @@ var init_run_story = __esmMin((() => {
52313
52571
  ]);
52314
52572
  timePattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?Z$/;
52315
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
+ }));
52316
52775
  // src/harness/watch-gate.ts
52317
52776
  var watch_gate_exports = /* @__PURE__ */ __exportAll({ run: () => run$1 });
52318
52777
  function readNullableText(source, field) {
@@ -52608,6 +53067,21 @@ function gateSignal(signal, healths, groups, numbers) {
52608
53067
  function chunk(items, size) {
52609
53068
  return Array.from({ length: Math.ceil(items.length / size) }, (_slot, index) => items.slice(index * size, index * size + size));
52610
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
+ }
52611
53085
  function readNumbers(file) {
52612
53086
  const value = readJson$1(file);
52613
53087
  return new Map([...brandNumbers.keys()].map((need) => {
@@ -52763,11 +53237,13 @@ function writeGate(folder) {
52763
53237
  vendors: describeHealth(healths),
52764
53238
  cantRunSaves: chunk(cantRuns, saveSize),
52765
53239
  groups: readGroupsByKey,
52766
- mapNodes
53240
+ mapNodes,
53241
+ mapGroups: groupMapNodes(mapNodes)
52767
53242
  };
52768
53243
  writeFileSync(join(folder, "gate.json"), `${JSON.stringify(gate, null, 2)}\n`);
52769
53244
  const toRead = readGroupsByKey.reduce((sum, group) => sum + group.signals.length, 0);
52770
- 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(", ")}.`);
52771
53247
  }
52772
53248
  function run$1(args) {
52773
53249
  const [mode, first, ...rest] = args;
@@ -52778,7 +53254,7 @@ function run$1(args) {
52778
53254
  else if (mode === "health" && hasOne) printHealth(resolve(first));
52779
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>");
52780
53256
  }
52781
- 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;
52782
53258
  var init_watch_gate = __esmMin((() => {
52783
53259
  init_signal_map();
52784
53260
  init_watch_words();
@@ -52786,7 +53262,9 @@ var init_watch_gate = __esmMin((() => {
52786
53262
  init_checkout();
52787
53263
  init_stack();
52788
53264
  groupSize = 15;
53265
+ mapGroupSize = 8;
52789
53266
  saveSize = 15;
53267
+ providerReadPattern = /^provider_read ([a-z_]+) /;
52790
53268
  settledNextDay = 1;
52791
53269
  vendorLimit = 20;
52792
53270
  answerLimit = 300;
@@ -53233,7 +53711,7 @@ var init_commands$1 = __esmMin((() => {
53233
53711
  ["check-map", {
53234
53712
  subcommands: [],
53235
53713
  usage: "",
53236
- about: "Checks the dig maps in catalog/maps.",
53714
+ about: "Checks the retention map in the knowledge wiki, and the Meta tables it shares a check with.",
53237
53715
  flags: [],
53238
53716
  load: () => Promise.resolve().then(() => (init_check_map(), check_map_exports))
53239
53717
  }],
@@ -53388,6 +53866,13 @@ var init_commands$1 = __esmMin((() => {
53388
53866
  ],
53389
53867
  load: () => Promise.resolve().then(() => (init_session_digest(), session_digest_exports))
53390
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
+ }],
53391
53876
  ["watch-gate", {
53392
53877
  subcommands: watchGateModes,
53393
53878
  usage: "list | probes <run folder> | gate <run folder> | health <brand_get answer file>",
@@ -53403,7 +53888,7 @@ var init_commands$1 = __esmMin((() => {
53403
53888
  load: () => Promise.resolve().then(() => (init_watch_page(), watch_page_exports))
53404
53889
  }]
53405
53890
  ]);
53406
- })), KNOWLEDGE_SYNC_PREFIX, wikiPath, pageAddress, wikiAddress, blockAddress, commit, hash, fieldPath, knowledgeFileChange, knowledgeEditKinds, knowledgeEditor, knowledgeChangeStates, knowledgeChange, knowledgePublished, knowledgeChangesAnswer, knowledgeSyncRefusal, knowledgeFillStates, pageFill, pageSummary, pendingSummary, snapshot, editErrors, savedEdit;
53891
+ })), KNOWLEDGE_SYNC_PREFIX, wikiPath, pageAddress, wikiAddress, blockAddress, commit, hash, fieldPath, knowledgeFileChange, knowledgeEditKinds, knowledgeEditor, knowledgeChangeStates, knowledgeChange, knowledgePublished, knowledgeChangesAnswer, knowledgeSyncRefusal, knowledgeFillStates, pageFill, pageSummary, pendingSummary, snapshot, lever, editErrors, savedEdit;
53407
53892
  var init_knowledge = __esmMin((() => {
53408
53893
  init_zod();
53409
53894
  init_call_access();
@@ -53511,6 +53996,15 @@ var init_knowledge = __esmMin((() => {
53511
53996
  commit,
53512
53997
  publishedAt: date$1()
53513
53998
  });
53999
+ lever = object({
54000
+ id: string(),
54001
+ title: string(),
54002
+ summary: string(),
54003
+ guides: array(object({
54004
+ label: string(),
54005
+ to: wikiAddress
54006
+ })).describe("The pages, stages and trees that answer it, in order. Empty when no guide exists yet.")
54007
+ });
53514
54008
  editErrors = {
53515
54009
  KNOWLEDGE_STALE: {
53516
54010
  status: 409,
@@ -53530,6 +54024,7 @@ var init_knowledge = __esmMin((() => {
53530
54024
  });
53531
54025
  readCall("people").input(object({}).strict()).output(object({
53532
54026
  snapshot: snapshot.nullable(),
54027
+ levers: array(lever).describe("What a staffer can fix, from start/index, in the order Knowledge shows them."),
53533
54028
  areas: array(object({
53534
54029
  area: string(),
53535
54030
  pages: array(pageSummary)