Skip to content

timesheets 0.4.0: two open copies, send lease, concurrent compaction (#123 M5) - #246

Merged
michielbdejong merged 2 commits into
mainfrom
claude/timesheets-m5-lease
Oct 1, 2026
Merged

michielbdejong merged 2 commits into
mainfrom
claude/timesheets-m5-lease

Conversation

@michielbdejong

Copy link
Copy Markdown
Contributor

Implements #123 M5 on top of M4 (#240), following #97 §5.2/§6.2 and #177: bookkeeping on the row, compare-on-open, review before send. Mock-tested only, so declared, not verified.

  • Advisory send lease (app/lease.ts): one open copy sends at a time.
    • The lease lasts 60 s, is renewed per change and per write, and is given back at the end.
    • A sync leaves another copy's unconfirmed create alone.
    • It is advisory because /app-write has no compare-and-swap. Two lease takes within one round trip can both succeed; the worst case is a duplicate create, which "Remove duplicate" fixes.
  • Range edits as write-once intents (app/intents.ts):
    • S22: an edit that sees open edits replaces them, or is refused if one of them reaches outside its range.
    • S21: edits made apart that disagree become a "between your edits" conflict on every device. Their changes are held until one is chosen.
  • S28: when two devices compact at once, both snapshots are kept as tips, and the next compaction merges them. This also fixes diffs that were dropped when one device appended while another compacted; the new tests fail on the old code.
  • Measured fold time and snapshot sizes at 600 entries (18 ms, 333 KB) and 2,000 entries (58 ms, 1.11 MB), written in the README. Snapshots are not split per week.
  • App 0.4.0 (143,683 bytes, limit 158,000), catalog entry, usertest-4.

Tests:

  • app/multiDevice.test.ts: S21 ×2, equal edits, S22 and its refusal, and 4 lease cases.
  • app/observationLog.test.ts: S28, plus 2 cases where one device compacts while another appends.
  • app/timeline/timeline.test.ts: the render text.

Lanes: typecheck, unit (466 tests) and e2e (4/4, 1 worker as in CI) pass. Tooling tests, apps and ontology checks, certify, oxlint and oxfmt also pass.

Defaults chosen (product questions go to #227):

  • The two sides of a conflict between your edits read "here" and "another device or an earlier visit", because the device id is new on each page load.
  • A range edit that only partly overlaps an unsent one is refused, not split.
  • When the same field is edited directly on two devices, the later save wins.

#123 stays open for the live checks in a test workspace and for the billable question.

🤖 Generated with Claude Code

…M5)

- Send lease (app/lease.ts, #97 answer 5): clockify-lease on the log head,
  60 s, taken (read, write, read back) before a send, renewed before each
  change and write, given back at the end. Held elsewhere: nothing is
  sent. A sync leaves another copy's unconfirmed create alone. Advisory:
  /app-write has no compare-and-swap.
- Range edits as intents (app/intents.ts, #97 §5.2, #177 §4.5): one
  write-once resource per range edit or resolution under the log head,
  found by clockify-intent-of; status derived (replaced, open).
  S22: an edit over open range edits it can see replaces them (their
  staged changes put back first); refused if one reaches outside it.
  S21: overlapping open edits made apart with different targets are a
  "between your edits" conflict on every device, their changes held
  until one is chosen.
- Concurrent compaction (S28): the head keeps a second snapshot tip
  instead of dropping it, unites tails (keeping diffs another copy
  appended during a compaction, which were dropped before), replays the
  DAG when there are two tips, and the next compaction merges them.
- fakeStore saves only properties set since the last save, as the host.
- Tests: S21 (range and same entry), equal edits, S22 and its refusal,
  the lease (held, expired, long batch, lost mid-batch, sync), S28 and
  one-compacts-one-appends in both orders. Measured fold/snapshot sizes
  at 600 and 2,000 entries (README).
- App 0.4.0 (143,683 bytes; limit re-measured), catalog copy, usertest-4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	usertest/catalog.mjs
@michielbdejong
michielbdejong merged commit 58e5ead into main Oct 1, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant