Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: resolve impact diagnostics from the runner environment (#13500)

Adam Eivy7640fd4abdcc
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index adb82e7493..1044635586 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -34,8 +34,6 @@ jobs:
name: Plan test impact
runs-on: ubuntu-latest
timeout-minutes: 10
- env:
- PORTOS_CI_IMPACT_DIAGNOSTICS: ${{ runner.temp }}/portos-ci-impact
# Still live despite the removed push trigger: a called workflow inherits
# the caller's event, and release.yml calls this one from a push.
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '[skip ci]')
diff --git a/scripts/ci-impact-diagnostics.js b/scripts/ci-impact-diagnostics.js
index d41736dc0b..e9d7010e30 100644
--- a/scripts/ci-impact-diagnostics.js
+++ b/scripts/ci-impact-diagnostics.js
@@ -10,6 +10,8 @@ import { writeStepSummary } from './lib/githubOutput.js';
export const IMPACT_STAGES = ['admission', 'base', 'hidden-content', 'import-case', 'plan', 'node-minimum', 'summary', 'autofixer-install', 'syntax'];
const OWNER_KEY = 'PORTOS_CI_IMPACT_OWNER';
+const diagnosticRoot = () => process.env.PORTOS_CI_IMPACT_DIAGNOSTICS
+ || (process.env.RUNNER_TEMP ? join(process.env.RUNNER_TEMP, 'portos-ci-impact') : undefined);
const validToken = value => typeof value === 'string' && /^[\da-f-]{36}$/.test(value);
const codeValue = value => Number.isInteger(value) && value >= 0 && value <= 255 ? value : null;
const signalValue = value => /^SIG[A-Z0-9]{1,12}$/.test(value ?? '') ? value : null;
@@ -70,7 +72,7 @@ function evidence(stage, boundary, values, log = console.log) {
// Child output and GitHub command files pass through unchanged. These records
// observe the direct command's events; they do not claim runner/job completion.
export async function observeImpactStage(stage, command, args, {
- root = process.env.PORTOS_CI_IMPACT_DIAGNOSTICS, env = process.env,
+ root = diagnosticRoot(), env = process.env,
scan = scanImpactOwners, log = console.log,
} = {}) {
if (!IMPACT_STAGES.includes(stage) || !command) throw Error('Invalid impact stage invocation.');
@@ -135,7 +137,7 @@ export function reportImpactSettlement(root, { scan = scanImpactOwners, log = co
async function main() {
const [stage, separator, command, ...args] = process.argv.slice(2);
if (stage === 'settlement' && separator === undefined) {
- reportImpactSettlement(process.env.PORTOS_CI_IMPACT_DIAGNOSTICS);
+ reportImpactSettlement(diagnosticRoot());
return;
}
if (separator !== '--') throw Error('Invalid impact stage invocation.');
diff --git a/scripts/ci-impact-diagnostics.test.js b/scripts/ci-impact-diagnostics.test.js
index a7d3394d23..ea26f595d2 100644
--- a/scripts/ci-impact-diagnostics.test.js
+++ b/scripts/ci-impact-diagnostics.test.js
@@ -24,12 +24,12 @@ it('preserves command output, failure status, and GitHub command files through t
const result = spawnSync(process.execPath, [launcher, 'plan', '--', process.execPath, '-e', `
require('node:fs').appendFileSync(process.env.GITHUB_OUTPUT, 'server_files=["example.test.js"]\\n');
console.log('original-output'); process.exitCode = 17;
- `], { encoding: 'utf8', timeout: 10_000, env: { ...process.env, PORTOS_CI_IMPACT_DIAGNOSTICS: dir, GITHUB_OUTPUT: output } });
+ `], { encoding: 'utf8', timeout: 10_000, env: { ...process.env, PORTOS_CI_IMPACT_DIAGNOSTICS: '', RUNNER_TEMP: dir, GITHUB_OUTPUT: output } });
expect(result.error).toBeUndefined();
expect(result.status, result.stderr).toBe(17);
expect(result.stdout).toContain('original-output');
expect(readFileSync(output, 'utf8')).toBe('server_files=["example.test.js"]\n');
- const record = JSON.parse(readFileSync(join(dir, 'plan.json'), 'utf8'));
+ const record = JSON.parse(readFileSync(join(dir, 'portos-ci-impact', 'plan.json'), 'utf8'));
expect(record).toMatchObject({ stage: 'plan', exit: { code: 17 }, close: { code: 17 } });
expect(record.exit.elapsedMs).toBeLessThanOrEqual(record.close.elapsedMs);
expect(result.stdout).not.toContain(record.token);
@@ -140,6 +140,7 @@ it('observes every repository stage before runner finalization while retaining t
const jobs = workflowJobs(readFileSync(new URL('../.github/workflows/ci.yml', import.meta.url), 'utf8'));
for (const stage of IMPACT_STAGES) expect(jobs.impact).toContain(`node scripts/ci-impact-diagnostics.js ${stage} -- `);
expect(jobs.impact).toMatch(/timeout-minutes: 10\n/);
+ expect(jobs.impact).not.toContain('${{ runner.temp }}');
expect(jobs.impact).toContain('if: always()\n run: node scripts/ci-impact-diagnostics.js settlement');
expect(jobs.impact).not.toMatch(/continue-on-error/);
expect(jobs.gate).toContain('CI_GATE_RESULT_IMPACT: ${{ needs.impact.result }}');