@allocator-one/rcl 4.5.5 → 4.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -226,6 +226,7 @@ program
226
226
  .option('--head-sha <sha>', 'Exact head commit a patch file was taken from (patch files only)')
227
227
  .option('--base-sha <sha>', 'Exact base commit a patch file was taken from (patch files only)')
228
228
  .option('--expect-head-sha <sha>', 'Fail fast unless the resolved head commit equals this SHA')
229
+ .option('--expect-pr-head-sha <sha>', 'Finalize-only cycle recovery: fail unless the live pull request remains open at this current head')
229
230
  .option('--spec-source <source>', 'Where --spec came from: flag | repo_file | harness_issue:<ID>')
230
231
  .option('--converge-target <key>', 'Converge target this round belongs to (or RCL_CONVERGE_TARGET)')
231
232
  .option('--for-pr <owner/repo#N>', 'The pull request a patch-file review is evidence for (or RCL_FOR_PR): Harness verifies its head against that pull request')
@@ -240,6 +241,7 @@ program
240
241
  .option('--finalize-pending-only', 'Finalize one authenticated pending launch without claiming or dispatching its successor')
241
242
  .option('--pending-native-sha256 <digest>', 'Finalize-only: exact native state digest returned by --preview-pending')
242
243
  .option('--pending-attempt-sha256 <digest>', 'Finalize-only: exact attempt state digest returned by --preview-pending')
244
+ .option('--pending-preview-sha256 <digest>', 'Changed-head cycle finalize-only: exact preview binding returned by --preview-pending')
243
245
  .option('--export-pending-package <path>', 'Export authenticated pending inputs to an exclusive private file without provider calls or native writes')
244
246
  .option('--expect-base-sha <sha>', 'Pending package export: require the resolved current base to equal this SHA')
245
247
  .option('--ordinary-pending-package <path>', 'Immutable pending-launch package; requires --resume-pending or --finalize-pending-only and replaces --retry-report')
@@ -1627,7 +1629,7 @@ async function runReview(target, opts) {
1627
1629
  const finalizeOnlyIgnoredReviewFlags = opts.retryReason !== undefined || opts.maxRounds !== undefined ||
1628
1630
  opts.round !== undefined || opts.attempt !== undefined || opts.post || opts.json ||
1629
1631
  opts.jsonFile !== undefined || opts.markdown !== undefined || opts.ci || opts.evidenceRequired ||
1630
- opts.forPr !== undefined || opts.role !== undefined || opts.roles !== undefined ||
1632
+ opts.role !== undefined || opts.roles !== undefined ||
1631
1633
  opts.models !== undefined || opts.secondaryModels !== undefined || opts.asyncModels !== undefined ||
1632
1634
  (opts.reviewer?.length ?? 0) > 0 || (opts.context?.length ?? 0) > 0 ||
1633
1635
  opts.spec !== undefined || opts.focus !== undefined;
@@ -1636,12 +1638,17 @@ async function runReview(target, opts) {
1636
1638
  opts.retryReport !== undefined || !opts.resumeAsyncSha256 || opts.maxAttempts === undefined ||
1637
1639
  (!opts.previewPending && (!opts.pendingNativeSha256 || !opts.pendingAttemptSha256)) ||
1638
1640
  (opts.previewPending && (opts.pendingNativeSha256 !== undefined || opts.pendingAttemptSha256 !== undefined)) ||
1641
+ (opts.expectPrHeadSha !== undefined && !opts.previewPending && !opts.pendingPreviewSha256) ||
1642
+ (opts.pendingPreviewSha256 !== undefined && opts.expectPrHeadSha === undefined) ||
1643
+ (opts.expectPrHeadSha !== undefined && opts.forPr === undefined) ||
1644
+ (opts.previewPending && opts.pendingPreviewSha256 !== undefined) ||
1639
1645
  opts.startOver || opts.boundFixRecovery || opts.attest || opts.launchIntent !== undefined ||
1640
1646
  finalizeOnlyIgnoredReviewFlags || finalizeOnlySourceFlags)) {
1641
1647
  throw new ReviewLaunchRefused('pending_finalize_incompatible', '--finalize-pending-only accepts only guarded target/head/base/config bindings, one ordinary pending package, an explicit unchanged attempt cap, retained async result digests and, for apply, both exact state digests from preview; do not combine it with review, output, evidence or retry flags.');
1642
1648
  }
1643
1649
  if (!opts.finalizePendingOnly &&
1644
- (opts.pendingNativeSha256 !== undefined || opts.pendingAttemptSha256 !== undefined)) {
1650
+ (opts.pendingNativeSha256 !== undefined || opts.pendingAttemptSha256 !== undefined ||
1651
+ opts.pendingPreviewSha256 !== undefined || opts.expectPrHeadSha !== undefined)) {
1645
1652
  throw new ReviewLaunchRefused('pending_finalize_incompatible', 'Pending native and attempt state digests apply only to --finalize-pending-only.');
1646
1653
  }
1647
1654
  if (!opts.resumePending && !opts.finalizePendingOnly &&
@@ -1704,6 +1711,14 @@ async function runReview(target, opts) {
1704
1711
  validateSha(opts.baseSha, '--base-sha');
1705
1712
  if (opts.expectHeadSha !== undefined)
1706
1713
  validateSha(opts.expectHeadSha, '--expect-head-sha');
1714
+ if (opts.expectPrHeadSha !== undefined)
1715
+ validateSha(opts.expectPrHeadSha, '--expect-pr-head-sha');
1716
+ if (opts.pendingPreviewSha256 !== undefined && !/^[a-f0-9]{64}$/.test(opts.pendingPreviewSha256)) {
1717
+ throw new ReviewLaunchRefused('pending_finalize_incompatible', '--pending-preview-sha256 must be a lowercase SHA-256 digest.');
1718
+ }
1719
+ if (opts.expectPrHeadSha !== undefined && !opts.finalizePendingOnly) {
1720
+ throw new ReviewLaunchRefused('pending_finalize_incompatible', '--expect-pr-head-sha applies only to cycle-backed --finalize-pending-only recovery.');
1721
+ }
1707
1722
  if (opts.evidenceRequired && patchTarget && opts.headSha === undefined) {
1708
1723
  throw new Error('--evidence-required needs --head-sha for a patch file: evidence must bind to the commit it reviewed.');
1709
1724
  }
@@ -1881,7 +1896,7 @@ async function executeCouncil(spinner, prepared, diff, opts, extra, preparedWork
1881
1896
  const runtime = await createTelemetryRuntime({ rclVersion: RCL_VERSION, config, noTelemetry: opts.telemetry === false });
1882
1897
  if (!runtime.sink || runtime.level !== 'full')
1883
1898
  throw new Error('Fresh review cycles require full Harness evidence and an actor credential');
1884
- cycleRemote = createReviewCycleRemote(runtime.sink, extra.target.repo, extra.target.prNumber, extra.target.headSha ?? '');
1899
+ cycleRemote = createReviewCycleRemote(runtime.sink, extra.target.repo, extra.target.prNumber, opts.expectPrHeadSha ?? extra.target.headSha ?? '');
1885
1900
  }
1886
1901
  if (opts.resumePending || opts.finalizePendingOnly) {
1887
1902
  const asyncBinding = opts.resumeAsyncSha256.trim();
@@ -1891,6 +1906,12 @@ async function executeCouncil(spinner, prepared, diff, opts, extra, preparedWork
1891
1906
  throw new ReviewLaunchRefused('pending_async_binding_invalid', 'Retained async bindings must be comma-separated lowercase SHA-256 digests, or "none" for an empty cycle history.');
1892
1907
  }
1893
1908
  const migrationPackage = opts.ordinaryPendingPackage === undefined ? undefined : JSON.parse((await readStable(opts.ordinaryPendingPackage)).text);
1909
+ if (opts.expectPrHeadSha !== undefined && migrationPackage?.version !== 2) {
1910
+ throw new ReviewLaunchRefused('pending_finalize_incompatible', '--expect-pr-head-sha requires a cycle-backed version-2 pending package.');
1911
+ }
1912
+ if (opts.finalizePendingOnly && opts.forPr !== undefined && migrationPackage?.version !== 2) {
1913
+ throw new ReviewLaunchRefused('pending_finalize_incompatible', '--for-pr finalize-only recovery requires a cycle-backed version-2 pending package.');
1914
+ }
1894
1915
  if (migrationPackage?.version !== 2 && (expectedAsyncSha256.length === 0 ||
1895
1916
  new Set(expectedAsyncSha256).size !== expectedAsyncSha256.length)) {
1896
1917
  throw new ReviewLaunchRefused('pending_async_binding_invalid', 'Ordinary retained async SHA-256 bindings must be non-empty and unique.');
@@ -1944,6 +1965,7 @@ async function executeCouncil(spinner, prepared, diff, opts, extra, preparedWork
1944
1965
  maxDurationMs: 1, validate: async () => { }, loadRetainedAsync: loadMigrationRetainedAsync,
1945
1966
  run: async () => { throw new Error('preview_must_not_run'); }, preview: true,
1946
1967
  cycleRemote,
1968
+ ...(opts.expectPrHeadSha === undefined ? {} : { currentPrHeadSha: opts.expectPrHeadSha }),
1947
1969
  previewMode: opts.finalizePendingOnly ? 'finalize-only' : 'combined' });
1948
1970
  spinner.stop();
1949
1971
  console.log(JSON.stringify({
@@ -1959,6 +1981,9 @@ async function executeCouncil(spinner, prepared, diff, opts, extra, preparedWork
1959
1981
  nativeStateSha256: opts.pendingNativeSha256, attemptStateSha256: opts.pendingAttemptSha256,
1960
1982
  retainedAsyncSha256: expectedAsyncSha256, migrationPackage,
1961
1983
  maxAttempts: Number(opts.maxAttempts), cycleRemote,
1984
+ ...(opts.expectPrHeadSha === undefined ? {} : {
1985
+ currentPrHeadSha: opts.expectPrHeadSha, previewSha256: opts.pendingPreviewSha256,
1986
+ }),
1962
1987
  loadRetainedAsync: loadMigrationRetainedAsync,
1963
1988
  ...(migrationPackage.version === 2 ? { cycleHistory: {
1964
1989
  resolveStoreDir: resolveExistingAsyncStoreDir,