Skip to content

Replace the status's historyReadAt time with a historyRead bool - #90

Merged
joeychilson merged 1 commit into
mainfrom
history-read
Oct 19, 2026
Merged

joeychilson merged 1 commit into
mainfrom
history-read

Conversation

@joeychilson

Copy link
Copy Markdown
Owner

The status's historyReadAt was a time nothing reads, rewritten at every catch-up: serve's push() turned it into a bool before comparing, and each catch-up wrote the database for it. It's now historyRead, true once the first read of the agents' history has finished, written once. Protocol 2.

Flags: changes the protocol (1 → 2); edits 3 tests for the field's name and protocol number; changes what state.history_at holds (no new revision)

Changes

  • historyRead replaces historyReadAt: whether state.history_at is set.
  • ingest sets history_at once, when the first read ends, even with nothing to read.
  • push() compares statuses less at, rewriting nothing.
  • The app's reading: a status whose historyRead is false.

Evidence

contract/status.notification.json:

     "at": 1791460800000,
-    "historyReadAt": 1791460740000,
+    "historyRead": true,

New serve::tests::a_status_is_pushed_only_when_what_it_shows_changed: pushes false, then true after the first read, nothing after a catch-up that read a session but changed nothing shown, then one after a settings change.

New ingest::tests::a_catch_up_after_the_first_read_that_reads_nothing_writes_nothing fails on main: another connection's data_version moves (left: 3, right: 2).

The Swift engine test passes. Main's binary, this one, then main's again share a scratch database fine; rollback is the previous build (details).

Not checked: the app by hand; real user databases.

Risk

  • A hello during the first read now gets historyRead: false; main set the time once files were listed, before reading them.

Left out

  • db::REVISIONS[0]'s comment still says "last read"; shipped scripts aren't edited. architecture.md has the new meaning.

Review focus

  • src/ingest.rs ingest: when history_at is written. The rest is mechanical.
Runs

Swift against the real engine:

$ cargo build
$ TURNSCOPE_BINARY="$PWD/target/debug/turnscope" swift test --package-path macos/TurnscopeKit -Xswiftc -warnings-as-errors
✔ Test theRealEngineIsStartedSaysHelloAndTakesChanges() passed after 3.232 seconds.
✔ Test run with 46 tests in 0 suites passed after 3.232 seconds.

Main's binary (old) and this branch's (new) on one scratch data directory, with TURNSCOPE_OFFLINE=1 and the fixture home's copy, target/tmp/home. Each sessions catches up, and each hello is followed by shutdown. jq prints a field that's missing as null.

fresh db, old binary: sessions
  history_at=1792449407450
old serve hello:
{"at":1792449360000,"historyReadAt":1792449407509,"historyRead":null}
new binary: sessions, twice (nothing new)
  history_at=1792449407509 then 1792449407509
new serve hello:
{"at":1792449360000,"historyReadAt":null,"historyRead":true}
back to the old binary: sessions
  ok, history_at=1792449407854
fresh db, new binary: before any read
  history_at=no db
  sessions twice: history_at=1792449407912 then 1792449407912

The push test fails at assert!(pushed(&mut server).is_empty()) when push() skips its comparison. It fails with left: [], right: [true] when the first read is not marked because there was nothing to read.

These were also run and passed: cargo fmt --check, cargo clippy --all-targets --locked -- -D warnings, cargo test --locked (again with TZ=America/Chicago), RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --locked, shellcheck scripts/*.sh, actionlint, cargo deny check advisories, scripts/build-app.sh, and scripts/check-app.sh on that build. check-app.sh reported "serve: protocol 2, a hello answered with a status" and drew the panel from the contract's example.

@joeychilson
joeychilson marked this pull request as ready for review October 19, 2026 22:44
@joeychilson
joeychilson merged commit a9743c3 into main Oct 19, 2026
3 checks passed
@joeychilson
joeychilson deleted the history-read branch October 19, 2026 23:20
@joeychilson joeychilson mentioned this pull request Oct 20, 2026
joeychilson added a commit that referenced this pull request Oct 20, 2026
Sets the version to 0.1.5 so the `v0.1.5` tag can start the release, and tidies its notes: grouped by area, plus the protocol change that #90 didn't mention.
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