gitoria
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
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- 2f2959c5|||PR apps API: broken JSON body gives 400 invalid_json, not 500mre
- f7c6ca07Merge branch 'ident-chooser-selector' into mainGitoria
- 691abb8e|||PR tests: find ident identity choice without the removed .choose classmre
- 16a3530fMerge branch 'heap-revert' into mainGitoria
- 220a80e0|||PR Remove temporary /__heap route and heap helper; logmre
- 13f0c342Merge branch 'hl25-records' into mainGitoria
- a002ecb7|||PR records: HL25 report, heap helper, logmre
- 2492a55cTemporary keyed /__heap route for the live memory snapshotmre
- fefaedd2log: tracker PR-only, HL25 startedmre
- 21aa57calog: parkmre
- e9f950a8reports: G25c soakmre
- a7783686log: deploy 9f41ffcmre
- 9f41ffc1log: W30b mergedmre
- bef635c1Merge branch 'w30b'mre
- 15b996a5Org list: keyed rows by @id, newest first, concat instead of hand loopmre
- c4f6d9e3reports: G25c growth huntmre
- b88e39f1log: privacy cleanup donemre
- bfd7826ddocs: neutral example organisation namemre
- 01b71c2edocs: neutral wording in missions, reports and logmre
- 3eeea733log: 2026-11-09 PR flow plan and membersmre