GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #106 from Capsize-Games/codex/proof-runtime-fixes-… · Capsize-Games/headlesscode@0fdcf39

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • package-lock.json
  • package.json
  • scripts
    • rsi-proof-demonstration.ts
  • src
    • cloud
      • __tests__
        • openshell-provider.test.ts
      • openshell-provider.ts
    • rsi
      • __tests__
        • controller-fleet.test.ts
        • microusd.test.ts
        • proof-campaign.test.ts
        • proof-demonstration-launcher.test.ts
      • controller.ts
      • microusd.ts
      • postgres-queue.ts
      • proof-campaign.ts
      • reports.ts
      • types.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎package-lock.json‎

Copy file name to clipboardExpand all lines: package-lock.json
+2-2Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "headlesscode",
3-
"version": "1.9.3",
3+
"version": "1.9.4",
44
"description": "Coding-agent harness with CLI and HTTP interfaces, parallel Git worktree orchestration, and bounded recursive self-improvement (RSI).",
55
"license": "Apache-2.0",
66
"repository": {
Collapse file

‎scripts/rsi-proof-demonstration.ts‎

Copy file name to clipboardExpand all lines: scripts/rsi-proof-demonstration.ts
+101-12Lines changed: 101 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,28 @@ function assertEngineeringRunProfile(run: RsiRunRecord, expected: ReturnType<typ
320320
}
321321
}
322322

323+
function assertEngineeringRunIdentity(
324+
run: RsiRunRecord,
325+
config: RsiConfig,
326+
campaign: string,
327+
arm: "fixed-control" | "self-hosted",
328+
rootCommit: string,
329+
seed: string,
330+
runtime: NonNullable<RsiConfig["workerHarnessRuntime"]>,
331+
expectedProfile: ReturnType<typeof openRouterProfileById>,
332+
): void {
333+
const plannedRunId = engineeringRunId(campaign, arm)
334+
const expectedProfileId = expectedProfile.id === RSI_DEFAULT_OPENROUTER_PROFILE_ID ? undefined : expectedProfile.id
335+
if (run.runId !== plannedRunId || run.workerHarnessPairId !== campaign || run.workerHarnessMode !== arm || run.baseCommit !== rootCommit || run.workerHarnessSamplingSeed !== seed || run.model !== config.model || run.openRouterProfileId !== expectedProfileId || JSON.stringify(run.workerHarnessRuntime) !== JSON.stringify(runtime) || run.proofCampaign?.manifest.phaseMode !== "engineering-only") {
336+
throw new Error(`engineering replay found a ${arm} run with changed frozen identity`)
337+
}
338+
const frozenConfig = run.proofCampaign.manifest.settings?.effectiveConfig
339+
if (!frozenConfig || typeof frozenConfig !== "object" || Array.isArray(frozenConfig) || (frozenConfig as Record<string, unknown>).maxTokens !== config.maxTokens) {
340+
throw new Error(`engineering replay found a ${arm} run with a changed frozen output-token limit`)
341+
}
342+
assertEngineeringRunProfile(run, expectedProfile)
343+
}
344+
323345
export function assertProofWorkerProfile(config: RsiConfig, expected: ReturnType<typeof openRouterProfileById>, env: NodeJS.ProcessEnv = process.env): void {
324346
const roles = resolveRoles(config.roles, env, config.model)
325347
const worker = roles.worker
@@ -473,20 +495,81 @@ export async function runEngineeringArm(config: RsiConfig, campaign: string, arm
473495
const prior = before.runs.concat(before.activeRuns).filter((entry) => entry.workerHarnessPairId === campaign && entry.workerHarnessMode === arm)
474496
if (prior.length > 1) throw new Error(`engineering replay found duplicate archived ${arm} runs`)
475497
const existing = prior[0]
476-
const plannedRunId = engineeringRunId(campaign, arm)
477498
if (existing) {
478-
if (existing.runId !== plannedRunId || existing.baseCommit !== rootCommit || existing.workerHarnessSamplingSeed !== seed || existing.model !== config.model || existing.openRouterProfileId !== (expectedProfile.id === RSI_DEFAULT_OPENROUTER_PROFILE_ID ? undefined : expectedProfile.id) || JSON.stringify(existing.workerHarnessRuntime) !== JSON.stringify(runtime) || existing.proofCampaign?.manifest.phaseMode !== "engineering-only") throw new Error(`engineering replay found a ${arm} run with changed frozen identity`)
479-
const frozenConfig = existing.proofCampaign.manifest.settings?.effectiveConfig
480-
if (!frozenConfig || typeof frozenConfig !== "object" || Array.isArray(frozenConfig) || (frozenConfig as Record<string, unknown>).maxTokens !== config.maxTokens) throw new Error(`engineering replay found a ${arm} run with a changed frozen output-token limit`)
481-
assertEngineeringRunProfile(existing, expectedProfile)
482-
if (existing.finishedAt && existing.proofCampaign.state === "finished") {
483-
const arms = existing.proofCampaign.ledgerSnapshot?.arms as Array<Record<string, unknown>> | undefined
484-
if (!arms?.some((entry) => entry.arm_id === arm && entry.state === "finished") || existing.proofCampaign.manifest.schedule.some((cell) => cell.phase === "confirmation")) throw new Error(`engineering replay found an invalid terminal ${arm} checkpoint`)
499+
assertEngineeringRunIdentity(existing, config, campaign, arm, rootCommit, seed, runtime, expectedProfile)
500+
const proofCampaign = existing.proofCampaign!
501+
if (existing.finishedAt && proofCampaign.state === "finished") {
502+
const arms = proofCampaign.ledgerSnapshot?.arms as Array<Record<string, unknown>> | undefined
503+
if (!arms?.some((entry) => entry.arm_id === arm && entry.state === "finished") || proofCampaign.manifest.schedule.some((cell) => cell.phase === "confirmation")) throw new Error(`engineering replay found an invalid terminal ${arm} checkpoint`)
485504
return existing
486505
}
487506
if (before.runs.some((entry) => entry.runId === existing.runId)) throw new Error(`engineering ${arm} run is archived without a terminal campaign finish; refusing to create a second identity`)
488507
}
489-
return runner({ ...config, dryRun: false, workerHarnessRunId: plannedRunId, ...(existing ? { resumeRunId: existing.runId } : {}), workerHarnessMode: arm, workerHarnessPhase: "development", workerHarnessPairId: campaign, workerHarnessEngineeringOnly: true, workerHarnessRuntime: runtime })
508+
return runner({ ...config, dryRun: false, workerHarnessRunId: engineeringRunId(campaign, arm), ...(existing ? { resumeRunId: existing.runId } : {}), workerHarnessMode: arm, workerHarnessPhase: "development", workerHarnessPairId: campaign, workerHarnessEngineeringOnly: true, workerHarnessRuntime: runtime })
509+
}
510+
511+
export async function runEngineeringArms(config: RsiConfig, campaign: string, rootCommit: string, seed: string, runtime: NonNullable<RsiConfig["workerHarnessRuntime"]>, runner: typeof runRsi = runRsi): Promise<RsiRunRecord[]> {
512+
const runs: RsiRunRecord[] = []
513+
for (const arm of ["fixed-control", "self-hosted"] as const) {
514+
const run = await runEngineeringArm(config, campaign, arm, rootCommit, seed, runtime, runner)
515+
runs.push(run)
516+
if (run.proofCampaign?.state === "incomplete") break
517+
}
518+
return runs
519+
}
520+
521+
export async function writeEngineeringStopReport(options: Options, run: RsiRunRecord): Promise<string> {
522+
if (run.proofCampaign?.state !== "incomplete" || !run.proofCampaign.ledgerSnapshot) throw new Error("engineering stop report requires a durable incomplete campaign checkpoint")
523+
const armId = run.proofCampaign.armId
524+
const events = (run.proofCampaign.ledgerSnapshot.events as Array<Record<string, unknown>> | undefined) ?? []
525+
const failureEvents = events.filter((event) => event.arm_id === armId && event.event_type === "candidate-incomplete")
526+
if (failureEvents.length === 0) throw new Error("engineering stop report has no durable candidate-incomplete event")
527+
const body = {
528+
schemaVersion: 1 as const,
529+
outcome: "incomplete" as const,
530+
campaignId: run.proofCampaign.campaignId,
531+
manifestSha256: run.proofCampaign.manifestSha256,
532+
rootCommit: run.baseCommit,
533+
runId: run.runId,
534+
armId,
535+
reason: run.proofCampaign.incompleteReason ?? "candidate proof attempt remains unresolved",
536+
runReportPaths: run.reports,
537+
candidateFailureEvents: failureEvents,
538+
ledgerSnapshot: run.proofCampaign.ledgerSnapshot,
539+
ledgerSnapshotSha256: canonicalHash(run.proofCampaign.ledgerSnapshot),
540+
qualifiedEvidencePath: options.output,
541+
}
542+
const stopReport = { ...body, digestSha256: canonicalHash(body) }
543+
const stopPath = await assertSupervisorOnlyPlanPath(options.repo, `${options.output}.stop.json`)
544+
await fs.mkdir(path.dirname(stopPath), { recursive: true, mode: 0o700 })
545+
try {
546+
const existing = JSON.parse((await readProtectedProofInput(options.repo, stopPath)).toString("utf8")) as { digestSha256?: string }
547+
if (existing.digestSha256 !== stopReport.digestSha256 || canonicalHash(Object.fromEntries(Object.entries(existing).filter(([key]) => key !== "digestSha256"))) !== stopReport.digestSha256) throw new Error("existing engineering stop report differs from the incomplete campaign checkpoint")
548+
} catch (error) {
549+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error
550+
await fs.writeFile(stopPath, `${JSON.stringify(stopReport, null, 2)}\n`, { mode: 0o600, flag: "wx" })
551+
}
552+
return stopPath
553+
}
554+
555+
export async function writePriorIncompleteEngineeringStopReport(
556+
options: Options,
557+
config: RsiConfig,
558+
campaign: string,
559+
rootCommit: string,
560+
seed: string,
561+
runtime: NonNullable<RsiConfig["workerHarnessRuntime"]>,
562+
): Promise<{ run: RsiRunRecord; stopPath: string } | undefined> {
563+
const expectedProfile = openRouterProfileForModel(config.model, config.roles?.worker?.openRouterProfile)
564+
assertProofWorkerProfile(config, expectedProfile, process.env)
565+
const archive = await readArchive(config.archiveDir)
566+
const prior = archive.runs.concat(archive.activeRuns).filter((run) => run.workerHarnessPairId === campaign && run.proofCampaign?.state === "incomplete")
567+
if (prior.length > 1) throw new Error("engineering replay found duplicate incomplete runs for the campaign")
568+
const run = prior[0]
569+
if (!run) return undefined
570+
if (run.workerHarnessMode !== "fixed-control" && run.workerHarnessMode !== "self-hosted") throw new Error("engineering replay found an incomplete run with an invalid arm identity")
571+
assertEngineeringRunIdentity(run, config, campaign, run.workerHarnessMode, rootCommit, seed, runtime, expectedProfile)
572+
return { run, stopPath: await writeEngineeringStopReport(options, run) }
490573
}
491574

492575
export async function executeEngineeringPair(options: Options, env: NodeJS.ProcessEnv = process.env, runner: typeof runRsi = runRsi): Promise<EngineeringEvidenceRecord | undefined> {
@@ -509,9 +592,15 @@ export async function executeEngineeringPair(options: Options, env: NodeJS.Proce
509592
const config = await validateRuntimeEvaluatorIntegrity(preview.execution.configs[0], options)
510593
assertProofWorkerProfile(config, openRouterProfileById(preview.model.profileId ?? RSI_DEFAULT_OPENROUTER_PROFILE_ID), process.env)
511594
const campaign = campaignId(preview.seeds.engineering)
512-
const runs: RsiRunRecord[] = []
513-
for (const arm of ["fixed-control", "self-hosted"] as const) {
514-
runs.push(await runEngineeringArm(config, campaign, arm, preview.rootCommit, preview.seeds.engineering, preview.runtime, runner))
595+
const priorIncomplete = await writePriorIncompleteEngineeringStopReport(options, config, campaign, preview.rootCommit, preview.seeds.engineering, preview.runtime)
596+
if (priorIncomplete) {
597+
throw new Error(`engineering campaign already has an incomplete terminal run ${priorIncomplete.run.runId}; stop report: ${priorIncomplete.stopPath}; a new run identity is required`)
598+
}
599+
const runs = await runEngineeringArms(config, campaign, preview.rootCommit, preview.seeds.engineering, preview.runtime, runner)
600+
const incompleteRun = runs.find((run) => run.proofCampaign?.state === "incomplete")
601+
if (incompleteRun) {
602+
const stopPath = await writeEngineeringStopReport(options, incompleteRun)
603+
throw new Error(`engineering stopped with unresolved proof accounting in ${incompleteRun.workerHarnessMode ?? "unknown"}; stop report: ${stopPath}; no further arm or qualified engineering evidence was written`)
515604
}
516605
const archive = await readArchive(config.archiveDir)
517606
const savedRuns = runs.map((run) => archive.runs.concat(archive.activeRuns).filter((entry) => entry.runId === run.runId))

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.