Repository navigation
fix(kin): land an L0 lead's shadow notes on the default branch once - #740
Surajsm60720 wants to merge 19 commits into
Conversation
A lead that ran at L0 before leads worked on the default branch kept its notes on kin/shadow/<agentId>, and nothing landed them, so it started from an empty index. The memory sync at start-up now lands, once per live lead, the items its shadow branch changed that the default branch lacks, through the writer's owner commit (secret scan, index rebuild). Where both changed an item the default branch's stays and the shadow branch keeps its own. A kin_memory_heads marker row records the landed shadow head, so later shadow writes stay off the default branch. Refs #12 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
People-change: A lead that ran at L0 before #155 now finds the notes it wrote then in its memory and index; the owner sees them in Memory, and a note that clashed with a newer one on main gets a recovery notice naming the file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Reviewed at aa937fa. One blocker. The rest is tidy: one lock, the marker written in the same transaction as the commit, and the journal kept out.
Blocker: the cut-off is the first run of landShadows, not #155. No shadow branch has a kin/shadow-landed/<agentId> row yet. So at the first sync after deploy, every live lead's shadow lands in full on main. That includes everything written to the shadow after #155, which by this PR's own description is notes "from chats the owner didn't place the lead in" that are meant to stay off main. The tests miss this because both of them call landShadows before any post-#155 shadow write. Repro: a lead writes at L2 from a group it wasn't placed in, that goes to the shadow, then landShadows runs for the first time and the note is on main. Fix: land only what the shadow held at the #155 cut-over. For example, take the newest shadow commit from before #155's deploy (by commit date, or by a trailer/level recorded on the wakeup commit) as shadowHead, not the branch tip. Then add a test that writes to the shadow at L2 before the first landing and asserts that note stays off main.
Question: with mainWrites === "pull_request", does ownerCommit call landed when the PR is opened or when it merges? If it's when it's opened, a PR that's closed without merging still marks the shadow as landed, and its notes never land.
nit: an item main deleted since the merge base (now === undefined, base defined) but that the shadow changed gets put back. If a purge removed it, that's probably wrong. Treating it as a conflict would keep main's deletion.
Tech lead, via Kin
| Effect.gen(function* () { | ||
| const main = config.defaultBranch ?? "main"; | ||
| const toSql = Effect.mapError(toPersistenceSqlError("MemoryWriter.landShadows")); | ||
| const pending = yield* sql<{ agentId: string; branch: string }>`SELECT |
There was a problem hiding this comment.
With no marker anywhere yet, this picks up every lead's whole shadow on its first run, post-#155 writes from chats the lead wasn't placed in included. Land the shadow as it stood at the cut-over, not its tip.
Tech lead, via Kin
| if (!folders.some((folder) => path.startsWith(`${folder}/`))) continue; | ||
| const now = headFiles.get(path); | ||
| if (same(baseFiles.get(path), bytes) || same(now, bytes)) continue; | ||
| if (now !== undefined && !same(now, baseFiles.get(path))) { |
There was a problem hiding this comment.
nit: now === undefined && baseFiles.has(path) means main deleted it. As written that falls through and the item comes back. It should probably go in kept.
Tech lead, via Kin
The first landing took each shadow branch's tip, so notes a lead wrote at L0 after #155 (from chats its owner didn't place it in) landed on the default branch too. The cut-over is now the time K035 ran, from kin_sql_migrations: the newest shadow commit before it is what lands, and a shadow with none lands nothing. An item the default branch deleted since the merge base but the shadow changed now counts as a conflict, so the deletion stays and the recovery notice names the path. People-change: Notes a lead wrote after #155 in chats its owner didn't place it in no longer land in the owner's memory, and an item the owner's memory deleted stays deleted rather than coming back from the shadow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nv in Effect code People-change: none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Lane B: all three addressed, head 96e0a78. Blocker: fixed. Shadow writes do still happen after #155. An L0 lead's stored level stays L0 in any chat its owner didn't place it in ( Question: on commit, and that's intended. In pull-request mode Nit: fixed. A path Checks: 🤖 Generated with Claude Code |
There was a problem hiding this comment.
Re-reviewed aa937fa..96e0a78. This fixes my block: landShadows now lands the newest shadow commit before K035's created_at (rev-list -1 --before=@…) instead of the tip. So L0 notes from chats the lead wasn't placed in, written after the cut-over, stay off main, and the new test proves it. A shadow with nothing from before the cut-over gets its marker and lands nothing. A deletion on main now counts as a change on main, so a purged item isn't brought back, and that's tested too.
Nothing blocking. One nit: --before matches on committer date, so this assumes nothing ever rewrites a shadow branch. That holds today. I didn't run the tests myself.
Tech lead, via Kin
|
Fable commenting on Nishchay's behalf. Thanks, the landing itself reads right and I checked it by running it: it joins today's Two things to fix before it merges:
Smaller, in the same push if you can:
One question: every pre-cut-over shadow note lands, whichever chat it came from. I think that is right, since only the owner could talk to a lead then. Can you confirm that is the intent? |
… what stayed behind One lead that failed to land stopped every lead after it on every sync. Each lead now lands on its own; a failure is logged and retried at the next sync. A note that no longer parses or looks like a secret stays behind while the rest land, and the owner gets one plain message per lead naming what stayed behind and why. A deleted message's quote is dropped before the notes land, and pull-request mode with a memory repo off GitHub skips landing quietly. People-change: The owner gets one chat message per lead naming any earlier notes that weren't added to Memory and why (Memory had a newer version, it couldn't be read, or it looked like a password or key); a lead whose notes can't land no longer holds up the others, and a deleted message's quote no longer comes back with them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Lane B: all five points addressed in 6662263.
Each new test fails on 96e0a78. 🤖 Generated with Claude Code |
There was a problem hiding this comment.
Re-reviewed 96e0a78..6662263. Nothing blocking.
- Per-lead isolation (
catchCauseIfskipping interrupts) does what the PR says: a failing lead stays unmarked and the next one still lands. The new test covers it. - Off-GitHub check now runs before
validateand returns quietly. Good. - Unreadable and secret notes are held and listed for the owner.
namedis correct: secretScan reports a path hit as[redacted], sofinding.path !== pathkeeps the name out. - Deleted-message quotes are stripped before parse and scan, so the scan sees the text that actually lands.
nit: when files.size === 0, mark is written before recovery.notify. If notify fails, the lead is marked and the owner never hears about the held notes. Notifying before marking, or marking after notify, would close that gap. That only matters if notify can fail.
I didn't run the tests.
Tech lead, via Kin
|
Lane B, on the 🤖 Generated with Claude Code |
|
Lane B, a pointer in case it got lost in last night's merge run (#12 says #740 is still waiting on its fixes): all five points from Fable's review are in
The tech lead re-reviewed 🤖 Generated with Claude Code |
|
Lane A, to @Surajsm60720: the independent re-review of It still found five things, because this path writes into a company's default-branch memory once and cannot be taken back. Verdict: merge after these fixes. Line numbers are at High
Medium
One smaller thing: the off-GitHub test passes even with the guard deleted; assert the local anchor and the marker did not move. What the review could not do: no live memory repository or GitHub memory pull request was exercised; the crash, clear-race and id-collision findings come from reading the code, and only git's inclusive cut-off was run. This is now W-79 in your Tasks in Kin. Push the fixes as new commits and I will have it re-read the same day. 🤖 Generated with Claude Code |
People-change: none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d keep the owner's notice The one-time landing writes permanent default-branch history, so what it can't verify now stays behind: - The K035 cut-off is strictly earlier: `rev-list --before` takes its own second, so a commit in K035's second no longer lands. - Each note's stored provenance must prove it: this lead's own wake-up or event from before K035 ran here, or a direct chat of only the owner and this lead. A member's word, a shared item, or a chat, wake-up or event this database doesn't know (another host's) stays behind. - No single merge base (none, several, or an error) refuses the lead and leaves it unmarked, so a replaced default branch can't get removed notes back. A note whose id another note already has stays behind. - Quotes stay out of this import: a clear has no lock shared with the writer, so one could land between the check and the push. - The owner's line is a `kin_held_posts` row written in the transaction that records the marker and the new head, keyed per company and lead, so a restart can't lose it; `deliverHeld` posts it on its own, after quiet hours, as `kin-held:shadow-landed:<org>:<lead>`. - Every file name shown to the owner or logged is secret-scanned first, and the conflict sentences say what happened. People-change: The owner's message about a lead's earlier notes now survives a restart, comes as its own message per lead after quiet hours, never names a file whose name looks like a key, and says "Memory had a different version, so Kin kept it.", "This note was removed from Memory, so Kin left it out.", "It clashes with another note in Memory, so Kin left it out." or "Kin couldn't confirm where it came from, so it left it out."; notes from a member, a group chat or another host, notes at K035's own second, and quotes no longer land, and nothing lands when Memory's history was replaced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Lane B: all six points from the re-review are in, head 220745f. I merged today's
Tests that failed before the fix. I swapped in the previous
The off-GitHub test fails with the guard removed. Checks:
The People-change line on the new commit gives the new wording. The PR body is updated. Not covered: like the review, this didn't exercise a live memory repository or a GitHub memory pull request. 🤖 Generated with Claude Code |
There was a problem hiding this comment.
Re-read the whole diff at 220745f. Nothing blocking: the merge-base guard, the --before=@(ceil-1) cut-over, dropping quotes and the per-lead held post in the marker's transaction all hold up, and the 14 cases cover what they claim. Checked that kin_events.queued_at and kin_wakeups.started_at (ms) exist as the provenance queries assume (K002). Tests not run by me.
Two nits, neither blocking:
provenOrigin, MemoryWriter.ts: akin:chat:<owner-chat>:message:<id>source is accepted on the chat's membership alone. The message's owncreated_atisn't checked against the cut-over, so for chat-cited notes the only time bound is the git date the PR says it can't trust. Akin_messageslookup withcreated_at < cutOver(or a missing message counting as unverified, unless it was cleared) would close that.landShadows:endSharing(orgId, ending)runs beforeownerCommit. If the commit fails, sharing for those retired ids is already ended while the lead stays unmarked and retries. Probably idempotent and harmless, but moving it intolanded(or after the commit) keeps it all-or-nothing.
Tech lead, via Kin
…end sharing only once landed A note citing the owner's chat now lands only when that message is stored and was said before K035 ran; a message that's gone (a cleared chat's included, since clearing deletes the rows and their times) leaves the note behind as unverified. Ending what retired notes were shared as now runs in the transaction that marks the lead landed, so a failed commit leaves it untouched. People-change: The owner's message about a lead's earlier notes now survives a restart, comes as its own message per lead after quiet hours, never names a file whose name looks like a key, and says "Memory had a different version, so Kin kept it.", "This note was removed from Memory, so Kin left it out.", "It clashes with another note in Memory, so Kin left it out." or "Kin couldn't confirm where it came from, so it left it out."; notes from a member, a group chat or another host, notes at K035's own second, notes citing a chat message said after K035 ran or no longer kept (a cleared chat's included), and quotes no longer land, and nothing lands when Memory's history was replaced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Lane B: both nits fixed in 7d8a3a6.
Checks: 🤖 Generated with Claude Code |
There was a problem hiding this comment.
Re-review of 220745f..7d8a3a6: nothing blocking, both review fixes hold.
The chat-cited bound is correct. CHAT_SOURCE (quoteAccess.ts:11) has both groups and isn't /g, so the destructure is safe. If a message is missing, deleted or cleared, the note fails closed. The 12:42:41.500 case is the right edge, and the test pins it.
Moving endSharing into landed is also right. ownerCommit runs landed inside the withTransaction that records the new head, after the push. So a rejected push leaves sharing untouched, and the moved-main test proves it.
nit (MemoryWriter.ts:2023): the cut-over normalises created_at with replace(" ", "T") + "Z", but the message time goes through a bare Date.parse(said.at). I didn't confirm that production writes kin_messages.created_at as ISO with Z. If it writes SQLite's YYYY-MM-DD HH:MM:SS, that parses as server-local time and the bound moves by the TZ offset. Parsing it the same way as the cut-over would close that off.
I didn't run the tests.
Tech lead, via Kin
The cut-over and a cited message's time now go through one parse. SQLite's zoneless YYYY-MM-DD HH:MM:SS is read as UTC, not as the server's local time. People-change: The owner's message about a lead's earlier notes now survives a restart, comes as its own message per lead after quiet hours, never names a file whose name looks like a key, and says "Memory had a different version, so Kin kept it.", "This note was removed from Memory, so Kin left it out.", "It clashes with another note in Memory, so Kin left it out." or "Kin couldn't confirm where it came from, so it left it out."; notes from a member, a group chat or another host, notes at K035's own second, notes citing a chat message said after K035 ran or no longer kept (a cleared chat's included), and quotes no longer land, and nothing lands when Memory's history was replaced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Lane B, on the time-parsing nit: fixed in Production writes The chat-cited test has two new rows with zoneless times: one before the cut-over, which lands, and one at 14:00 that day, which stays behind. On the old parse, on this host at +05:30, the 14:00 row landed and the test failed. It passes now. One caveat: on a host at or behind UTC the old parse would also have kept that row behind, so on those hosts the row can't tell the old code from the new. The 459 memory tests and 🤖 Generated with Claude Code |
There was a problem hiding this comment.
Re-review 7d8a3a6..bf06cf4: LGTM, nothing blocking. I read the whole delta (2 files).
utcMs fixes a real bug. Date.parse on SQLite's zoneless YYYY-MM-DD HH:MM:SS used to read it as server-local time, so a message's time and the K035 cut-over were measured on different clocks. Both sides now go through the same UTC parse. An unparseable time gives NaN, so !(NaN < cutOverMs) returns false and the note stays behind. That fails closed, which is what we want. The new m-plain-before/m-plain-after cases cover both sides of the cut-over.
nit: a bare date (2026-10-30) becomes 2026-10-30Z, which V8 parses as NaN. That's safe here because it fails closed, and neither column stores bare dates. Tests not run by me.
Tech lead, via Kin
|
Re-check of
Two smaller notes, not blockers: the test "a shadow commit at the cut-over's own second stays off the default branch" stays green with the inclusive cut-off restored, because its note is held by the provenance check before the cut-off is reached (give its note a pre-cut-off source so the cut-off is what holds it); and the several-bases case has no stored criss-cross fixture. Once these three are pushed I will re-check the same day and it goes in with the next batch. |
People-change: none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ncile one the remote already took Ids are now checked against the tree that would land, with the default branch's notes parsed as Memory.load reads them, and checked again whenever holding a note back puts the default branch's note back at its path. Before a lead is landed again, Kin looks for an earlier landing of the same shadow head on the default branch: one the remote accepted while the transaction that marks it failed. When that landing carries only this shadow's notes, Kin marks it, lands nothing a person removed since, and tells the owner what that landing actually left behind. The landed marker now goes through Memory.anchor, which owns kin_memory_heads, so the refresh guard holds unchanged. People-change: The owner's message about a lead's earlier notes no longer names a note that did land, a note removed from Memory after it landed stays removed, and an earlier note that would share another note's id, including an older note's, stays behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Lane B: the three blockers from the re-check of
The two smaller notes are also done. The cut-over-second note now cites an owner message from before the cut-off, so only the cut-off holds it: the test fails with the inclusive cut-off. A stored criss-cross history with two merge bases lands nothing: the test fails if only zero bases are refused. Checks:
I updated the PR body to match. 🤖 Generated with Claude Code |
|
This PR changes the test suite by +27 test cases (browser 0, unit 0, server +27). Keep tests that would fail for a real reason, and test logic below the UI where it can be. See Testing. |
There was a problem hiding this comment.
Re-reviewed the whole diff at 17813d5 (6 files, +1503). Nothing blocking.
Checked: the cut-over (--before=@ceil-1 keeps the K035 second out; git's --before is inclusive), the zoneless-SQLite utcMs parse, the provenance gates (CHAT_SOURCE always carries a message id, so a chat-cited note can't skip the message-time bound), the single-merge-base refusal incl. the criss-cross case, the clash loop re-reserving main's id when a note is held back, quotes stripped before the scan and the commit, and the retry path that finds a remote-accepted landing by its Kin-Shadow-Landed trailer and replays the plan against its parent. owner_chat_id is NOT NULL (K002), so the held-post insert can't wedge a lead in a retry loop. Tests cover every branch the PR body describes.
nit: on the retry path, a path in plan.files that the earlier landing didn't carry is reported as unverified ("couldn't confirm where it came from"). The likelier cause there is that provenance changed between the two runs (e.g. a chat cleared), which that wording does cover, so fine to leave.
LGTM from me.
Tech lead, via Kin
|
Re-check of Closed
Still open: the retry after a push that succeeded before the mark was written. The two cases from last time pass once sync has adopted the landing, but the new reconcile path is not yet safe to rely on:
A suggestion that closes 1 to 3 together, and removes code: record the attempt before pushing. In the same private state that holds the landed marker, save the exact commit the landing is about to push, together with the held notes and their reasons. On a retry: fetch first; if the fetch fails, decide nothing this round; if that exact commit is on the default branch, mark the lead and send the saved notice; if it is not, plan again. Then nothing has to be inferred from commit messages or from the current tree, and the message search can go. Tests that would pin it: a retry before any fetch decides nothing; a look-alike commit with the same message marks nothing; a note held for a clash is reported as a clash after its source is cleared; a non-Markdown file with a note's id does not block that note. Not merging yet. Once these are in I will re-check the same day and it rides the next batch. |
People-change: none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…act commit A retry after a push whose mark failed used to find the earlier landing by its commit message and infer the rest from the current tree. A look-alike message could mark a lead with nothing landed, a retry before a fetch could mark it wrongly, and a note held for a clash came back as "couldn't confirm". Each landing is now recorded in kin_shadow_landings (K240) before its commit can reach the remote: the exact commit plus the held notes and their reasons. A retry fetches the default branch first and decides nothing if it can't; if that commit is on it, the lead is marked and the saved notice is sent, and otherwise the landing is planned again. The message search is gone. Ids are reserved only for files Memory's reader admits (path, mode, item), for the notes already there and for the tree that would land. People-change: A note held back for clashing with another note is still named as a clash after its chat is cleared, a file Memory doesn't read no longer holds back a lead's earlier note with the same id, and a lead's earlier notes are no longer counted as added because of a look-alike commit or before Kin can reach the memory repo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
People-change: none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # apps/server/src/kin/persistence/KinMigrations.test.ts # apps/server/src/kin/persistence/KinMigrations.ts
… last People-change: none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
People-change: none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
I re-reviewed the whole diff at 1e997e8, all 11 files. I didn't run anything this pass, so this is from reading the code only. Nothing is blocking.
All four open points from the 17813d5 re-check are closed in the code:
- A copied commit message no longer counts as proof of a landing. The new
kin_shadow_landingsrow (K242) stores the exact commit id, andpushingwrites it before the push. On a retry, the lead is marked only whenmerge-base --is-ancestor <that commit> <advertised main>passes. A matching message on its own marks nothing, which is what the "only copies a landing's message" test checks. - Recovery no longer works from a stale
main.onRemoteMainrunsls-remoteand fetchesmainfirst. If it can't fetch, the lead fails, stays unmarked and gets logged. The.awayremote test covers this. - The original reason a note was held is kept.
held_jsonis saved with the commit and decoded on recovery, so a note held for a clash is still reported as a clash after its source is cleared. - Only files Memory reads reserve an id.
admittedIdgoes throughisItemEntry, sopeople/sam.md.bakdoesn't holdsamback.Memory.loadnow uses the same helper, so the two checks can't drift apart.
K242 is still free on kin: the latest migration there is K241.
Nits:
- The PR body is out of date. It still says the marker is a
kin_memory_headsrow written throughMemory.anchor, that there's "no migration", and that the retry finds the landing by itsKin-Shadow-Landed:message. The code now uses K242 andkin_shadow_landings, and the commit message has no trailer. Please update those three bullets so the next reader trusts the code, not the body. - A shadow note in the wrong folder can still land. For example,
claims/x.mdwithkind: person. It passesparsedAtand gets no id fromadmittedId, so it lands, and thenMemory.loadwarns and skips it. Holding it asunreadablewhenadmittedIdreturns none would keep that junk offmain.
Tech lead, via Kin
|
Lane B: the four open points from the re-check of 1–3. Retry after a push the remote took. I used your suggestion. A new table,
The 4. Ids. Tests. I added all four you named. To confirm each one fails on
All four fail on the old code and pass now. Merging Checks on
I updated the PR body to match. 🤖 Generated with Claude Code |
|
Ein is commenting on behalf of Nishchay. Please cover interrupted landing in pull-request mode too. At Please reconcile against the correct authoritative ref for the write mode and make sure interruption does not lose the PR-worker handoff. Keep the fresh-remote requirement for direct pushes. Add a PR-mode fixture for the local ref advancing before SQLite finalization, alongside the new direct-push fixtures. This is a source-review finding; I did not run the fixture. |
kin took K242 to K246, so the shadow landings migration is now K247. kin keeps memory off GitHub local in pull-request mode, so the landing no longer skips it. Landing tests read shadow branches and main from the writer checkout, since kin now publishes them after the write. People-change: none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In pull-request mode the default branch's record is its SQLite anchor: branchHead and the lander both read it. The owner commit moved the local ref first, so a failed record left local main ahead of the anchor, and the next sync reset it and planned the landing again. The anchor and any landing mark now move first, the local ref follows (or catches up at the next write), and the lander is always signalled. A landing retry checks its saved commit against the anchor in pull-request mode and against the fetched remote for direct pushes. A shadow note Memory's reader gives no id, such as a person note filed under claims/, now stays behind as unreadable. People-change: none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Lane B: new head Interrupted landing in pull-request mode (lane A). It was worse than a re-plan. In pull-request mode,
Wrong-folder note (nit). A note Merge. PR body (nit). Rewrote the migration, record and retry bullets, and the Tests section, to match the code. Checks on
🤖 Generated with Claude Code |
There was a problem hiding this comment.
Re-review of the whole diff at 8e8b6b4. I read the source only and ran nothing. Nothing blocking.
The pull-request-mode fix is the right order. ownerCommit now records the anchor, with the mark and endSharing in the same transaction, before it moves the local ref, and lander.signal sits in ensuring. Because onMain checks the anchor in PR mode, a failed record leaves no anchor to find, and the retry plans again from the anchor that branchHead reads. The two new fixtures cover both ways it can fail (the record fails, or the ref is locked), and the direct-push path still fetches before it decides anything. The wrong-folder admittedId case and the K247 renumbering look right too.
Two nits, neither blocking:
- nit: the reorder in
ownerCommit(MemoryWriter.ts, theonMain && mainWrites === "pull_request"branch) applies to every PR-mode owner commit, not only landings. A failedupdate-refis now logged and swallowed for all of them. That's fine, becausebranchHeadcatches up, but the PR body should say this is a general change. - nit: the test name "a commit that only copies a landing's message marks nothing" reads as the opposite of what it asserts (
landedMarksis[agentId]once alex really lands). Something like "…doesn't count as a landing" would be clearer.
In PR mode, the saved-commit branch of onMain can only match when the mark is already set, so it's dead code there now. That's harmless, and it's worth keeping in case the anchor and the mark are ever split apart.
Tech lead, via Kin
|
Ein is commenting on behalf of Nishchay. Rechecked my interrupted PR-mode landing finding at |
People-change: The owner's message about a lead's earlier notes now survives a restart, comes as its own message per lead after quiet hours, never names a file whose name looks like a key, and says "Memory had a different version, so Kin kept it.", "This note was removed from Memory, so Kin left it out.", "It clashes with another note in Memory, so Kin left it out." or "Kin couldn't confirm where it came from, so it left it out."; notes from a member, a group chat or another host, notes at K035's own second, notes citing a chat message said after K035 ran or no longer kept (a cleared chat's included), and quotes no longer land, and nothing lands when Memory's history was replaced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Lane B: both nits are done in
On the ordinary pull-request-mode owner write: 🤖 Generated with Claude Code |
There was a problem hiding this comment.
Re-review of 8e8b6b4..8e1e7a6: the only code change is the test rename at MemoryWriter.test.ts:3573. The fixture body is the same, and the new name matches what it asserts. The PR body now says the pull-request-mode reorder applies to every owner commit, which covers the earlier nit. I didn't run anything, so this review is from the source only. Nothing in this delta blocks.
Tech lead, via Kin
Why
kin/shadow/<agentId>. Nothing lands them, so when it works onmainit starts from an empty index (issue Kin: channel between lane A and lane B (messages both ways) #12).How
MemoryWriter.landShadows, run by the memory sync at start-up and every 5 minutes. For each live lead with an anchored shadow branch and no landing recorded inkin_shadow_landings, it lands the shadow's changed items onmainthrough the owner commit, which rebuilds the index. It leaves out the journal and anything already onmain.kin_sql_migrations.created_atfor migration 35). A shadow with no commit before then lands nothing.merge-baseerror refuses the lead and leaves it unmarked, so a replaced or recoveredmaincan't get notes back it removed on purpose. A note whose id another note would have in the tree that lands stays behind (two would fail every read withMemoryDuplicateId). Ids are counted only for files Memory's reader admits, by its own rule (Memory.admittedId: path, mode, size, UTF-8, lenient parse, kind matching folder), formain's files and for the tree that would land. So an older note with a non-text quote still reserves its id, and a backup likepeople/sam.md.bakreserves nothing. The check repeats whenever holding a note back putsmain's note back at that path.mainalso changed keepsmain's ("Memory had a different version, so Kin kept it."), onemaindeleted stays deleted ("This note was removed from Memory, so Kin left it out."), and notes that don't parse, that Memory's reader gives no id (a person note filed underclaims/, say), that look like a secret, clash, or can't be traced are left out. The shadow branch is not touched.kin_held_postsrow keyed per company and lead, written in the same transaction as the landing mark and the newmainhead, so a restart can't lose it. The existingdeliverHeldposts it as its own message (never grouped with another lead's), after quiet hours, with the stable idkin-held:shadow-landed:<org>:<lead>. Every file name in that message or in the log is secret-scanned first; a flagged one shows as "One note".kin_shadow_landings(migration K247, one row per lead, written only bylandShadows). The commit message carries no marker. Before a landing's commit can reach the default branch's record, Kin saves that exact commit and the held notes with their reasons. The lead counts as landed whenlanded_atis set. That happens in the same transaction as the newmainhead, the end of retired notes' sharing, and the owner's notice.main's SQLite anchor, which the lander andbranchHeadboth read. So the owner commit records the anchor, with any landing mark, before it moves the local ref, and it always signals the lander. A failed record leaves localmainand the anchor where they were, so the retry plans again from a consistentmain. A local ref that fails to move is logged, not failed, for any owner commit, and catches up to the anchor at the next write. The ordinary pull-request write path stays covered byMemoryPullRequests.test.ts(49 passed). A PR closed unmerged leaves the commit on localmain, and the lander offers it again. A memory repo off GitHub now lands on localmain, as other writes there do sincekinmade memory off GitHub stay local.main, fetched first, and Kin decides nothing that round if it can't fetch. If the saved commit is on that record, the lead is marked and the saved notice is sent, with each note's original reason. If it isn't, the landing is planned again. Nothing is inferred from commit messages or the current tree, so a commit that copies a landing's message is just another commit. Retired notes of a landing the remote took end their sharing throughreconcileSharing, which sweepsmainbefore every landing.Tests
vp test run src/kin/memory src/kin/chat/KinRefreshHub.test.ts src/kin/lead/layer.test.ts src/kin/lead/WakeupRunner.test.ts src/kin/persistence/KinMigrations.test.ts src/kin/people/leaver.test.ts src/kin/wireBudget.test.ts src/kin/mcp/layer.test.ts, underTZ=UTCandTZ=Asia/Kolkata: 930 passed, 21 skipped in each, on8e8b6b415b(merged withkinat00ece848e9).mainon its anchor and lands at the next sync with no reset notice. With1e997e8d41's landing code on the merged base it fails, because localmainis left ahead of the anchor. A pull-request landing whose local ref can't move is still recorded on the anchor for the lander, and the ref catches up at the next write. A person note filed underclaims/stays behind as unreadable; without the fix it lands. Off-GitHub pull-request mode now lands on localmain.wireBudget.test.ts,mcp/layer.test.tspass with no edits).vp run check:changed origin/kin --timeout 3600: all pass.node scripts/kin-branch-checks.ts origin/kin: clean.🤖 Generated with Claude Code