@rig-c/review 0.10.0 → 0.10.1

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/package.json +1 -1
  2. package/src/rebuild.ts +14 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rig-c/review",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "type": "module",
5
5
  "description": "Local human rig inspection and structured feedback export",
6
6
  "license": "MIT",
package/src/rebuild.ts CHANGED
@@ -105,6 +105,8 @@ export function configCuts(configText: string): Record<string, unknown> {
105
105
  out.assemble = kept;
106
106
  }
107
107
  if (config.limbs !== undefined) out.limbs = config.limbs;
108
+ // #184: the Cuts panel must see the config's `regions`, or a new part's `add /regions {}` replaces every existing one.
109
+ if (config.regions !== undefined) out.regions = config.regions;
108
110
  return out;
109
111
  }
110
112
  /** #115: why a build-routed Apply cannot run here (the handoff declares no painting and full run), or null. */
@@ -793,6 +795,9 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
793
795
  async function apply(job: RebuildJob | PatchJob | DeltaJob | RetargetJob, dir: string, inputs: ProducerInputs, resolved: Resolved, op: ProducerOp, steps: ApplySteps = {}): Promise<void> {
794
796
  const push = (line: string) => { if (job.lines.length < MAX_LINES) job.lines.push(line); };
795
797
  const producer = resolved.producer;
798
+ // #180: a refusal or failure is published only after its scratch is removed (as "built" is published last, #146),
799
+ // so a reader that sees the outcome never finds a folder mid-removal.
800
+ let outcome: RebuildStatus | null = null;
796
801
  try {
797
802
  await rm(dir, { recursive: true, force: true });
798
803
  await mkdir(dir, { recursive: true, mode: 0o700 });
@@ -803,7 +808,7 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
803
808
  // #148: the producer's line stays as printed; review adds what it means here, when it knows.
804
809
  const hint = producerHint(job.producerLine);
805
810
  if (hint && !('refusals' in job)) { (job as RebuildJob | PatchJob | DeltaJob).hint = hint; push(`review: ${hint}`); }
806
- job.status = 'refused'; return;
811
+ outcome = 'refused'; return;
807
812
  }
808
813
  job.producerLine = run.stdout.filter(l => l.trim()).at(-1)?.trim() ?? null;
809
814
  const { pageEdges, packShape, note } = await op.flags(push);
@@ -818,9 +823,9 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
818
823
  push(`review: ${resolved.compiler.package} ${resolved.compiler.version} build --profile rig-play --pack --page-edges ${pageEdges} --pack-shape ${packShape}${note}`);
819
824
  const compile = await runTool(resolved.compiler.bin, compileArgs({ rig: `${op.spec}/rig.json`, motion: `${op.spec}/motion.json`, out: 'build', pageEdges, packShape }), { cwd: dir, onLine: push });
820
825
  job.wallMs.compile = compile.wallMs;
821
- if (compile.exitCode !== 0) { job.exitCode = compile.exitCode; job.producerLine = firstRefusal(compile.lines) ?? `rigc build exited ${compile.exitCode} without a named refusal`; job.status = 'refused'; return; }
826
+ if (compile.exitCode !== 0) { job.exitCode = compile.exitCode; job.producerLine = firstRefusal(compile.lines) ?? `rigc build exited ${compile.exitCode} without a named refusal`; outcome = 'refused'; return; }
822
827
  const carried = steps.check && steps.carried ? await steps.carried(push) : null;
823
- if (carried && 'refused' in carried) { job.producerLine = carried.refused; job.status = 'refused'; push(`review: ${carried.refused}`); return; }
828
+ if (carried && 'refused' in carried) { job.producerLine = carried.refused; outcome = 'refused'; push(`review: ${carried.refused}`); return; }
824
829
  if (steps.check && carried) steps.check(carried.summary, null);
825
830
  else if (steps.check) {
826
831
  // check measures the scratch rig; a FAIL is its judgment, recorded beside the build, not a refusal of the build.
@@ -838,7 +843,7 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
838
843
  if (steps.hashed) await steps.hashed();
839
844
  // #166: an undo's re-run must reproduce the build its record names, file for file; otherwise it is refused, not guessed.
840
845
  const changed = steps.candidate ? null : restoredDifference(job.id, job.build.files);
841
- if (changed) { job.producerLine = changed; job.status = 'refused'; push(`review: ${changed}`); return; }
846
+ if (changed) { job.producerLine = changed; outcome = 'refused'; push(`review: ${changed}`); return; }
842
847
  if (!steps.candidate) latestId = job.id;
843
848
  await writeFile(join(dir, 'result.json'), JSON.stringify({ ...job, status: 'built', reused: false }, null, 1) + '\n', { mode: 0o600 });
844
849
  // Each Apply replaces the previous scratch build of this package in the scratch root; #166 keeps the applied records'
@@ -847,11 +852,12 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
847
852
  // "built" is published last: a reader that sees it finds the scratch root already settled (no sibling mid-removal).
848
853
  job.status = 'built';
849
854
  } catch (error) {
850
- job.status = 'failed'; job.producerLine = error instanceof Error ? error.message : String(error); push(`review: ${job.producerLine}`);
855
+ outcome = 'failed'; job.producerLine = error instanceof Error ? error.message : String(error); push(`review: ${job.producerLine}`);
851
856
  } finally {
852
- if (restoring?.id === job.id && job.status !== 'built') restoring = null;
853
- // Only a built Apply keeps its scratch directory; a refusal or failure leaves nothing behind.
854
- if (job.status !== 'built') await rm(dir, { recursive: true, force: true }).catch(() => {});
857
+ const built = job.status === 'built';
858
+ if (restoring?.id === job.id && !built) restoring = null;
859
+ // Only a built Apply keeps its scratch directory; a refusal or failure leaves nothing behind — removed before it is published.
860
+ if (!built) { await rm(dir, { recursive: true, force: true }).catch(() => {}); job.status = outcome ?? 'failed'; }
855
861
  }
856
862
  }
857
863