tracker
All repositories: gitoria
2.5 KB
// A barrier releases 16 independent processes against one absent path.import { spawn, spawnSync } from 'node:child_process';import { mkdtempSync, writeFileSync, existsSync, readFileSync, rmSync } from 'node:fs';import { join, resolve } from 'node:path';import assert from 'node:assert/strict';const root = resolve(import.meta.dirname, '../../..');const bin = process.env.HL_BIN || join(root, 'native/zig-out/bin/hybriel');const work = mkdtempSync(join(process.env.TMPDIR || '/tmp', 'hl-exclusive-'));const children = [];try {const src = join(work, 'claim.hl');writeFileSync(src, `import { createFile, exists } from 'hl:fs'import { args } from 'hl:proc'import { sleep } from 'hl:time'a = args()createFile(a[0] + '.ready.' + a[1], '')while (!exists(a[0] + '.go')) { sleep(0.005) }console.log(createFile(a[0], a[1]))`);const native = join(work, 'claim');const built = spawnSync(bin, ['--native', src, '-o', native], { encoding: 'utf8' });assert.equal(built.status, 0, `${built.error || ""}${built.stdout || ""}${built.stderr || ""}`);for (const engine of ['run', 'native']) {const path = join(work, engine);const promises = Array.from({ length: 16 }, (_, i) => {const child = spawn(engine === 'run' ? bin : native, engine === 'run' ? [src, path, String(i)] : [path, String(i)]);children.push(child);return new Promise((resolve, reject) => {let output = '';child.stdout.on('data', b => { output += b; });child.stderr.on('data', b => { output += b; });child.on('error', reject);child.on('close', code => resolve({ code, output: output.trim(), i }));});});const deadline = Date.now() + 30000;while (!Array.from({ length: 16 }, (_, i) => existsSync(path + '.ready.' + i)).every(Boolean)) {assert.ok(Date.now() < deadline, 'workers did not reach barrier');await new Promise(r => setTimeout(r, 20));}writeFileSync(path + '.go', '');const answers = await Promise.all(promises);for (const a of answers) { assert.equal(a.code, 0, a.output); assert.match(a.output, /^(true|false)$/); }const winners = answers.filter(a => a.output === 'true');assert.equal(winners.length, 1);assert.equal(readFileSync(path, 'utf8'), String(winners[0].i));console.log(`exclusive-create ${engine}: 1/16 won, winner content preserved`);}} finally {for (const c of children) if (c.exitCode === null) c.kill('SIGKILL');await Promise.all(children.filter(c => c.exitCode === null).map(c => new Promise(r => c.once('close', r))));rmSync(work, { recursive: true, force: true });}
Branches
Latest commits
- 783957c2Merge branch 'sr1-search' into mainTracker
- 792b9652README: search results come from the routeTracker
- fd8570b1|||PR search: one server exchange per keystrokeTracker
- e8f5cbcaLog: SR1 result, SR1bTracker
- 8ad275a4Log/status: tracker 68, SR1Tracker
- f5a06a0fLog: gitoria push setup, SR1Tracker
- d6b109baMission SR1mre
- 608b7558Log: FF1 merged via PR #1mre
- 2939d94cMerge branch 'ff1-gate-failfast' into mainTracker
- c934361a|||PR tests: gates fail fast when the app exits during startmre
- d714ae42Log/status: AP56 closed out, FF1mre
- a429d088Mission FF1mre
- 03bbfba3Log: AP56c causemre
- 24845fe3Log: AP56b result, AP56cmre
- 6a6d71eaLog: gitoria membershipmre
- 8b842dc8Log + CONDUCTOR: gitoria PR switch-onmre
- 6bb7c20estatus: window 2026-11-09mre
- 5db84974Log: Apollo window GO, AP56b started, BS1 copy removedmre
- e84586a7Mission AP56bmre
- 15917f03Record PR workflow rule (gitoria#50)mre