mirror of
https://github.com/garrytan/gbrain.git
synced 2026-07-27 22:15:33 +00:00
* fix(extract): links_extraction_lag never clears on Postgres (#1768) Stamp the full-microsecond updated_at (via to_char ... AT TIME ZONE UTC) instead of the millisecond-truncated JS Date, so links_extracted_at equals the DB updated_at exactly and the staleness predicate clears. Stamp SQL unchanged: version-arm backdating still works, D4 preserved, CDX-1 strengthened. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(core): out-of-band hard-deadline watchdog primitive (#1633) Bun eval-Worker that SIGTERM->grace->SIGKILLs its own process from a separate OS thread, so a sync whose main event loop is starved (ReDoS spin) still dies. Signals SELF (no PID-reuse footgun). Empirically validated on Bun 1.3.13. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(sync): arm hard-deadline watchdog + graceful SIGINT cancel (#1633) cli.ts installs the watchdog before connectEngine (bounds connect hangs); resolveSyncHardDeadline + composeAbortSignals in sync.ts; SIGINT graceful cancel on single-source + --all; withRefreshingLock timer unref'd. Non-TTY default 3600s makes cron orphan-pileup structurally impossible. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(claude): annotate process-watchdog + #1768/#1633 fixes Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: bump version and changelog (v0.42.13.0) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: rebump v0.42.13.0 -> v0.42.18.0 (queue collision) Sibling workspaces claimed v0.42.13-v0.42.17; advance this branch's slot. VERSION + package.json + CHANGELOG header + CLAUDE.md annotations + llms bundles. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(key-files): current-state phrasing for #1633/#1768 entries (fix check:doc-history) The doc-history guard bans the bolded **v0.X release-clause marker in reference docs (history belongs in CHANGELOG + git). Rewrote the extract.ts/sync.ts additions as current-state prose and de-versioned the process-watchdog entry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
/**
|
|
* Fixture for test/process-watchdog.serial.test.ts. Spawned via `bun`.
|
|
*
|
|
* Usage: bun watchdog-harness.ts <mode> <deadlineMs> <graceMs>
|
|
* starve-with — install the watchdog, then starve the event loop forever.
|
|
* The watchdog must SIGKILL this process by deadline+grace.
|
|
* starve-without — no watchdog, just starve. Proves the busy loop truly hangs
|
|
* (the test kills it). Isolates the watchdog as cause of death.
|
|
* clean-dispose — install with a long deadline, dispose immediately, exit 0.
|
|
* The watchdog must NOT kill a cleanly-disposed process.
|
|
*
|
|
* Safety net: the busy loop self-exits after 8s so a failed test kill can't hang CI.
|
|
*/
|
|
import { installProcessWatchdog } from '../../src/core/process-watchdog.ts';
|
|
|
|
const mode = process.argv[2] ?? 'starve-with';
|
|
const deadlineMs = Number(process.argv[3] ?? 300);
|
|
const graceMs = Number(process.argv[4] ?? 150);
|
|
|
|
if (mode === 'starve-with' || mode === 'clean-dispose') {
|
|
const handle = installProcessWatchdog({ deadlineMs, graceMs, label: 'test-wd' });
|
|
if (mode === 'clean-dispose') {
|
|
handle.dispose();
|
|
process.stdout.write('DISPOSED\n');
|
|
process.exit(0);
|
|
}
|
|
}
|
|
|
|
// Starve the main event loop with a synchronous busy loop (simulates ReDoS).
|
|
const start = Date.now();
|
|
while (Date.now() - start < 8000) { /* spin — no await, no yield */ }
|
|
process.stdout.write('SURVIVED\n'); // must NOT print under starve-with
|
|
process.exit(0);
|