From 4577e46459fa10380fdd01e76700cf8e086fc5b9 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Sat, 24 Oct 2026 13:11:27 -0500 Subject: [PATCH] Untested: row 328 isolate revoked T9 sync from timer ticks --- BUILD-LOG.md | 2 + agents/fethry/work/queue-328/BUILD.md | 73 ++++++++++ .../fethry/work/queue-328/manifest.r1.sha256 | 1 + agents/fethry/work/queue-328/stress.py | 127 ++++++++++++++++++ docs/SESSIONS.md | 2 + .../bus/tests/library-credential.test.mjs | 7 +- 6 files changed, 209 insertions(+), 3 deletions(-) create mode 100644 agents/fethry/work/queue-328/BUILD.md create mode 100644 agents/fethry/work/queue-328/manifest.r1.sha256 create mode 100644 agents/fethry/work/queue-328/stress.py diff --git a/BUILD-LOG.md b/BUILD-LOG.md index c4f77056d..f9e19df85 100644 --- a/BUILD-LOG.md +++ b/BUILD-LOG.md @@ -5560,3 +5560,5 @@ claim. Receipts and limitations in agents/lena/work/queue-296/BUILD.md and run-r 2026-10-24 | Fethry | Row266 implementation verified before candidate commit. Six owned production paths plus four new tests, no old tests edited. RED history and fixture corrections recorded before action. Editor build, webui458/0, plugins120/0, bus1000/0 and all12 scripts exit0. Initial bus999/1 hit old T9 50ms timer race; sage4158 authorized three unchanged credential-file6/0 reruns and whole bus1000/0 rerun, all green. Raw/normalized TAP provenance retained. Candidate/mutants/review next; no landing claim. 2026-10-24 | Fethry | Row266 final verification: candidate3095d6ea5, manifest5f816042 (10 package paths, no old-test edit). All16 isolated mutants killed by assertions with restored hashes and unchanged candidate. Initial M01 uncaught plugin refusal excluded, strengthened only new doesNotReject assertion and full plugins120/0 rerun. Final cwd node/Chromium sweep empty, killpg cleanup recorded. Full webui458/0, plugins120/0, bus1000/0, all12 scripts0; earlier T9 race plus four unchanged green reruns retained. Push/review packet next; Sage gate and two reviews remain. + +2026-10-24 | Fethry | Row328 (#1826/Vikunja622, mos-1594, sage4190) prepared UNTESTED on fethry/row328 from2ce476d54. Before: second T9 start keeps50ms periodic timer, causing old bus999/1 race in266. After: only T9 helper accepts interval default50 and second start uses2147483647 TIMEOUT_MAX; assertions/product unchanged, approved test +4/-3. Stress runner prepared for50 M1-50, optional50 M1-1,50 fixed, whole file; per-run TMPDIR/TAP/load, hash restoration and killpg cleanup. No tests before Sage CLEAR; explicit untested push requested. diff --git a/agents/fethry/work/queue-328/BUILD.md b/agents/fethry/work/queue-328/BUILD.md new file mode 100644 index 000000000..39819a366 --- /dev/null +++ b/agents/fethry/work/queue-328/BUILD.md @@ -0,0 +1,73 @@ +# Row 328 — T9 second-start library sync race (#1826, Vikunja 622) + +Fethry14f80e3c; branch fethry/row328; new worktree +/home/jwoltje/.t3/worktrees/mosaic-stack/fethry-row328 on base2ce476d54. +Brief: docs/plans/2026-10-24_t9-library-sync-race.md, section Brief. +Authority: sage4190 and Mos1594. Review Boyd first, Dewey landing; Sage owns slot/gate/landing. +Status: UNTESTED. No CLEAR yet; Gyro then Della have the next slots. No tests run. +Local root npm ci --ignore-scripts --no-audit --no-fund completed, no shared dependency links. + +## Root cause and bounded fix + +Row266 bus999/1 exposed T9's revoked second start racing a later timer pass. Waiting for the +first held log only orders the initial pass: sync.mjs clears running in finally before the +runtime writes the held log. A later50ms timer can acquire running before the manual verb. +The verb then gets library-sync-busy instead of the asserted library-fetch-no-grant. + +Only packages/bus/tests/library-credential.test.mjs T9 changes. Give its start closure an +intervalMs parameter default50. Leave the first start as start(); pass2147483647 to the second. +This is Node TIMEOUT_MAX, within the runtime positive safe integer validator. Do not exceed it: +Node clamps overflow to1ms. The startup tick still runs and the existing held-log wait orders it; +no periodic tick can overlap the second verb within this test's60s lifetime. close still clears +its unref'd interval. A comment names mos-1594 and why the interval differs. + +No assertion changes, other-test changes, product code, timer hooks or row278 work. If more is +needed, stop for Sage/Mos. Existing approved test numstat will be recorded after implementation. + +## Plan and acceptance (sage4190 / pinned brief) + +- [x] Read brief and relevant runtime/sync/T9 paths; create separate worktree; queue next names328. +- [x] Owner start from canonical, op fethry-0037, rev3992, no timeout. +- [x] Implement only the start parameter/second interval and short comment; assert the diff has + no changed assertion text and no production path. Write the stress/M1 runner below. +- [ ] Commit/push marked Untested, per Sage's explicit instruction overriding the default test- + before-commit rule for this gated assignment. Send tip, manifest and concrete run plan. +- [ ] After Sage CLEAR: RED M1-50,50 T9-only runs, each fresh mktemp-d TMPDIR under scratch. + If no race failure, run M1-1 for50 and retain both. Neither failing means stop/report. +- [ ] Restore exact fixed bytes/SHA after each mutant; git diff --stat against build commit + must be empty. Run the same50 fixed T9 attempts, all must pass; whole touched file too. +- [ ] Record all commands/counts/load averages and TAPs, cleanup own process groups, return slot. + Sage's landing gate: bus suite and every scripts/test-*.sh. Boyd then Dewey review. + +## Stress runner contract + +stress.py --clear-key KEY --output ABS_NEW_DIR --runs 50 +runs M1-50 first; M1-1 only if needed; then fixed50; then the whole touched file. +Each child is timeout -k10 120 node --test --test-reporter=tap --test-concurrency=1 +--test-timeout=90000 [--test-name-pattern '^C2-03b T9 runtime:'] TEST_PATH. +Each child gets its own process group and unique mktemp-d TMPDIR. Live-provider env is unset. +Every TAP and per-run load average/exit/counts is retained. Only an assertion of actual +library-sync-busy versus expected library-fetch-no-grant counts as the required race failure; +other failures stop for Sage. Fixed runs require exactly one passing T9, no failures/cancels; +whole file requires all six pass. Mutants restore in finally and verify byte hash against HEAD. +The runner does not weaken assertions, manufacture load, change production, or retry away a red. + +## Prepared candidate (UNTESTED, pending CLEAR) + +Approved pre-existing test: packages/bus/tests/library-credential.test.mjs numstat +4/-3. +Exact diff is limited to default50 parameter, shorthand intervalMs, second-start2147483647 +and one Mos1594 comment. Python static comparison verifies the complete expected transformation +and unchanged assertion lines. No other package path changes. stress.py parses with Python AST; +no test/harness execution, Node syntax run, suite, stress attempt or mutant has run. +Manifest.r1 freezes the single test file; the runner/docs are review-packet support. + +Run plan after CLEAR (about3-5min for100-150 T9 runs plus whole six-test file): + mkdir only the desired parent output directory, then from this worktree: + python3 agents/fethry/work/queue-328/stress.py --clear-key SAGE_CLEAR_KEY \ + --runs 50 --output /mnt/storage/scratch/tmp/fethry-328-EVIDENCE_UNIQUE +The runner creates that new output dir itself. It does NOT stop at M1's first expected race: all50 +are retained, then optional50 M1-1 if M1-50 all green, then50 fixed and whole touched file. +Unexpected red, neither mutant failing, or any fixed red stops and reports; no additional fix +is authorized. Subsequent bus/scripts scope belongs to Sage's landing gate unless CLEAR expands it. +After execution copy/record evidence, counts/load, restoration git diff --stat and own-process sweep, +commit/push evidence, return slot, then first-review handoff Boyd. No review/green claim yet. diff --git a/agents/fethry/work/queue-328/manifest.r1.sha256 b/agents/fethry/work/queue-328/manifest.r1.sha256 new file mode 100644 index 000000000..8e560debc --- /dev/null +++ b/agents/fethry/work/queue-328/manifest.r1.sha256 @@ -0,0 +1 @@ +ba485ecf337b4845a1c3e8ba2f4e2f0ee221d981b8d74080a3b0bcbef55d6605 packages/bus/tests/library-credential.test.mjs diff --git a/agents/fethry/work/queue-328/stress.py b/agents/fethry/work/queue-328/stress.py new file mode 100644 index 000000000..f7a1012f8 --- /dev/null +++ b/agents/fethry/work/queue-328/stress.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python3 +"""Mos-1594: M1 RED then the same fifty fixed T9 runs. Requires Sage's slot CLEAR.""" +import argparse +import hashlib +import json +import os +from pathlib import Path +import re +import signal +import subprocess +import time + +ROOT = Path(__file__).resolve().parents[4] +TEST = Path('packages/bus/tests/library-credential.test.mjs') +ANCHOR = b' runtime = await start(2147483647);' +BASE_COMMAND = ['node', '--test', '--test-reporter=tap', '--test-concurrency=1', '--test-timeout=90000'] +PATTERN = '^C2-03b T9 runtime:' + + +def digest(value): + return hashlib.sha256(value).hexdigest() + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--clear-key', required=True, help='Sage message authorizing this test slot') + parser.add_argument('--output', required=True, type=Path) + parser.add_argument('--runs', type=int, default=50) + args = parser.parse_args() + if args.runs < 50: + parser.error('Mos requires at least fifty attempts per phase') + output = args.output.resolve() + output.mkdir(parents=True, exist_ok=False) + path = ROOT / TEST + fixed = path.read_bytes() + committed = subprocess.check_output(['git', 'show', f'HEAD:{TEST}'], cwd=ROOT) + assert fixed == committed and fixed.count(ANCHOR) == 1, 'Start with the committed fixed test' + report = {'clear': args.clear_key, 'source': subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=ROOT, text=True).strip(), + 'fixedSHA256': digest(fixed), 'runsPerPhase': args.runs, 'loadStart': os.getloadavg(), 'runs': [], 'status': 'running'} + + def save(): + (output / 'summary.json').write_text(json.dumps(report, indent=2) + '\n') + + def run(phase, number, whole=False): + temporary = subprocess.check_output(['mktemp', '-d', '/mnt/storage/scratch/tmp/fethry-328.XXXXXX'], text=True).strip() + command = ['timeout', '-k', '10', '120', *BASE_COMMAND] + if not whole: + command += ['--test-name-pattern', PATTERN] + command += [str(TEST)] + env = {**os.environ, 'TMPDIR': temporary} + env.pop('MOSAIC_LIVE_PROVIDER', None) + env.pop('NODE_TEST_CONTEXT', None) + log = output / f'{phase}-{number:03}.tap' + before = time.monotonic() + signals = [] + with log.open('w') as stream: + child = subprocess.Popen(command, cwd=ROOT, env=env, stdout=stream, stderr=subprocess.STDOUT, start_new_session=True) + try: + code = child.wait(timeout=135) + except subprocess.TimeoutExpired: + os.killpg(child.pid, signal.SIGKILL) + signals.append('KILL') + code = child.wait() + finally: + try: + os.killpg(child.pid, signal.SIGTERM) + signals.append('TERM') + time.sleep(.2) + try: + os.killpg(child.pid, signal.SIGKILL) + signals.append('KILL') + except ProcessLookupError: + pass + except ProcessLookupError: + pass + text = log.read_text() + counts = {name: int(value) for name, value in re.findall(r'^# (tests|pass|fail|cancelled|skipped) (\d+)$', text, re.M)} + green = code == 0 and counts.get('pass') == (6 if whole else 1) and counts.get('fail') == 0 and counts.get('cancelled') == 0 + race = (not whole and code == 1 and counts.get('fail') == 1 and counts.get('cancelled') == 0 + and 'ERR_ASSERTION' in text and re.search(r'^not ok \d+ - C2-03b T9 runtime:', text, re.M) is not None + and "+ code: 'library-sync-busy'" in text and "- code: 'library-fetch-no-grant'" in text) + entry = {'phase': phase, 'attempt': number, 'command': command, 'TMPDIR': temporary, 'load': os.getloadavg(), + 'exit': code, 'counts': counts, 'green': green, 'race': race, 'seconds': round(time.monotonic() - before, 3), + 'cleanupSignals': signals, 'TAP': log.name, 'TAPSHA256': digest(log.read_bytes())} + report['runs'].append(entry) + save() + print(json.dumps(entry), flush=True) + if not green and not (phase.startswith('M1-') and race): + raise RuntimeError(f'Unexpected red in {log}; stop for Sage, do not change assertions') + return race + + def mutant(interval): + label = f'M1-{interval}' + path.write_bytes(fixed.replace(ANCHOR, f' runtime = await start({interval});'.encode(), 1)) + try: + races = sum(run(label, number) for number in range(1, args.runs + 1)) + report[label] = {'attempts': args.runs, 'raceFailures': races} + return races + finally: + path.write_bytes(fixed) + assert digest(path.read_bytes()) == report['fixedSHA256'], 'Mutant restore changed fixed test' + stat = subprocess.check_output(['git', 'diff', '--stat', 'HEAD', '--', str(TEST)], cwd=ROOT, text=True) + assert not stat, 'Mutant restore differs from build commit' + report[label + '-restore'] = {'SHA256': digest(path.read_bytes()), 'gitDiffStat': stat} + save() + + try: + races = mutant(50) + if races == 0: + races = mutant(1) + if races == 0: + raise RuntimeError('Neither M1 interval failed; fix cannot be shown to matter. Stop for Sage.') + for number in range(1, args.runs + 1): + run('fixed', number) + run('whole-file', 1, whole=True) + report['status'] = 'green' + finally: + path.write_bytes(fixed) + report['loadEnd'] = os.getloadavg() + report['restored'] = digest(path.read_bytes()) == report['fixedSHA256'] + report['gitDiffStat'] = subprocess.check_output(['git', 'diff', '--stat', 'HEAD', '--', str(TEST)], cwd=ROOT, text=True) + save() + assert report['restored'] and not report['gitDiffStat'] + + +if __name__ == '__main__': + main() diff --git a/docs/SESSIONS.md b/docs/SESSIONS.md index 1ff1c9a63..2097a194c 100644 --- a/docs/SESSIONS.md +++ b/docs/SESSIONS.md @@ -1681,3 +1681,5 @@ are never rewritten or removed; corrections are new entries. 2026-10-24 | Fethry14f80e3c | Row266 C2-10c (#1771), sage4154/4156 | New fethry/row266 worktree from962046aaa, doc-only fast-forward487500a16. Read pinned brief and amendment; local npm ci roots, no links. Identified room.read missing guard check/last; Sage authorized bounded broker hydration amendment and re-pin. Owner start retried after stale-pin refusal; design/current-code notes in agents/fethry/work/queue-266/BUILD.md. Slot held; RED-first new tests next; no production edits yet. 2026-10-24 | Fethry14f80e3c | Row266 C2-10c (#1771) implementation complete for review | Source3095d6ea5; manifest5f81604210 paths. Full webui458/0, plugins120/0, bus1000/0,12 scripts0,16/16 mutants. Initial old T9 timer race and sage4158 unchanged6/0 x3 plus1000/0 rerun preserved. No old tests changed; own-cwd process sweep empty. Slot returned with push handoff; Boyd then Dewey, Sage landing pending. + +2026-10-24 | Fethry14f80e3c | Row328 T9 timer race (#1826) | New fethry/row328 worktree on2ce476d54, owner start rev3992 opfethry-0037. Test-only +4/-3 under Mos1594, no assertion/product changes. Local root npm ci, no links. Static-only stress/M1 preparation and untested push; waiting for Sage CLEAR, then Boyd/Dewey review. diff --git a/packages/bus/tests/library-credential.test.mjs b/packages/bus/tests/library-credential.test.mjs index 23ba4aae1..bc14937e4 100644 --- a/packages/bus/tests/library-credential.test.mjs +++ b/packages/bus/tests/library-credential.test.mjs @@ -286,8 +286,8 @@ test('C2-03b T9 runtime: the chief\'s store file and user, then a real revoke th return write.call(this, chunk, ...rest); }; t.after(() => { process.stderr.write = write; }); - const start = () => startBroker({ dataRoot, businesses: { acme: verbDoc(gitea.url, root) }, organization: { dir: root, rolesDir, system: systemFor(root) }, - librarySync: { command, intervalMs: 50 } }); + const start = (intervalMs = 50) => startBroker({ dataRoot, businesses: { acme: verbDoc(gitea.url, root) }, organization: { dir: root, rolesDir, system: systemFor(root) }, + librarySync: { command, intervalMs } }); const untilAsync = async (fn) => { const end = Date.now() + 10000; while (!fn() && Date.now() < end) await sleep(10); }; let runtime = await start(); @@ -311,7 +311,8 @@ test('C2-03b T9 runtime: the chief\'s store file and user, then a real revoke th revoking.close(); chmodSync(slot, 0o000); calls.length = 0; lines.length = 0; - runtime = await start(); + // mos-1594: TIMEOUT_MAX keeps later timer ticks from racing the revoked verb sync. + runtime = await start(2147483647); await untilAsync(() => lines.length >= 1); const human2 = runtime.broker.bindHuman({ business: 'acme', human: 'jason', via: 'cli', outsideAgent: true }); await assert.rejects(runtime.broker.request(human2, { verb: 'library.sync', args: { project: 'books' } }), { code: 'library-fetch-no-grant' });