samagotchi 0.190.0 → 0.190.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4402302a9a90677b9393d78fae32bb1c8213213a268ce1a3f12c955ef90dc6c
4
- data.tar.gz: 2b8c88cea8b95af6322c909bab6f2f51e9ed7e271074f30982f0fa811583938a
3
+ metadata.gz: 77aeed37eaf5c2f38aa322093568ec409ed14b7da71edd1f07ed84f1b0a5895b
4
+ data.tar.gz: 0c393097b0e2a9a070bec87976e6e1ab34d81e3bb94c93dbf23e415cff348a5e
5
5
  SHA512:
6
- metadata.gz: 85843a002d4fca2b1d2bc05b62e90c21636b948b26e519359b735033f0d0038fb44bb10a67522ffe10391bfde8eacb4a9a73ceee0283ef83b862c5700135f072
7
- data.tar.gz: aac37870c1e2de7a62c8f83a0c8ee81d1c2fd2f710fff9a0f3241c6ae1da8420a3d08d7620d963c3491126f73356c6ef7133d8bc19e79533e2ef6e0335107ffe
6
+ metadata.gz: 26f9472dbc97b6cdda56c4fcac3446275b8f97d8677b2bc6f753f621d590f0ec56057a01dff03ae5472110868369fcb0dd33c285e871b3216424285fa32a8da2
7
+ data.tar.gz: d86525428d4e6a6fcc78cbb08ce6f695766d4b849b7f01fc9b3e9bf33526f29d40a1766bcc2a417ddb7b6622a80255fe234c359f2f2ac189a6f68f9c472d9bd4
data/CHANGELOG.md CHANGED
@@ -8,6 +8,21 @@ and commands may change between minor versions. How releases are made:
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.190.1] - 2026-11-26
12
+
13
+ ### Fixed
14
+
15
+ - known-names no longer blocks a folder or ticket id that differs from a protected name only in its digits
16
+ (`~/projects/ISSUE-8932` while in a repo named `ISSUE-8926`); a letter typo next to the digits is still caught
17
+ (known-names 0.2.2).
18
+ - A pruned schedule's first session keeps working as the chain's address: once `keep_links` pruning had deleted
19
+ the session after it, `chi send <its id>` from another agent was refused as archived, a person's send brought
20
+ that old session back beside the chain, and `last:<its id>` named it instead of the newest link. These now reach
21
+ the schedule's newest link, and continuing that first session directly is refused, naming the newest link.
22
+ - Schedule pruning no longer stops for good after its first deletion; a chain stays at its `keep_links` length.
23
+
24
+ Update with `chi update` (known-names 0.2.2).
25
+
11
26
  ## [0.190.0] - 2026-11-26
12
27
 
13
28
  ### Added
@@ -6951,7 +6966,8 @@ and long-lived sessions.
6951
6966
  - A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
6952
6967
  hotkey panel that send selected text or the clipboard to your sessions.
6953
6968
 
6954
- [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.190.0...HEAD
6969
+ [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.190.1...HEAD
6970
+ [0.190.1]: https://github.com/dm1try/samagotchi/compare/v0.190.0...v0.190.1
6955
6971
  [0.190.0]: https://github.com/dm1try/samagotchi/compare/v0.189.0...v0.190.0
6956
6972
  [0.189.0]: https://github.com/dm1try/samagotchi/compare/v0.188.0...v0.189.0
6957
6973
  [0.188.0]: https://github.com/dm1try/samagotchi/compare/v0.187.0...v0.188.0
data/docs/context.md CHANGED
@@ -334,7 +334,7 @@ link's id (`chi context push` exits 1; chi web answers 410
334
334
  chi context push: 3f2a9c1e was continued as 7b1d…: notes stays with the session it was attached to; attach it to 7b1d… (or pair again with 7b1d…) and push there
335
335
  ```
336
336
 
337
- An archived session that nobody continued takes pushes as before.
337
+ An archived session that nobody continued takes pushes as before; a schedule's anchor whose successor a prune deleted counts as continued by the schedule's head ([sessions.md](sessions.md), *Session chains* → Which link).
338
338
 
339
339
  ### Peers and a continue
340
340
 
data/docs/guardrails.md CHANGED
@@ -1447,7 +1447,11 @@ edit of a known name shorter than 10 characters, or two edits of a longer
1447
1447
  one, is a near miss. Tokens and names shorter than `min_length` (6) are
1448
1448
  skipped, as is a token that equals another known name. A token with a shell
1449
1449
  glob (`*?[]{}`, as in `ls -d samagotchi*`) is not checked. In `~name` (that
1450
- user's home folder) the name after `~` is what is checked.
1450
+ user's home folder) the name after `~` is what is checked. For a name with a
1451
+ digit, a token that differs from it only in digits (`ISSUE-8932` next to a
1452
+ repo named `ISSUE-8926`, `run-3` for `run-2`) is a numbered sibling, not a
1453
+ near miss. A name without digits still catches a digit typo (`j0hndoe` or
1454
+ `johndoe2` for `johndoe`).
1451
1455
 
1452
1456
  By default (`mode: reject`) the call is denied with advice in place of the
1453
1457
  usual tail, so the model retries it corrected:
data/docs/scheduling.md CHANGED
@@ -394,7 +394,13 @@ delegates archived forever with a dangling `parent_id`: archiving a session arch
394
394
  its descendants, and archived sessions are outside the retention sweep
395
395
  ([sessions.md](sessions.md)), so the delegate pile is the bulk of the archived
396
396
  count. The `anchor` is never pruned: it is the chain's root, the id the user and
397
- the coordinator remember, and `last:<anchor>` must keep resolving.
397
+ the coordinator remember, and `last:<anchor>` must keep resolving. Once the
398
+ anchor's successor is gone, nothing continues the anchor; the chain walks for
399
+ `last:`, `chi send` and notes cross that gap to the entry's `head`
400
+ (`SessionChain::Links#anchor_forward`, [sessions.md](sessions.md), *Session chains*
401
+ → Which link), so the anchor stays the chain's address. A link a previous prune
402
+ already deleted is skipped, so each later firing prunes the next link behind the
403
+ window.
398
404
 
399
405
  What a schedule protects (its anchor, its head and its resolved target, while it is
400
406
  enabled) the retention sweep keeps and a delete refuses: schedules are
data/docs/sessions.md CHANGED
@@ -346,7 +346,7 @@ pbpaste | chi send 3fa2 # the clipboard is the messa
346
346
  - Fire and forget: it returns once the message is queued and never prints the answer; that shows in whatever is attached. A guardrail "ask" waits for a UI to answer it, so with nothing attached the turn stalls there until one attaches (`chi --attach ID`).
347
347
  - `--image PATH` (repeatable, up to 20) sends images with the message, as the web composer's chips do. Each file is read once before anything is sent (bmp, tiff and heic converted to png, large ones downscaled, as for `@path`); a missing file or one that isn't an image stops the send (exit 1; with `--wait --format json`, an `error` line) and nothing is sent; more than 20 is a usage error (exit 2). Each session gets its own copy in `<session>/images/`. Text is still required (`-m` or stdin; context alone counts), also with `--wait`. The session's model must see images: one known not to (the host's model list says text-only, `vision: false` in `models:` or `hosts:`, a native llama.cpp without a vision model) is refused before anything is sent, with the reason (`<id> refused: gemma can't take images (…); send text only or switch the model (/model)`); the other sessions of the same send still get it, and the exit is 1. With `--new` nothing is started. When chi can't tell (a native host whose `/props` doesn't answer, a list that doesn't say), the message is sent as before and a text-only model fails the turn in the session. A running turn doesn't take images mid-turn: the message runs as the next turn, and the line says `(runs after the current turn)`. With `--new` the session starts idle with the message as its preview, then the message goes in as its first turn once its worker is up (`<id> started with 1 image`); if the worker doesn't come up in 5 s the session is kept, with its id on the `failed:` line.
348
348
  - A session command runs as the command, as typed in a terminal: `chi send -m "/model qwen" 3fa2` switches the model (`sent as a session command`), and the model never sees the line. What counts is what the session's worker knows (the built-ins, `!cmd`, its bundles' commands); an unknown `/word` (`/usr/bin/env is missing`) goes in as a message. A UI-only command (`/stats`, `/exit`, `/recap`, …) is refused instead: the worker doesn't run it, so the line would reach the model as a prompt (`<id> refused: /stats is a terminal and web command; use chi sessions stats <id8>`; exit 1, and nothing is sent). With `--new` a line starting with `/` or `!` starts the session idle and goes to its worker once it is up, which decides. With `--wait` a command has no reply to wait for: exit 0 at once, `<id> sent as a session command: no reply to wait for …` on stderr (`{"status":"command",…,"detail":…}` with `--format json`); its output shows where the session is open.
349
- - A session that was **continued** (archived, with a later link): the message goes to its chain's newest link, as a note does (*Context notes*), and the old link stays archived. The line names both, in `chi note`'s wording: `3f9a1c2e → 7b2d41aa (continued) sent`. Every id is resolved once, before anything is sent (`SessionAccess#head`, `SessionInbox::Head`'s walk for the `send` row), so the parent-answers check, images, a session command, the UI-only refusal and `--wait` all act on that newest link, and `chi send OLD NEW` sends once. `--wait` waits there: its `--format json` `session_id` is the newest link's, and `asked` the id given (only when they differ). `--wait` without a message follows too, but `--wait --turn T` of the old link (a turn from before the continue) waits on the old one. A link archived and never continued is still brought back by a send. A link being continued right now (its intent written, its new link not saved yet: `SessionContinue`) is asked again for up to 10 s; still not there, it is refused and nothing is written: `3f9a1c2e refused: being continued as 7b2d41aa; send again in a moment`. A continue that ends or starts after that resolve still never gets the old link: chi send's delivery says it follows (`deliver_turn`'s `follow:`, `follow: true` on chi web's turn route for `chi --remote`), and an archived link with a saved successor, or one a continue holds the lock of, refuses it (409 `link_continued`, nothing written; the check and the input go in under a shared hold of that lock, so no continue starts between them); chi send resolves again and sends to the new link (taking back the `--image` copies it made in the old one, on this machine; `chi send OLD NEW` still sends once), for up to 10 s, then `refused: being continued; send again in a moment` (an older chi web ignores the field and sends as before). A chain's first link's id is a stable address for the whole chain. What stays on the id it names: the web composer (typing on an archived link's page brings that link back), a participant's turn (a grant is for one session), `delegate(session:)`, a plugin's turn and a schedule (its own rule, *Schedules*).
349
+ - A session that was **continued** (archived, with a later link): the message goes to its chain's newest link, as a note does (*Context notes*), and the old link stays archived. The line names both, in `chi note`'s wording: `3f9a1c2e → 7b2d41aa (continued) sent`. Every id is resolved once, before anything is sent (`SessionAccess#head`, `SessionInbox::Head`'s walk for the `send` row), so the parent-answers check, images, a session command, the UI-only refusal and `--wait` all act on that newest link, and `chi send OLD NEW` sends once. `--wait` waits there: its `--format json` `session_id` is the newest link's, and `asked` the id given (only when they differ). `--wait` without a message follows too, but `--wait --turn T` of the old link (a turn from before the continue) waits on the old one. A link archived and never continued is still brought back by a send (a schedule's anchor whose successor a prune deleted counts as continued: the send goes to the schedule's head, *Session chains* → Which link). A link being continued right now (its intent written, its new link not saved yet: `SessionContinue`) is asked again for up to 10 s; still not there, it is refused and nothing is written: `3f9a1c2e refused: being continued as 7b2d41aa; send again in a moment`. A continue that ends or starts after that resolve still never gets the old link: chi send's delivery says it follows (`deliver_turn`'s `follow:`, `follow: true` on chi web's turn route for `chi --remote`), and an archived link with a saved successor, or one a continue holds the lock of, refuses it (409 `link_continued`, nothing written; the check and the input go in under a shared hold of that lock, so no continue starts between them); chi send resolves again and sends to the new link (taking back the `--image` copies it made in the old one, on this machine; `chi send OLD NEW` still sends once), for up to 10 s, then `refused: being continued; send again in a moment` (an older chi web ignores the field and sends as before). A chain's first link's id is a stable address for the whole chain. What stays on the id it names: the web composer (typing on an archived link's page brings that link back), a participant's turn (a grant is for one session), `delegate(session:)`, a plugin's turn and a schedule (its own rule, *Schedules*).
350
350
  - One line per session: `sent`, `sent as a session command`, `sent with 2 images`, `sent (goes in at the running turn's next step)`, with `--cut` `sent (cut in now)`, `sent (cuts in once the thinking passes 20 s)` or `sent (cutting is off; goes in at the next step)`, with `--queue` `sent (queued: runs after the current turn)`, `sent (the running turn had ended: it runs now)` or `sent (nothing running: it runs now)`, `sent (started its worker)`, `refused: …` or `failed: …`. Exit 0 when all were sent, 1 when any was refused, failed or not found, 2 for a usage error. There is no `--all`.
351
351
 
352
352
  The Automator action above works for messages too: swap its last line for `pbpaste | "$chi" send -m "what do you make of this?" $(print -r -- "$picked" | cut -f1)`.
@@ -403,11 +403,11 @@ A session can **continue** an earlier one: "the next run of the same routine" (a
403
403
  - **Its open delegates move to the new link** instead: each direct delegate that is running, waiting for an answer, has a live worker or a reply its parent wasn't given, or has such a delegate below it (checked again after the recap wait, so one delegated meanwhile moves too). It moves with its own delegates, stays unarchived, and from then on is the new link's: its card folds under the new link, its reports ring the new link (an idle one runs a wake turn for them, as for its own delegates), `delegate_result` and the `⑂` chip count it there, and what its parent was already told (`delegates.json`) and any report still waiting come along, so nothing is reported twice. A moved delegate gets a context note from `session chain`, `Your parent session is now 4b7e9a01 (…), the next link of its session chain: …`, as its system prompt keeps naming the parent it started with. The move writes `<child>/parent.json` (`{parent_id, from, at}`) beside the child's session file, never the file itself, so a live child worker saving its own copy changes nothing; every reader applies it (a later move overwrites it; it is never removed). A continue is **refused for an open delegate that can't move** (`SessionContinue::Refused`, naming it): one whose live worker runs an older chi (`older chi worker 0.46.1; restart it`: `chi sessions restart <id>`, or stop it) or that a one-turn `chi --non-interactive` run has (`in use by a one-turn chi --non-interactive run or an older chi's terminal; let it finish`). An older `chi web` or CLI still running shows a moved delegate under the archived link until it is restarted.
404
404
  - **What it records:** `<new link>/continued_from.json` (`ContinuedFrom`: `{previous_id, archived_ids, moved_ids}`), written first in the new link's `before_spawn`: the ids its archive hid (the previous link and the delegates archived with it, not ones archived before) and the delegates it moved. Deleting the link reads it to undo the continue. A link from an older chi has none.
405
405
  - **If the continue fails part-way:** what a continue carries (its delegates, attached context, objectives and notes, in that order) and how each is given back is one list, `SessionContinue::CARRY` (the per-session stores it leaves behind, and why, are `SessionContinue::NOT_CARRIED`). A new link that fails to start gives its moved delegates back before it is deleted (each gets a note saying so; its worker is stopped first, if one started, and a worker that won't stop is reported, the link left), with any report one of them rang it with meanwhile, and the notes it moved with any sent to it meanwhile (never the continue's own: the carry note, the attached-context note, the objectives' list): its session file goes first, so a note sent to the previous link from then on stays there, then the notes go back, then its folder goes, and a note an older chi writes into it after that is given back too (a note for a session with no file and no folder is refused, never a stray folder); the previous link, back in the lists, is woken for reports waiting. A continue that dies in the middle leaves a `move.json` in the new link's folder: the new link's next worker finishes that move (only the delegates it names, and without a second note to one already told) as it starts. Its `continue.json` intent remains in the previous link's folder too, so a later list can restore it if the successor was never saved. Until the new link's own worker holds it, a ring from a moved delegate doesn't start another (a `starting` marker in its folder, which that worker removes; a stale one, over 60 s old or from a process that is gone, is ignored). An open delegate below an archived delegate refuses the continue (`under archived …`): unarchive that one, or archive this one.
406
- - **Refused too:** a link that is continued already (naming the link that continues it; continue that one, or `last:<id>`), a previous link whose folder is gone, and one whose model's host can't run it when no default model is configured to fall back to. A refusal starts nothing and archives nothing; a new link that fails to start puts back what was archived. Every refusal that can be known up front (the archive's ones included) comes before the recap wait. One continue of a session runs at a time (a lock in its folder; other chains don't wait), so a double click finds the first one's link and is refused, while a `last:<id>` continue that waited follows the chain to its new end.
406
+ - **Refused too:** a link that is continued already (naming the link that continues it; continue that one, or `last:<id>`; a schedule's anchor whose successor a prune deleted counts as continued by the schedule's head, so no second line starts beside the chain), a previous link whose folder is gone, and one whose model's host can't run it when no default model is configured to fall back to. A refusal starts nothing and archives nothing; a new link that fails to start puts back what was archived. Every refusal that can be known up front (the archive's ones included) comes before the recap wait. One continue of a session runs at a time (a lock in its folder; other chains don't wait), so a double click finds the first one's link and is refused, while a `last:<id>` continue that waited follows the chain to its new end.
407
407
  - **Web:** `POST /api/sessions` takes `continues: "<id, prefix or last:id>"`, with `idle: true` (a new link waiting for its first message, previewed by the previous link's, or `preview`) or a `prompt`, and `model` (or `model_name`) for the new link's model, but not `dir`, `llm_context`, `thinking`, `settings`, `toolkit`, `tools`, `no_tools` or `parent_answers` (400 `invalid_continues`: the previous link's are taken). 201 is the new session's summary, `continues` set, with `moved`: the ids of the delegates that moved to it (`[]` for none), and `model_warning`: the default-model fallback's warning, then any about the model id, joined by `; ` (`null` for none), and `opener`: the previous link's first typed message, in full, when that link continues one itself (`null` otherwise: a chain's first link's first message is its task), and `moved_context`: `{moved: [names], stayed: [{name, why}]}`, the attached context it took (`why` `pushed` or `not movable`); 404 `not_found`; 400 `ambiguous_id` for a prefix of several sessions, `invalid_model` for a given model whose host config.yml doesn't have (or a fallback with no default model); 409 `continued` with `next_id` (the link that continues it already, which the page opens instead), `open_children` with `ids` (open delegates that can't move), `folder_gone`, `busy`, `scratch` or `owned_by_tui`. Every session summary carries `continues`.
408
408
  - **The page:** the info bar's `continue →` continues the open session (`continues: <id>, idle: true`; it reads `continuing…` through the recap wait) and opens the new link with an opener in the composer, not sent (a draft written in this session stays instead; one carried over from another session or the start page gives way to the opener, and the toast's **Restore draft** brings it back): the previous link's own first typed message when that link continues one (the 201's `opener`; a `!shell` line isn't taken), else `Continue where we left off.`. So whatever you sent on the last link comes back on the next one, and editing it once changes it for every later link; the previous link is archived, a toast says so (`Continued 3fa2c1d0 in 4b7e9a01; 3fa2c1d0 is archived; 1 open delegate moved`), and a moved delegate's card folds under the new link. When the previous link's model's host is gone the link starts on the default model and the toast carries the server's `model_warning` too, and then stays until closed. A fresh link (one with no turn yet, however it was made: `continue →`, `chi send --new --continues`, a reload) shows the model picker in its composer with the link's model, until its first turn starts (a failed or canceled first turn ends it too); a pick runs `/model <name>` in the link (a command bubble; the info bar follows) and changes neither the start page's remembered model nor its Recent list, and a Send right after it waits for the `/model` to be taken. A link a one-turn `chi --non-interactive` run has, or one continued already, shows none. A link continued already has no `continue →`: its `→` link goes to the next link (a stale page's continue answered 409 `continued` opens `next_id`). A continue refused for open delegates that can't move shows a toast that names each one (its preview and what the server says to do: `older chi worker 0.46.1; restart it`, `in use by a one-turn chi --non-interactive run or an older chi's terminal; let it finish`), each a link to its page; any other refusal shows the server's words. The info bar of a link carries `← 2026-10-08` (the previous link's day) and, on an earlier link, `2026-10-10 →`, each a link with its id, its full start (`2026-10-10 14:32`) and its preview in the tooltip; a neighbour that started on the open link's own day shows its time instead (`← 09:12`, `14:32 →`). A link made by `continue →` inherits the previous link's preview (and its title, if it has one) when it is created, so its card keeps its chain's title whatever opener it is sent, and its top bar and browser tab show its card's title. A link with a recap of its own reads its auto title, else its recap's first sentence, instead (a link without one reads its chain's name, and a first link's recap names its chain). A link whose title is the opener and nothing else (a `chi send --new --continues` link whose first message is `Continue where we left off.`) shows its chain's first link's title instead, on its card, in the popover and in its info bar's title line, display only (its messages and data keep the opener; its own title when the first link is gone). The lists fold a chain into the card of its latest listed link, whatever the earlier links' archived state (typing in an archived link brings it back, folded there still), their delegates with them: the card's `↩ #N` chip (`#N of M` when later links aren't listed; its tooltip `Session chain: link N of M`) opens a popover of the other links, newest first (`#N`, its date, with its time (`2026-10-17 14:32`) when another link of the chain started the same day, its own title when it differs from the card's (a link inherits its chain's, so mostly it doesn't), else its recap's first sentence, else its preview, `archived`), a click opens one; the chip shows a live dot or `waiting` for a link that has a worker or waits on the user, and a waiting link puts its chain's card first. All sessions folds nothing while a search is typed or the `archived` toggle is on: every link is a card of its own then, its chip `#N of M`, with its own delegates folded in, so a search finds an earlier link and its delegates.
409
409
  - **CLI:** `chi send --new --continues (ID|PREFIX|last:ID) [--model M] [-m TEXT]` (see *Starting a session*).
410
- - **Which link:** an id, a unique prefix, or `last:<id or prefix>`, the latest link of the chain that session is in. It walks the links that still exist: a deleted link in the middle (`chi sessions delete`, the retention sweep of an unarchived one) ends the walk before it, so `last:` of an earlier link then names that earlier link, and continuing it starts a second line beside the links after the gap; name a link after the gap instead. A trigger names the chain this way: a person's message to an archived link that nobody continued brings it back (a human's input), it doesn't continue the chain; an unattended sender's is refused (*Who may wake a session*). That is the rule: `chi send` and a note go to the chain's newest link (*Sending a message*, *Context notes*); the web composer, a participant's turn and `delegate(session:)` go to the link they name. One walker answers every one of these (`SessionChain::Links`: one session listing, archive flags read once; the earliest created successor wins a fork a hand edit made, a loop ends where it would repeat), with two rules on it, not unified on purpose: `last:` and a schedule take the chain's **end** (`Links#latest`: a continue refuses a link continued already, and a schedule never un-archives a chain you retired), `chi send` and a note the **first link not archived** (`Links#first_live`: a person's input goes where the chain is live, and brings back an archived end). A chain pruned by a schedule keeps its `anchor`: the kept window's oldest link still names a link that is gone, so the walk simply stops there; the page's chip counts from the surviving root (pruning renumbers the links) and its popover says `earlier links pruned` where the walk stops, rather than linking to a deleted session.
410
+ - **Which link:** an id, a unique prefix, or `last:<id or prefix>`, the latest link of the chain that session is in. It walks the links that still exist: a deleted link in the middle (`chi sessions delete`, the retention sweep of an unarchived one) ends the walk before it, so `last:` of an earlier link then names that earlier link, and continuing it starts a second line beside the links after the gap; name a link after the gap instead. The one exception is a schedule's anchor (below). A trigger names the chain this way: a person's message to an archived link that nobody continued brings it back (a human's input), it doesn't continue the chain; an unattended sender's is refused (*Who may wake a session*). That is the rule: `chi send` and a note go to the chain's newest link (*Sending a message*, *Context notes*); the web composer, a participant's turn and `delegate(session:)` go to the link they name. One walker answers every one of these (`SessionChain::Links`: one session listing, archive flags read once; the earliest created successor wins a fork a hand edit made, a loop ends where it would repeat), with two rules on it, not unified on purpose: `last:` and a schedule take the chain's **end** (`Links#latest`: a continue refuses a link continued already, and a schedule never un-archives a chain you retired), `chi send` and a note the **first link not archived** (`Links#first_live`: a person's input goes where the chain is live, and brings back an archived end). A chain pruned by a schedule keeps its `anchor`, and the prune deletes the links behind its window, the anchor's successor among them, so nobody continues the anchor any more. The addressing walks bridge that gap: at an archived link nobody continues, `last:`, `chi send`, a note and the peer/context refusals' `next_id` go on at the head of a schedule anchored there (`Links#anchor_forward`; the first entry in `schedules.json` whose head still exists and isn't the anchor, disabled ones too), so `last:<anchor>` names the chain's end and a send to the anchor reaches the live link (`3f9a1c2e → 7b2d41aa (continued)`), as for any continued link; a continue of the anchor itself (without `last:`) is refused as continued already, naming the head. The graph stays raw: `next_of`, the chain's links (`Links#chain`: the anchor alone), the deletes and a delegate's ring never cross the gap. With the head gone (no forward) the walk stops at the anchor, as before; an anchor a person's send brought back before this (no longer archived) isn't bridged either. Backward, the kept window's oldest link still names a link that is gone, so the walk back stops there; the page's chip counts from the surviving root (pruning renumbers the links) and its popover says `earlier links pruned` where the walk stops, rather than linking to a deleted session.
411
411
  - **Deleting a link** (`SessionChain::Delete`; the CLI, the web and `/exit --delete`): a link of a chain is deleted alone by default, and what follows depends on where it is. **The newest link** (nobody continues it, it isn't archived itself, the link before it is archived) undoes its continue: the delegates the continue moved go back to the previous link, finished ones too (`continued_from.json`'s `moved_ids`, still under the link; without the record, its children whose `parent.json` says they came from the previous link), each with a note saying the link was deleted; every note waiting in the link but the continue's own goes back too (`NoteMove.give_back`); then the previous link and what the continue archived with it come back to the lists (without the record, the previous link alone). The previous link is **not started**: reports a moved-back delegate left wait for its next start. What dies with the link: its turns, context sources, objectives edits, session approvals and participant grants (the previous link kept its own copies). Every refusal comes before anything goes: the link's delegates that would go are checked too (a schedule on one through `SessionProtection.hold`, a one-turn run), and they and the link are removed (and the undo runs) only under their `owner.lock`s (kind deleting, taken without waiting, so a worker that took one refuses it); a moved delegate that can't go back (`ChildMove.unmovable`: an older chi's worker, a one-turn run) refuses it (`delegate_unmovable`, naming it), as does a worker that took the link after the stop. Deleting the links one after another undoes each continue by its own record. **A middle link** splits the chain (the earlier links stay archived, the later ones go on as their own chain); nothing is undone or re-linked. A link whose chain is all archived stays archived around the gap. **The link's own delegates** (any position) follow one rule, `SessionManager::DELEGATES` (`SessionManager::DelegateRule`; one shared preview row snapshot): a running one (a worker owns it or is starting for it, a one-turn run; a saved `running` with no worker is a crashed run, and goes) is left running with its whole subtree, its file untouched (its parent's id names a deleted session; its reports are refused as for any gone parent); every other node under the link goes, deepest first, before the link. A session in no chain (a link alone past a gap too) is a link with nothing to undo: its delegates follow the same rule (*Deleting a session*). **The web asks first**: chi web's delete sheet reads `GET /api/sessions/:id/delete_plan` (`:owner`; no query or body; no-store) for any session, `SessionChain::Delete::Preview` over the same `LinkPlan`/`ChainPlan` and checks the delete runs (`check_link!`, `check_chain!`): the link's place in the chain, what comes back and goes for each choice, and each choice's refusal now (a schedule on the chain, the link or a delegate that would go, a continue under way, a one-turn run, a moved delegate that can't go back and whether the page can stop it). A session in no chain answers `{chained: false, session_id, link}`, the same `link` a chained one gets (`previous_id` null, `earlier`/`later` 0, `next_id` null); an older page reads only `chained`. Each choice (`link`, `chain`) also carries `delegates` (`{delete: [ids], leave: [{id, running}]}`; `running` false for a stopped session left under a running delegate, beside the counts `deletes` and `left_running`), `tasks` (`{running, unverified, unreadable}`: `RunningTasks.of` the ids the choice deletes) and `worker` (a link's: `"turn"` when a worker owns it and a turn runs, `"idle"` when a worker owns it or is starting, null; a chain's `{idle, turn}` counts over its links). No titles: the page names each id from its own list. One shared session-row snapshot serves the link and chain choices; Links lists on its own, and a folder whose session file is gone answers too (the delete still takes it). Each call read-only checks each link's continue lock (a session in no chain too), and writes nothing else but the listing's own repair of an interrupted continue; an unknown id is the usual 404. chi web lists `delete_plan_all` in `/api/info`'s features (`Web::App::DELETE_PLAN_FEATURE`). **The tap stops only what the sheet named**: whenever the choice lists any task, the page sends `stop_tasks=true&tasks=<id,id>`, the choice's running ids (`tasks=` when it has only unverified or unreadable records, which a stop never signals, so such a session can still be deleted); archive's sheet sends `{"stop_tasks": true, "tasks": [ids]}` in its body. `tasks` works only with `stop_tasks`; without it, it is ignored, and `stop_tasks` without `tasks` (the CLI's `--stop-tasks`, an older page) takes every running task the operation can stop. A running task not named refuses (`tasks_running`), and the sheet reads the plan again and shows it with "changed; check again". A chain stops link by link: a link refused that way leaves it and the earlier links whole. The moved count is each moved delegate with its subtree (they come back with it), and a `delegate_unmovable` 409 says `stoppable` itself. Each choice carries a `digest` (`SessionChain::Delete.digest`: the sorted ids it deletes, leaves, revives and moves back); the sheet's DELETE sends it as `expect=`, and the delete compares it with the plan it runs (a link's under its holds, as `delete_link` starts; the chain's before its checks) and refuses `plan_changed` (409) before anything changes; a session in no chain is compared the same way (a sheet shown for a link whose chain is gone since deletes when its ids still match). Without `expect` (the CLI, an older page) it deletes as it plans then.
412
412
  **The whole chain** (`chi sessions delete --chain`, `DELETE /api/sessions/:id/chain`, `SessionManager.delete_chain`): every link reachable from this one on its branch, newest first, each with its delegates by the same rule. Refused before anything goes when a schedule is on the chain (`chain_scheduled`, `SessionProtection.chain_hold`) or on a delegate that would go (`scheduled`), a link or such a delegate is in a one-turn run, a continue of a link is under way (`continuing`), without `force` a link has a worker, or a link's worker outlives the stop's wait: every link is checked and stopped before the first is deleted, and each then goes under the owner locks of it and its delegates. A chain with a gap before this link reaches only the part after the gap: the earlier links stay archived (`cut_off: true`). A link refused part-way (a worker that took it after its stop) leaves it, its delegates and the earlier part of the chain whole, its new end back in the lists, and the result lists what was left.
413
413
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: known-names
3
- version: 0.2.1
3
+ version: 0.2.2
4
4
  requires_chi: ">= 0.150.0"
5
5
  scope: system
6
6
  description: Catches a near-miss of a protected name (home folder, login, git name, repo name, names from config) in a tool call and rejects it with the right spelling; mode ask / correct optional
@@ -9,6 +9,6 @@ files:
9
9
  known_names.md: sha256:d5348b95b6c655017b541910b36e384220da280818160201f6ec9a50e1e4287c
10
10
  plugin:
11
11
  file: plugin.rb
12
- sha256: sha256:f519ec42023a6857f87fba9ff8a8db5d261dccfd88e3a9b58310ae3293b3cbdc
12
+ sha256: sha256:ba70badd722f108d6e4dbd577cb436b6662e2ae2281c2832f08c220cba4f99fb
13
13
  # config.yml bundles: known-names: (another key warns; an older chi ignores this)
14
14
  settings: [names, ignore, mode, derive, min_length, max_distance]
@@ -9,7 +9,9 @@ require "samagotchi/git_env"
9
9
  # a rejection that names the right one breaks the loop.
10
10
  #
11
11
  # A token with a shell glob (*?[]{}) is not checked. In "~name" the name
12
- # after "~" is checked.
12
+ # after "~" is checked. For a name with a digit, a token that differs from
13
+ # it only in digits (ISSUE-8932 for ISSUE-8926, run-3 for run-2) is not a
14
+ # near miss: numbered siblings, not a misspelling.
13
15
  #
14
16
  # Settings (config.yml, `bundles: known-names:`), all optional:
15
17
  # names: [jonathandoe] names to protect besides the derived ones
@@ -112,6 +114,7 @@ class KnownNames
112
114
 
113
115
  max = @max_distance || (name.length < 10 ? 1 : 2)
114
116
  bare = name_down.gsub(EDGE_SEPARATORS, "")
117
+ next if digits_only?(down, bare)
115
118
  next if (candidate.length - bare.length).abs > max
116
119
 
117
120
  d = self.class.distance(down, bare)
@@ -134,6 +137,19 @@ class KnownNames
134
137
  [upper, upper[0].downcase + upper[1..]].include?(candidate)
135
138
  end
136
139
 
140
+ # "ISSUE-8932" for "ISSUE-8926", "run-3" for "run-2": numbered siblings
141
+ # (tickets, worktrees, versions) aren't misspellings, so a token whose
142
+ # non-digit characters are the name's, in order, passes whatever its
143
+ # digits. Only for a name with a digit: for "johndoe", "johndoe2" (an
144
+ # added digit) is still a near miss. A digit in place of a letter
145
+ # ("j0hndoe") never matches here: its letters differ. Both come in
146
+ # downcased, without edge separators.
147
+ def digits_only?(down, name_down)
148
+ return false unless name_down.match?(/\d/)
149
+
150
+ down.delete("0-9") == name_down.delete("0-9")
151
+ end
152
+
137
153
  # [where, text] pairs to scan: the command, the cwd a command names,
138
154
  # each path, and a write/edit call's own path (in case normalisation
139
155
  # dropped it). Not file contents.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: samagotchi-system
3
- version: 0.190.0
3
+ version: 0.190.1
4
4
  scope: system
5
5
  description: Default system memories — identity, self map, config modification protocol, memory guide and the delegated-session rules
6
6
  files:
@@ -19,8 +19,12 @@ module Samagotchi
19
19
  # (deepest first) and the link last. The walk stops at a link that is not
20
20
  # archived, one whose subtree has a live worker, or one with a descendant
21
21
  # still unarchived: nothing is deleted in that case, and the next firing
22
- # retries (a schedule failure it is not). The anchor is never pruned:
23
- # `last:<anchor>` must keep resolving, and it is the id the user remembers.
22
+ # retries (a schedule failure it is not). A link already gone (the one
23
+ # an earlier prune deleted: the walk back from the head ends on its id)
24
+ # is skipped, not a stop, or every prune after the first would stall
25
+ # there. The anchor is never pruned: `last:<anchor>` must keep resolving
26
+ # (SessionChain::Links forwards it over the gap to the head), and it is
27
+ # the id the user remembers.
24
28
  def prune(entry, links)
25
29
  chain = []
26
30
  id = entry.head
@@ -43,6 +47,7 @@ module Samagotchi
43
47
 
44
48
  older.reverse_each do |link|
45
49
  next if link == entry.anchor
50
+ next if link_gone?(link)
46
51
  break unless ArchiveStore.archived?(Session.session_dir(link, state_dir: @state_dir))
47
52
 
48
53
  tree = SessionManager.delete_tree_ids(link, @state_dir)
@@ -74,6 +79,12 @@ module Samagotchi
74
79
  rescue Session::NotFound => e
75
80
  Log.warn(:worker, "prune_missing", id: entry.id, msg: e.message)
76
81
  end
82
+
83
+ # Neither a session file nor a folder: nothing left to delete.
84
+ def link_gone?(link)
85
+ !File.exist?(Session.session_file(link, state_dir: @state_dir)) &&
86
+ !File.directory?(Session.session_dir(link, state_dir: @state_dir))
87
+ end
77
88
  end
78
89
  end
79
90
  end
@@ -256,6 +256,17 @@ module Samagotchi
256
256
  ambiguous(list.select { |entry| entry.title.to_s.casecmp?(given) }, given).first
257
257
  end
258
258
 
259
+ # anchor → the heads of the schedules anchored there, in the file's order,
260
+ # disabled and fired one-offs too (SessionChain::Links' walk over a pruned
261
+ # anchor's gap: a paused schedule's chain is still one chain). Lenient and
262
+ # quiet: a file that doesn't read forwards nothing.
263
+ # @return [Hash{String => Array<String>}]
264
+ def anchor_heads
265
+ read(quiet: true).entries.grep(Entry).each_with_object({}) do |entry, heads|
266
+ (heads[entry.anchor] ||= []) << entry.head
267
+ end
268
+ end
269
+
259
270
  # One match is the answer; several are a usage error naming them, the way
260
271
  # Session::AmbiguousId does for session prefixes.
261
272
  def ambiguous(entries, given)
@@ -751,13 +751,15 @@ module Samagotchi
751
751
 
752
752
  def dir = @state_dir ? { state_dir: @state_dir } : {}
753
753
 
754
- # The session that continues +id+, or nil. The archive check first: a
755
- # continued link is always archived, and SessionChain.next_of loads
756
- # every session.
754
+ # The session that continues +id+, or nil; for a schedule's pruned
755
+ # anchor, the schedule's head (SessionChain::Links#anchor_forward). The
756
+ # archive check first: a continued link is always archived, and the
757
+ # walk loads every session.
757
758
  def continued_as(id)
758
759
  return nil unless ArchiveStore.archived?(session_dir(id))
759
760
 
760
- SessionChain.next_of(id, state_dir: state_dir!)
761
+ links = SessionChain::Links.new(state_dir: state_dir!)
762
+ links.next_of(id) || links.anchor_forward(id)
761
763
  end
762
764
 
763
765
  def state_dir! = @state_dir || Session.default_state_dir
@@ -15,7 +15,7 @@ module Samagotchi
15
15
  # a walk that comes back to a link it passed (a loop a hand-edited file
16
16
  # could make) ends where it would repeat. A walk stops where no listed
17
17
  # session continues the link: past a deleted middle link nothing is
18
- # reached.
18
+ # reached, with one exception, the pruned anchor (below).
19
19
  #
20
20
  # The walks, and who uses which (not unified on purpose: a schedule
21
21
  # firing must continue the chain's end, SessionContinue refuses a link
@@ -23,19 +23,36 @@ module Samagotchi
23
23
  # live, and a send un-archives an archived end, a schedule never does):
24
24
  # - #latest: the chain's end (SessionChain.latest, `last:<id>`, Schedules)
25
25
  # - #first_live: the first link not archived, or the end (Head: send, note)
26
+ # - #anchor_forward: one hop over a pruned anchor's gap (continued_as)
26
27
  # - #root: back to the first link (Schedules' one firing per chain)
27
28
  # - #chain / #live_links: every link of +id+'s branch, root to end
28
29
  # (Schedules#chain_of, the chain delete)
29
30
  #
31
+ # A pruned anchor: a schedule's prune keeps its anchor but deletes the
32
+ # links behind its window, the anchor's successor too, so nobody
33
+ # continues the anchor any more. The addressing walks (#latest,
34
+ # #first_live, #anchor_forward) bridge that gap: at an archived link
35
+ # nobody continues, they go on at the head of a schedule anchored there
36
+ # (#anchor_head), so the anchor stays the chain's address. The graph
37
+ # walks (#next_of, #chain, #live_links, #root) stay raw: their callers
38
+ # delete, move delegates back or plan deletes from the answer, and must
39
+ # never reach the schedule's head through it.
40
+ #
30
41
  # The listing is a snapshot: one Links per question, or per tick.
31
42
  class Links
32
43
  attr_reader :state_dir
33
44
 
34
- def initialize(state_dir:)
45
+ # @param anchor_heads [Hash{String => Array<String>}, nil] anchor →
46
+ # the heads of the schedules on it (Schedules#anchor_heads); nil reads
47
+ # them from the schedules file the first time a walk dead-ends at an
48
+ # archived link
49
+ def initialize(state_dir:, anchor_heads: nil)
35
50
  @state_dir = state_dir
36
51
  @by_id = nil
37
52
  @nexts = nil
38
53
  @archived = {}
54
+ @anchor_heads = anchor_heads
55
+ @anchor_head = {}
39
56
  end
40
57
 
41
58
  # The listed session +id+ (a Session summary), or nil.
@@ -61,15 +78,27 @@ module Samagotchi
61
78
  def next_of(id) = nexts[id]
62
79
 
63
80
  # The chain's end from +id+ on: +id+ itself when nobody continues it.
64
- def latest(id) = walk(id).last
81
+ # Over a pruned anchor's gap too (#anchor_head).
82
+ def latest(id) = walk(id, forward: true).last
65
83
 
66
84
  # From +id+ forward over archived links: +id+ when it is not archived,
67
- # else the first link after it that is not, or the chain's end. Only an
68
- # archived +id+ makes the listing.
85
+ # else the first link after it that is not, or the chain's end (over a
86
+ # pruned anchor's gap too). Only an archived +id+ makes the listing.
69
87
  def first_live(id)
70
88
  return id unless archived?(id)
71
89
 
72
- walk(id) { |link| !archived?(link) }.last
90
+ walk(id, forward: true) { |link| !archived?(link) }.last
91
+ end
92
+
93
+ # The link after a pruned anchor's gap: the head of a schedule anchored
94
+ # at +id+ when +id+ is archived and nobody continues it, else nil. One
95
+ # hop, as #next_of (SessionAccess::Local#continued_as, SessionContinue's
96
+ # check).
97
+ # @return [String, nil]
98
+ def anchor_forward(id)
99
+ return nil if !archived?(id) || nexts[id]
100
+
101
+ anchor_head(id)
73
102
  end
74
103
 
75
104
  # The chain's first link: back through `continues` to a link with no
@@ -90,7 +119,7 @@ module Samagotchi
90
119
  # it would repeat.
91
120
  # @return [Array<String>]
92
121
  def chain(id)
93
- ids = [latest(id)]
122
+ ids = [walk(id).last]
94
123
  while (previous = continues(ids.last)) && !ids.include?(previous)
95
124
  ids << previous
96
125
  end
@@ -106,15 +135,45 @@ module Samagotchi
106
135
 
107
136
  # +id+ and the links after it, in order, until none follows, a link
108
137
  # would repeat, or the block says stop at the one just reached.
109
- def walk(id)
138
+ # +forward+ crosses a pruned anchor's gap (#anchor_head).
139
+ def walk(id, forward: false)
110
140
  seen = [id]
111
- while (following = nexts[seen.last]) && !seen.include?(following)
141
+ while (following = step(seen.last, forward)) && !seen.include?(following)
112
142
  seen << following
113
143
  break if block_given? && yield(following)
114
144
  end
115
145
  seen
116
146
  end
117
147
 
148
+ # The link after +link+: its successor; with +forward+, at an archived
149
+ # link nobody continues, a schedule's head anchored there.
150
+ def step(link, forward)
151
+ nexts[link] || (forward && archived?(link) && anchor_head(link)) || nil
152
+ end
153
+
154
+ # The head of a schedule anchored at +link+ that is still listed and
155
+ # isn't +link+ itself: the first such of the entries on it, in the
156
+ # schedules file's order (disabled ones too: a paused schedule's chain
157
+ # is still one chain). nil without one, so a gone head (the same
158
+ # fallback as Schedules#target_of) or a schedule that never fired
159
+ # forwards nothing. Kept per link.
160
+ def anchor_head(link)
161
+ return @anchor_head[link] if @anchor_head.key?(link)
162
+
163
+ @anchor_head[link] = Array(anchor_heads[link]).find { |head| head != link && !gone?(head) }
164
+ end
165
+
166
+ # The schedules file read once, at the first gap: a normal walk never
167
+ # reaches it. Schedules sits above this file (schedules.rb requires
168
+ # session_chain), hence the deferred require, as
169
+ # SessionProtection.schedule_protector does.
170
+ def anchor_heads
171
+ @anchor_heads ||= begin
172
+ require_relative "../schedules"
173
+ Schedules.new(state_dir: @state_dir).anchor_heads
174
+ end
175
+ end
176
+
118
177
  def by_id
119
178
  @by_id ||= Session.list(state_dir: @state_dir, sort: "created_at", order: "asc", include_archived: true)
120
179
  .to_h { |session| [session.id, session] }
@@ -31,7 +31,8 @@ module Samagotchi
31
31
  # SessionManager's.
32
32
  module SessionContinue
33
33
  # A continue that can't happen (#run). reason: :continued
34
- # (another session continues it already: +ids+ names it), :open_children
34
+ # (another session continues it already, or a schedule's pruned
35
+ # anchor: +ids+ names the successor, or the schedule's head), :open_children
35
36
  # (open children it can't move to the new link: on an older chi's
36
37
  # worker or open in a one-turn chi run; +ids+ names them) or :folder_gone (its
37
38
  # folder isn't there).
@@ -538,7 +539,11 @@ module Samagotchi
538
539
  # @return [Checked]
539
540
  # @raise [Refused, ModelProfile::MissingModel]
540
541
  private_class_method def self.check!(previous, state_dir, model: nil)
541
- if (following = SessionChain.next_of(previous.id, state_dir: state_dir))
542
+ # A schedule's pruned anchor counts as continued, by the schedule's
543
+ # head (Links#anchor_forward): continuing it would start a second
544
+ # line beside the chain.
545
+ links = SessionChain::Links.new(state_dir: state_dir)
546
+ if (following = links.next_of(previous.id) || links.anchor_forward(previous.id))
542
547
  raise Refused.new(previous.id, :continued, ids: [following])
543
548
  end
544
549
 
@@ -190,7 +190,8 @@ module Samagotchi
190
190
 
191
191
  # +id+ for a pinned kind, or for an id not archived (the cheap check
192
192
  # first: only an archived id is walked, with one Session.list).
193
- # Else the walk forward over archived links that have a successor:
193
+ # Else the walk forward over archived links that have a successor (a
194
+ # schedule's pruned anchor: its head, Links#anchor_forward):
194
195
  # to the first link not archived, or the last (a loop a hand-edited
195
196
  # file could make ends where it started); a :reader kind goes one hop
196
197
  # at most. Then, for a kind that would un-archive the link it reaches
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Samagotchi
4
- VERSION = "0.190.0"
4
+ VERSION = "0.190.1"
5
5
  # Sent as the User-Agent of every HTTP request chi makes.
6
6
  USER_AGENT = "chi/#{VERSION}"
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samagotchi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.190.0
4
+ version: 0.190.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Dedov