crysk 0.3.1 → 0.3.2

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 (65) hide show
  1. package/README.md +9 -5
  2. package/dist/SKILL-6j27707y.md +140 -0
  3. package/dist/SKILL-816621e5.md +74 -0
  4. package/dist/SKILL-bnh7nrjz.md +74 -0
  5. package/dist/SKILL-fv8x6hhx.md +140 -0
  6. package/dist/SKILL-nv32jpc5.md +74 -0
  7. package/dist/SKILL-qnfc8yp3.md +539 -0
  8. package/dist/SKILL-xr56f0b6.md +140 -0
  9. package/dist/SKILL-yz6wk92g.md +542 -0
  10. package/dist/ci-admission-09k2ba89.md +126 -0
  11. package/dist/ci-admission-f19qh39t.md +128 -0
  12. package/dist/ci-admission-tcqsj7b2.md +126 -0
  13. package/dist/cli.js +1831 -1150
  14. package/dist/index.js +1464 -911
  15. package/dist/materiality-f1qwnvg1.md +27 -0
  16. package/package.json +3 -2
  17. package/prompts/materiality.md +27 -0
  18. package/skills/crysk/SKILL.md +2 -2
  19. package/skills/crysk-ci-setup/SKILL.md +13 -7
  20. package/skills/crysk-ci-setup/references/ci-admission.md +4 -0
  21. package/skills/crysk-loop/SKILL.md +32 -5
  22. package/src/asset-manifest.ts +2 -0
  23. package/src/assets.ts +4 -1
  24. package/src/brand.ts +11 -9
  25. package/src/ci/cli-record.ts +1 -1
  26. package/src/ci/gates.ts +31 -0
  27. package/src/ci/outcome.ts +2 -1
  28. package/src/ci/override.ts +11 -10
  29. package/src/ci/publish.ts +44 -103
  30. package/src/ci/reporter.ts +34 -5
  31. package/src/ci/review-levels.ts +21 -0
  32. package/src/ci/setup.ts +1 -2
  33. package/src/commands/post.ts +17 -0
  34. package/src/compare/loop.ts +356 -0
  35. package/src/compare/materiality.ts +266 -0
  36. package/src/compare/noise.ts +166 -0
  37. package/src/diversity/projection.ts +3 -0
  38. package/src/index.ts +1 -1
  39. package/src/model/routing.ts +62 -0
  40. package/src/pr/admission.ts +13 -1
  41. package/src/pr/discovery.ts +17 -5
  42. package/src/pr/inline.ts +15 -1
  43. package/src/pr/plan.ts +5 -0
  44. package/src/pr/post-floor.ts +30 -0
  45. package/src/pr/posting.ts +4 -0
  46. package/src/pr/pr-status.ts +14 -0
  47. package/src/pr/pr.ts +50 -34
  48. package/src/pr/preflight.ts +2 -2
  49. package/src/pr/publish-outcome.ts +4 -0
  50. package/src/pr/review-pr.ts +65 -26
  51. package/src/pr/teardown.ts +1 -1
  52. package/src/rereview/prepare.ts +16 -0
  53. package/src/rereview/state.ts +206 -25
  54. package/src/review/boundary.ts +4 -1
  55. package/src/review/dedupe.ts +48 -4
  56. package/src/review/findings.ts +47 -1
  57. package/src/review/materiality-gate.ts +134 -0
  58. package/src/review/pipeline.ts +521 -41
  59. package/src/review/preflight.ts +69 -0
  60. package/src/review/report.ts +73 -10
  61. package/src/review/review.ts +16 -0
  62. package/src/review/route-preflight.ts +29 -1
  63. package/src/review/run.ts +2 -0
  64. package/src/ui/config.ts +8 -0
  65. package/src/updater.ts +1 -1
package/src/pr/pr.ts CHANGED
@@ -71,7 +71,6 @@ import {
71
71
  LEGACY_ADMISSION_CHECK_RUN_NAME,
72
72
  LEGACY_WORKFLOW_FILE_NAME,
73
73
  matchMarkerPrefix,
74
- statusContextForms,
75
74
  WORKFLOW_FILE_NAME,
76
75
  } from "../brand";
77
76
  import { CliError } from "../errors";
@@ -85,6 +84,7 @@ import {
85
84
  parseHunkAnchors,
86
85
  resolvePostLine,
87
86
  } from "./inline";
87
+ import { isBelowPostFloor, type PostMinSeverity } from "./post-floor";
88
88
  import {
89
89
  type CiMode,
90
90
  COMMIT_STATUS_TIMEOUT_MS,
@@ -425,16 +425,12 @@ export async function ghRepoNameWithOwner(
425
425
  // `crysk/local` from every other run, so the POST can never pick a context
426
426
  // the caller did not choose.
427
427
  //
428
- // WHY two POSTs: for one version every status is also written on the legacy
429
- // `pr-hero` name (`pr-hero/local` for a local run). Users have `pr-hero` as a
430
- // required check in branch protection, and a head that stops getting it blocks
431
- // every PR until they add `crysk`. Both POSTs carry one state, one description
432
- // and one target. They start together, crysk first, so the cancellation settle
433
- // (which runs inside a signal handler racing a SIGKILL) spends one short
434
- // window, not two. A failed POST never skips the other: the required check may
435
- // be either name, so the call still throws if either failed, and the caller's
436
- // own handling (fail-soft or fail-loud) applies exactly as it did to one POST.
437
- // Resolves with the created_at of the crysk row, the context the CLI reads back.
428
+ // WHY one POST: since #457 a status is written on its crysk context alone, never
429
+ // on the legacy `pr-hero` name (`pr-hero/local` for a local run). Readers still
430
+ // take a `pr-hero` row as the same gate (isStatusContext), so a head reviewed
431
+ // before that change keeps its verdict, but a branch protection that requires
432
+ // `pr-hero` must switch to `crysk`. Resolves with the created_at of the row the
433
+ // POST created, the one the CLI reads back.
438
434
  export async function postCommitStatus(
439
435
  operatorRoot: string,
440
436
  sha: string,
@@ -450,25 +446,10 @@ export async function postCommitStatus(
450
446
  `commit status: head sha is not a full 40-char id: ${sha.slice(0, 16)}`,
451
447
  );
452
448
  }
453
- const results = await Promise.allSettled(
454
- statusContextForms(status.context).map((context) =>
455
- postCommitStatusOn(
456
- operatorRoot,
457
- sha,
458
- { ...status, context },
459
- spawnFn,
460
- options,
461
- ),
462
- ),
463
- );
464
- for (const result of results) {
465
- if (result.status === "rejected") throw result.reason;
466
- }
467
- const [crysk] = results;
468
- return crysk?.status === "fulfilled" ? crysk.value : undefined;
449
+ return postCommitStatusOn(operatorRoot, sha, status, spawnFn, options);
469
450
  }
470
451
 
471
- // One POST of a status on one context, with the retry.
452
+ // The POST of a status on its context, with the retry.
472
453
  async function postCommitStatusOn(
473
454
  operatorRoot: string,
474
455
  sha: string,
@@ -2730,6 +2711,7 @@ export async function resolveInlinePostPlan(input: {
2730
2711
  doc: FindingsDocument;
2731
2712
  diffPatch: string;
2732
2713
  spawnFn?: typeof Bun.spawn;
2714
+ postMinSeverity?: PostMinSeverity;
2733
2715
  }): Promise<{
2734
2716
  plan: PostPlan;
2735
2717
  previousHeadSha: string | undefined;
@@ -2787,6 +2769,11 @@ export async function resolveInlinePostPlan(input: {
2787
2769
  anchors,
2788
2770
  posted,
2789
2771
  headSha: input.headSha,
2772
+ hiddenIds: new Set(
2773
+ input.doc.findings
2774
+ .filter((f) => isBelowPostFloor(f, input.postMinSeverity))
2775
+ .map((f) => f.id),
2776
+ ),
2790
2777
  });
2791
2778
  return {
2792
2779
  plan,
@@ -2977,6 +2964,8 @@ export async function postInlineFindings(input: {
2977
2964
  // The run was a comment-triggered (forced) run. It leaves the summary counter
2978
2965
  // where it was: the budget bounds automatic reviews (see nextStateReviewCount).
2979
2966
  force?: boolean;
2967
+ // The `post_min_severity` config key (pr/post-floor.ts). Absent posts all.
2968
+ postMinSeverity?: PostMinSeverity;
2980
2969
  }): Promise<InlinePostOutcome> {
2981
2970
  const { operatorRoot, pr, headSha, doc, webUrl, spawnFn } = input;
2982
2971
  const ghTimeoutMs = input.ghTimeoutMs ?? COLLAPSE_GH_TIMEOUT_MS;
@@ -3055,6 +3044,19 @@ export async function postInlineFindings(input: {
3055
3044
  }
3056
3045
  if (priorSummaryVanished) log(vanishedPriorSummaryDegradedMessage(pr));
3057
3046
 
3047
+ // The summary and the state block describe what was POSTED. Findings below
3048
+ // `post_min_severity` have no comment, so they are left out of both and
3049
+ // counted in one summary line instead; a state row would otherwise claim an
3050
+ // inline comment that does not exist. The re-review Δ `new` count and the
3051
+ // admission block below count `postedDoc` too, so the summary never counts a
3052
+ // finding it does not show, a re-review scores the same findings the first
3053
+ // review did, and a hidden finding never spends a re-review. The gate is
3054
+ // unaffected: the floor never hides a blocking finding.
3055
+ const hiddenIds = new Set(plan.notPosted.map((f) => f.id));
3056
+ const postedDoc: FindingsDocument =
3057
+ hiddenIds.size === 0
3058
+ ? doc
3059
+ : { ...doc, findings: doc.findings.filter((f) => !hiddenIds.has(f.id)) };
3058
3060
  // Every re-review-framed surface reads off THIS, never `input.rereview`
3059
3061
  // directly — the delta overlay, the `Still live:` list it carries, and the
3060
3062
  // state block appended after the report marker. The collapse loop at the
@@ -3067,7 +3069,7 @@ export async function postInlineFindings(input: {
3067
3069
  const rereviewDelta =
3068
3070
  framing === undefined
3069
3071
  ? undefined
3070
- : rereviewDeltaFromProvenance(framing, doc.findings.length);
3072
+ : rereviewDeltaFromProvenance(framing, postedDoc.findings.length);
3071
3073
  const overlayDelta = (delta: PrCommentDelta): PrCommentDelta =>
3072
3074
  rereviewDelta === undefined ? delta : { ...delta, rereview: rereviewDelta };
3073
3075
  const byId = new Map(doc.findings.map((f) => [f.id, f]));
@@ -3104,7 +3106,11 @@ export async function postInlineFindings(input: {
3104
3106
  )
3105
3107
  ? "outside"
3106
3108
  : "inline";
3107
- const freshFindings: FreshStateFinding[] = doc.findings.map((f) => ({
3109
+ const notPosted =
3110
+ hiddenIds.size === 0 || input.postMinSeverity === undefined
3111
+ ? undefined
3112
+ : { count: hiddenIds.size, floor: input.postMinSeverity };
3113
+ const freshFindings: FreshStateFinding[] = postedDoc.findings.map((f) => ({
3108
3114
  path: f.path,
3109
3115
  line: lineById.get(f.id) ?? f.line,
3110
3116
  proof_refs: f.proof_refs,
@@ -3114,13 +3120,15 @@ export async function postInlineFindings(input: {
3114
3120
  channel: freshChannel(f.id),
3115
3121
  }));
3116
3122
  const referenceBody = renderPrComment(
3117
- doc,
3123
+ postedDoc,
3118
3124
  webUrl,
3119
3125
  overlayDelta({ ...plan.delta, previousHeadSha }),
3120
3126
  plannedOutsideDiff,
3121
3127
  undefined,
3122
3128
  undefined,
3123
3129
  input.ciMode,
3130
+ undefined,
3131
+ notPosted,
3124
3132
  );
3125
3133
  // WHY one merge function for both writes: the S1 re-merge reruns it with a
3126
3134
  // PATCH-sized budget and the SAME inputs, so the kept ids and hw cannot
@@ -3140,6 +3148,12 @@ export async function postInlineFindings(input: {
3140
3148
  ...(framing.resolved_ids ?? []),
3141
3149
  ...(framing.worsened ?? []).map((w) => w.priorId),
3142
3150
  ],
3151
+ // The priors this run's gate count released through a materiality
3152
+ // demotion, recorded on the rereview block by the pipeline, so the
3153
+ // state the next run reads agrees with this run's count.
3154
+ ...(input.rereview?.materiality_released_ids === undefined
3155
+ ? {}
3156
+ : { releasedIds: input.rereview.materiality_released_ids }),
3143
3157
  fresh: freshFindings,
3144
3158
  stateBudget,
3145
3159
  });
@@ -3154,7 +3168,7 @@ export async function postInlineFindings(input: {
3154
3168
  compactFrom?: number,
3155
3169
  ): string => {
3156
3170
  const body = renderPrComment(
3157
- doc,
3171
+ postedDoc,
3158
3172
  webUrl,
3159
3173
  overlayDelta(delta),
3160
3174
  outside,
@@ -3162,6 +3176,7 @@ export async function postInlineFindings(input: {
3162
3176
  urls,
3163
3177
  input.ciMode,
3164
3178
  compactFrom,
3179
+ notPosted,
3165
3180
  );
3166
3181
  // WHY the admission block is written on BOTH paths: its `reviews` is the
3167
3182
  // only count a summary keeps when the count is 0. renderStateBlock omits 0
@@ -3172,7 +3187,7 @@ export async function postInlineFindings(input: {
3172
3187
  // priorScoreForAdmission), and the first-review path already writes them
3173
3188
  // this way.
3174
3189
  const counts = tierCountsFromFindings(
3175
- canonicalAdmissionFindings(doc.findings),
3190
+ canonicalAdmissionFindings(postedDoc.findings),
3176
3191
  );
3177
3192
  const admissionBlock = renderCiAdmissionBlock(
3178
3193
  doc.head_sha,
@@ -3469,7 +3484,7 @@ export async function postInlineFindings(input: {
3469
3484
  headSha,
3470
3485
  delta: overlayDelta(delta),
3471
3486
  newPosted: reachedIds.size,
3472
- totalFindings: doc.findings.length,
3487
+ totalFindings: postedDoc.findings.length,
3473
3488
  runStatus: doc.run_status,
3474
3489
  summaryUrl:
3475
3490
  webUrl === undefined
@@ -3604,6 +3619,7 @@ export async function postInlineIfEligible(input: {
3604
3619
  ciMode?: CiMode;
3605
3620
  // Forwarded to postInlineFindings: a forced run leaves the summary counter alone.
3606
3621
  force?: boolean;
3622
+ postMinSeverity?: PostMinSeverity;
3607
3623
  }): Promise<InlinePostOutcome | null> {
3608
3624
  if (input.sessionFailed) {
3609
3625
  log(input.skippedReason);
@@ -982,8 +982,8 @@ export function prHtmlUrl(
982
982
  // The newest row of one context by created_at, across both of its names (crysk and the legacy
983
983
  // pr-hero): an override an older action posted only on `pr-hero` is the gate when it is newer
984
984
  // than this version's `crysk` verdict. A tie within one name goes to the later row in the list
985
- // (`>=`); a tie across the names goes to the crysk row, because the pair a run writes has one
986
- // content on both and the answer must not depend on the order of the list.
985
+ // (`>=`); a tie across the names goes to the crysk row, because the pair a run before #457
986
+ // wrote has one content on both and the answer must not depend on the order of the list.
987
987
  export function latestStatusInContext(
988
988
  statuses: readonly CommitStatusFact[],
989
989
  context: CommitStatusContext,
@@ -43,6 +43,7 @@ import {
43
43
  import { publishCiReviewIfEligible } from "#pr/ci-publish";
44
44
  import type { PrDiscoveryResult } from "#pr/discovery";
45
45
  import { type InlinePostOutcome, postingExitCode } from "#pr/inline";
46
+ import type { PostMinSeverity } from "#pr/post-floor";
46
47
  import { type PostingStageResult, postFindingsIfEnabled } from "#pr/posting";
47
48
  import type { CiMode } from "#pr/preflight";
48
49
  import { unresolvedBlockingCount } from "#rereview/state";
@@ -90,6 +91,8 @@ export interface PublishRunOutcomeInput {
90
91
  // The run's one resolved CI mode (resolveCiMode, reviewPr). The report, the
91
92
  // summary comment and the step summary all name it; nothing re-resolves it.
92
93
  ciMode: CiMode;
94
+ // The `post_min_severity` config key. Only the PR comments read it.
95
+ postMinSeverity?: PostMinSeverity;
93
96
  estimate: ReturnType<typeof estimateCost>;
94
97
  // W3-FOOTER: the plan's free-route count. Absent means no free share, and the
95
98
  // footer keeps its subscription wording.
@@ -227,6 +230,7 @@ export async function publishRunOutcome(
227
230
  delivered = true;
228
231
  },
229
232
  ciMode: input.ciMode,
233
+ postMinSeverity: input.postMinSeverity,
230
234
  });
231
235
  } catch (error) {
232
236
  if (!delivered) {
@@ -24,7 +24,7 @@ import {
24
24
  hunterFailureRecords,
25
25
  writeCliRecord,
26
26
  } from "#ci/cli-record";
27
- import { planCiSizeSkip } from "#ci/gates";
27
+ import { planCiExcludedSkip, planCiSizeSkip } from "#ci/gates";
28
28
  import { withCiWorkflowGroup } from "#ci/reporter";
29
29
  import { RECHECK_COMMAND, REVIEW_COMMAND } from "#ci/trigger";
30
30
  import { pipelineConfigInput } from "#config/config";
@@ -51,7 +51,11 @@ import {
51
51
  recordCiConfigErrorSkip,
52
52
  yieldToInFlightReview,
53
53
  } from "#pr/ci-admission-gate";
54
- import { discoveryHunters, resolvePrDiscovery } from "#pr/discovery";
54
+ import {
55
+ AllExcludedError,
56
+ discoveryHunters,
57
+ resolvePrDiscovery,
58
+ } from "#pr/discovery";
55
59
  import type { InlinePostOutcome } from "#pr/inline";
56
60
  import { resolvePrPlanAndConfirm } from "#pr/plan";
57
61
  import {
@@ -91,6 +95,7 @@ import {
91
95
  import { estimateCost } from "#review/report";
92
96
  import {
93
97
  pipelineConsolidateInput,
98
+ pipelineMaterialityInput,
94
99
  pipelineScoutInput,
95
100
  pipelineSummarizerInput,
96
101
  } from "#review/route-preflight";
@@ -484,6 +489,58 @@ export async function reviewPr(
484
489
  fetchPostedFindingComments(operatorRoot, prNumber),
485
490
  fetchPrReviewComments(operatorRoot, prNumber),
486
491
  ]);
492
+ let discovery: Awaited<ReturnType<typeof resolvePrDiscovery>>;
493
+ try {
494
+ discovery = await resolvePrDiscovery({
495
+ diffFromSha,
496
+ headSha,
497
+ full: options.full,
498
+ adjudicate: options.adjudicate === true,
499
+ baseRef: target.baseRef,
500
+ headLabel,
501
+ isCi,
502
+ sizeGateOverrides,
503
+ config,
504
+ prIgnore,
505
+ issueComments,
506
+ postedFindings,
507
+ reviewComments,
508
+ git: {
509
+ commitExists: (sha) => gitCommitExists(gitDirOwner, sha),
510
+ isAncestor: (ancestor, descendant) =>
511
+ gitIsAncestor(gitDirOwner, ancestor, descendant),
512
+ nameOnly: (from, to) => gitNameOnly(gitDirOwner, from, to),
513
+ nameStatus: (from, to) => gitNameStatus(gitDirOwner, from, to),
514
+ runGit: (args) => git(gitDirOwner, args),
515
+ },
516
+ log,
517
+ });
518
+ } catch (error) {
519
+ // #317: a first review whose every changed file is excluded has nothing
520
+ // to review. In CI that is a finished no-op, so it ends as a skip: exit 0,
521
+ // a green gate, an unspent attempt, and no PR comment. Outside CI the
522
+ // error stays the one-line exit 1 it has always been.
523
+ if (!(isCi && error instanceof AllExcludedError)) throw error;
524
+ await settleCiGateSkip(
525
+ ciAdmissionLedger,
526
+ "every changed file is excluded from review",
527
+ );
528
+ return await publishCiSkip({
529
+ operatorRoot,
530
+ prNumber,
531
+ post: options.post === true,
532
+ isCi,
533
+ stepSummaryFlag: options.stepSummary,
534
+ plan: planCiExcludedSkip({
535
+ prNumber,
536
+ excludedPaths: error.droppedPaths,
537
+ ciMode,
538
+ }),
539
+ noticeMessage: error.message,
540
+ ciMode,
541
+ headSha,
542
+ });
543
+ }
487
544
  const {
488
545
  prepared,
489
546
  skipDiscovery,
@@ -498,30 +555,7 @@ export async function reviewPr(
498
555
  phaseB,
499
556
  diffStat,
500
557
  sizeGate,
501
- } = await resolvePrDiscovery({
502
- diffFromSha,
503
- headSha,
504
- full: options.full,
505
- adjudicate: options.adjudicate === true,
506
- baseRef: target.baseRef,
507
- headLabel,
508
- isCi,
509
- sizeGateOverrides,
510
- config,
511
- prIgnore,
512
- issueComments,
513
- postedFindings,
514
- reviewComments,
515
- git: {
516
- commitExists: (sha) => gitCommitExists(gitDirOwner, sha),
517
- isAncestor: (ancestor, descendant) =>
518
- gitIsAncestor(gitDirOwner, ancestor, descendant),
519
- nameOnly: (from, to) => gitNameOnly(gitDirOwner, from, to),
520
- nameStatus: (from, to) => gitNameStatus(gitDirOwner, from, to),
521
- runGit: (args) => git(gitDirOwner, args),
522
- },
523
- log,
524
- });
558
+ } = discovery;
525
559
 
526
560
  // 5b(CI) — the assistant-posture branch, BEFORE applySizeGate: outside
527
561
  // CI, a hard skip in non-interactive mode THROWS a CliError (see
@@ -797,6 +831,10 @@ export async function reviewPr(
797
831
  ...(skipDiscovery ? {} : pipelineSummarizerInput(summary)),
798
832
  ...(skipDiscovery ? {} : pipelineScoutInput(options)),
799
833
  ...(skipDiscovery ? {} : pipelineConsolidateInput()),
834
+ // Gated on skipDiscovery like consolidation: an empty-delta
835
+ // re-review posts no new findings, so there is nothing to judge.
836
+ ...(skipDiscovery ? {} : pipelineMaterialityInput(config)),
837
+ prTitle: target.title,
800
838
  ...(resolveSharedPrefix(options) ? { sharedPrefix: true } : {}),
801
839
  // NOT gated on skipDiscovery: an empty-delta re-review still
802
840
  // classifies and verifies against this config, and a run whose
@@ -871,6 +909,7 @@ export async function reviewPr(
871
909
  worktreePath,
872
910
  isCi,
873
911
  ciMode,
912
+ postMinSeverity: config.post_min_severity,
874
913
  estimate,
875
914
  freeRoute,
876
915
  ciAdmissionLedger,
@@ -247,7 +247,7 @@ export async function settleCommitStatusAndLedger(input: {
247
247
  }): Promise<void> {
248
248
  // Only the gate's own context is graded (T3 S7): any other context is
249
249
  // advisory, so a run asked for gate without a `--ci` context still cannot
250
- // write a verdict onto pr-hero. resolveCiPosture keeps the pair consistent in
250
+ // write a verdict onto the gate. resolveCiPosture keeps the pair consistent in
251
251
  // production; this keeps the write safe if they ever diverge.
252
252
  const effectiveMode: CiMode =
253
253
  input.statusContext === COMMIT_STATUS_CONTEXT ? input.ciMode : "advisory";
@@ -110,6 +110,11 @@ export interface RereviewProvenance {
110
110
  discovery_skip_reason?: "no_delta" | "all_excluded";
111
111
  // Populated only when `discovery_skip_reason` is `"all_excluded"`.
112
112
  discovery_excluded_paths?: string[];
113
+ // The prior ids this run's gate count released through a materiality
114
+ // demotion (rereview/state.ts materialityReleasedIds). The state merge
115
+ // re-tiers them advisory. Absent when none was released, and on every
116
+ // pipeline.json written before this field existed.
117
+ materiality_released_ids?: string[];
113
118
  prior_findings: number;
114
119
  settled_deterministically: number;
115
120
  verified: number;
@@ -413,6 +418,14 @@ export function readRereviewProvenance(
413
418
  ) {
414
419
  return problem("discovery_excluded_paths");
415
420
  }
421
+ const releasedIds = raw.materiality_released_ids;
422
+ if (
423
+ releasedIds !== undefined &&
424
+ (!Array.isArray(releasedIds) ||
425
+ !releasedIds.every((id) => typeof id === "string"))
426
+ ) {
427
+ return problem("materiality_released_ids");
428
+ }
416
429
 
417
430
  return {
418
431
  kind: "ok",
@@ -449,6 +462,9 @@ export function readRereviewProvenance(
449
462
  returned: (raw.returned as number | undefined) ?? 0,
450
463
  re_tiered: (raw.re_tiered as number | undefined) ?? 0,
451
464
  ...(worsened === undefined ? {} : { worsened }),
465
+ ...(releasedIds === undefined
466
+ ? {}
467
+ : { materiality_released_ids: releasedIds as string[] }),
452
468
  },
453
469
  };
454
470
  }