Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Valid time (page editions by date)
GBRA-217. Guide: page history. Recorded time (known_as_of) is the
belief ledger.
src/core/valid-time.ts— the one date normaliser (validDatein TypeScript,validDateSqlin SQL, the same pattern:YYYY-MM-DD, a YAML Date or a midnight-UTC timestamp; anything else is undated), the pure status rules (validTimeVerdict: status, historyretained|incomplete|unknown, the onewhy), the plain-read status (currentValidTime), the write advisory (validTimeWriteAdvisory) and the client's version-skew check (assertValidTimeEcho,host_upgrade_required). Intervals are half-open, as links are.src/core/ops/valid-time-read.ts—get_page {as_of}. One REPEATABLE READ transaction: the page identity (a slug in two granted sources refuses), then one statement picks over the current page and itspage_versions(greatestvalid_fromon or before the date, latest recorded on a tie) with the counts, gap facts and ambiguity window, before any visibility check; a chosen edition the caller may not see ispage_not_found. Reasons usereplacedBecauseSql, so their visibility matchesget_versions. Onlyin_forcereturns text at the top level; other statuses nest the edition underlast_in_force/earliest_known. Large or segmented editions are windowed; the gpw1 cursor pinsv:<version id>or the current revision (found again among versions if the page moved on), and an edition that has gone answershistory: incomplete,why: edition_pruned. Recovery fixes:git log --followfor a world-visible file in a source with a checkout, elseask_userfor a backup (always on a repo-less brain).src/core/persistence/valid-time-advisory.ts—withValidTimeAdvisory, wrapped aroundwithChangeReasoninservice.tsfor page writes: compares the page before and after the apply and addsvalid_timeto the outcome (valid_from_unparsed,valid_time_correction,valid_time_date_only). Reads only rows the write's transaction produced; changes nothing.src/cli/page-render.tsvalid-time helpers —validTimeLine(stderr header),printAsOfWindows(pages a windowed edition by itsnextcalls),asOfExitCode(15 when no edition is in force).src/cli/main.tscallsassertValidTimeEchoon every thin-client as_of reply.
Pinned by test/valid-time-gbra217.test.ts (PGLite and Postgres).