Hermes 1.4 fourth review: updated_at required with checklist item numbers (400 if missing or malformed), README retry wording, duplicate-text test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin BurchellandClaude Opus 5.5 committed 2026-10-07 12:15:07 -07:00
1 parent 8509611f7e
commit b86de1497b
4 files changed
+25 -10

No files matched your search

+1 -1
View File
@@ -112,7 +112,7 @@ The helper prints them as `BrainFeed API error <status> (<code>): <message>`.
| `POST /v1/notes/search` | `q?` (words AND-ed, `#tag` filters), `tags?[]`, `pinned?`, `limit?` ≤50, `before?` (a `created_at` from a result, used exactly), `before_id?` (that note's `id`: with `before`, continues after it, ties broken by id), `archived?` (true = only archived, false = none; omitted = both), `parent_id?` (notes inside that note) | `notes[]` newest first (then by id) |
| `POST /v1/notes/get` | `id` | `note`, `parent` (`id`, `first_line`) or null, `children[]` (`id`, `first_line`, `archived`, `created_at`; newest first, then by id, at most 100), `children_truncated` (true when there are more: continue with `notes/search` + `parent_id` + `before`/`before_id` of the last child), `checklist[]` (`n`, `done`, `text`) |
| `POST /v1/notes/update` | `id`, `body?`, `add_tags?[]`, `remove_tags?[]`, `pinned?`, `archived?` (true hides from the feed, false restores), `parent_id?` (note id = move inside, null = take out) | `note` (hashtags re-derived from a new body; manual tags kept). Atomic via `bf_update_note` |
| `POST /v1/notes/check` | `id`, `check?[]` / `uncheck?[]` (item numbers, or item text: an exact case-insensitive match, else text found in exactly one item), `add?[]` (new items, after the last item, or a new list at the end), `updated_at?` (the note's `updated_at` from the `get_note` the numbers came from, verbatim; if the note changed since, 409 `conflict` and nothing changes) | `note`, `checked`, `unchecked`, `added`, `checklist[]`, `message` ("3/5 done"). Errors `no_match` / `ambiguous` (400). Written only if the note is unchanged since it was read, so concurrent ticks never overwrite each other. If the note changed in between: a request that picks **any item by number** is never retried (numbers have no stable meaning once lines move, and identical lines can swap) and answers 409 `conflict` with nothing changed; a request that picks only by text is matched again by text and retried (up to 4 tries, then 409) |
| `POST /v1/notes/check` | `id`, `check?[]` / `uncheck?[]` (item numbers, or item text: an exact case-insensitive match, else text found in exactly one item), `add?[]` (new items, after the last item, or a new list at the end), `updated_at` (**required whenever any item number is used**, optional for text-only and add-only requests: the note's `updated_at` from the `get_note` the numbers came from, verbatim. Missing with a number → 400; malformed → 400; stale → 409 `conflict` and nothing changes) | `note`, `checked`, `unchecked`, `added`, `checklist[]`, `message` ("3/5 done"). Errors `no_match` / `ambiguous` (400). Written only if the note is unchanged since it was read, so concurrent ticks never overwrite each other. If the note changed in between: a request that picks **any item by number** is never retried (numbers have no stable meaning once lines move, and identical lines can swap) and answers 409 `conflict` with nothing changed; a text-only request **without** `updated_at` is matched again by text and retried (up to 4 tries, then 409); with `updated_at`, any change since that read is an immediate 409 |
| `POST /v1/tags` | `limit?` ≤500 | `tags[]` (`tag`, `count`), non-archived notes, most-used first |
| `POST /v1/notes/append` | `id`, `body` | `note` with `\n\n— Oct 4, 8:30 PM\n<body>` added (stamp in the user's zone, built server-side). A single database UPDATE (`bf_append_note`), so concurrent appends never overwrite each other |
| `POST /v1/calendar` | `from_local?` (`YYYY-MM-DD`, default today), `days?` 1–31 (default 7) | `overdue_before[]` (open reminders due before the range) and `days[]`: `date`, `weekday`, `reminders[]` (`time_local`, `repeat`, `status`: scheduled / overdue / repeat / done) and `notes[]` (non-archived, `first_line`). Repeats expanded with the same wall-clock, anchored, month-end-clamped rules as delivery |
+1 -1
View File
@@ -56,7 +56,7 @@ file name.
| `search_notes` | `q` (words AND-ed; `#tag` filters), `tags`, `pinned`, `limit` (≤50), `before` + `before_id` (for the next page: the last result's `created_at` and `id`), `archived` (`false` = leave archived out, `true` = only archived; omit for both), `parent_id` (list the notes inside that note) |
| `get_note` | `id`. Also returns `parent` (the note it sits in), `children` (notes inside it, newest first, up to 100; `children_truncated: true` means there are more: get them with `search_notes` + `parent_id`, with `before`/`before_id` set to the last child's `created_at`/`id`) and `checklist` (numbered items with `done`) |
| `edit_note` | `id`, and any of `body`, `add_tags`, `remove_tags`, `pinned`, `archived` (true hides it from the feed and calendar; false brings it back), `parent_id` (a note id moves it inside that note; `null` takes it back out). Archived notes still appear in `search_notes` results, with `archived_at` set |
| `check_items` | `id`, and any of `check` / `uncheck` (lists of item numbers from `get_note`'s `checklist`, or item text), `add` (list of new item texts, added after the last item), `updated_at` (**always** send it when you use item numbers: the note's `updated_at` from that `get_note`, copied exactly). Returns the updated `checklist` and a `message` like "3/5 done" |
| `check_items` | `id`, and any of `check` / `uncheck` (lists of item numbers from `get_note`'s `checklist`, or item text), `add` (list of new item texts, added after the last item), `updated_at` (**required** when you use item numbers, or the call is refused: the note's `updated_at` from that `get_note`, copied exactly). Returns the updated `checklist` and a `message` like "3/5 done" |
| `list_tags` | `limit` (optional): Kevin's tags with how many notes use each, most-used first |
| `append_note` | `id`, `body`: adds a time-stamped entry ("— Oct 4, 8:30 PM") to the end of an existing note |
| `calendar` | `from_local` (`"YYYY-MM-DD"`, default today), `days` (1–31, default 7): each day's reminders (with repeats worked out, `status` scheduled/overdue/repeat/done) and non-archived notes created that day, plus `overdue_before`: open reminders that were due before `from_local` |
+15 -3
View File
@@ -556,7 +556,8 @@ class Skill14(unittest.TestCase):
def test_check_items(self):
n = j("add", "# Groceries\n- [ ] Milk\n- [ ] eggs\n- [x] Bread\n- [ ] oat milk\nnotes after")["note"]
out = self.call({"op": "check_items", "id": n["id"], "check": ["eggs"], "uncheck": [3], "add": ["Coffee"]})
ts = lambda: self.call({"op": "get_note", "id": n["id"]})["note"]["updated_at"]
out = self.call({"op": "check_items", "id": n["id"], "check": ["eggs"], "uncheck": [3], "add": ["Coffee"], "updated_at": ts()})
self.assertEqual([(x["text"], x["done"]) for x in out["checklist"]],
[("Milk", False), ("eggs", True), ("Bread", False), ("oat milk", False), ("Coffee", False)])
self.assertTrue(out["note"]["body"].endswith("- [ ] Coffee\nnotes after"))
@@ -565,9 +566,14 @@ class Skill14(unittest.TestCase):
self.assertEqual(self.call({"op": "check_items", "id": n["id"], "check": ["milk"]})["checked"], ["Milk"])
self.assertIn("ambiguous", self.call({"op": "check_items", "id": n["id"], "check": ["mil"]}, check=False).stderr)
self.assertIn("no_match", self.call({"op": "check_items", "id": n["id"], "check": ["kale"]}, check=False).stderr)
self.assertIn("no item 9", self.call({"op": "check_items", "id": n["id"], "check": [9]}, check=False).stderr)
self.assertIn("no item 9", self.call({"op": "check_items", "id": n["id"], "check": [9], "updated_at": ts()}, check=False).stderr)
# numbers need updated_at; malformed timestamps are a 400, not a 409
self.assertIn("updated_at is required", self.call({"op": "check_items", "id": n["id"], "uncheck": [1]}, check=False).stderr)
self.assertIn("400", self.call({"op": "check_items", "id": n["id"], "check": [1], "updated_at": "banana"}, check=False).stderr)
# text-only and add-only requests don't need it
self.call({"op": "check_items", "id": n["id"], "add": ["Tea"]})
got = self.call({"op": "get_note", "id": n["id"]})
self.assertEqual([x["n"] for x in got["checklist"]], [1, 2, 3, 4, 5])
self.assertEqual([x["n"] for x in got["checklist"]], [1, 2, 3, 4, 5, 6]) # "Tea" was added above
self.assertIn("404", self.call({"op": "check_items", "id": NOTE_B, "add": ["x"]}, check=False).stderr)
def test_check_items_stale_numbers_refused(self):
@@ -584,6 +590,12 @@ class Skill14(unittest.TestCase):
self.assertEqual([x["done"] for x in out["checklist"]], [False, False, False])
self.assertIn("400", self.call({"op": "check_items", "id": n["id"], "check": [1], "updated_at": 5}, check=False).stderr)
def test_exact_duplicate_text_is_ambiguous(self):
n = j("add", "- [ ] eggs\n- [ ] eggs\n- [ ] Eggs\n- [ ] milk")["note"]
p = self.call({"op": "check_items", "id": n["id"], "check": ["eggs"]}, check=False)
self.assertIn("(ambiguous)", p.stderr)
self.assertEqual(j("get", n["id"])["note"]["body"], "- [ ] eggs\n- [ ] eggs\n- [ ] Eggs\n- [ ] milk")
def test_check_items_starts_a_list(self):
n = j("add", "Packing for the trip")["note"]
out = self.call({"op": "check_items", "id": n["id"], "add": ["charger", "socks"]})
+8 -5
View File
@@ -1,4 +1,4 @@
// BrainFeed agent API (v1, revision 9).
// BrainFeed agent API (v1, revision 10).
//
// A deliberately small, fixed set of operations for an agent like Hermes
// or an iPhone Shortcut: add / search / edit notes (incl. nesting and
@@ -457,10 +457,12 @@ const routes: Record<string, Handler> = {
'POST /v1/notes/check': async (c, b) => {
only(b, ['id', 'check', 'uncheck', 'add', 'updated_at']);
const id = uuid(b.id);
// updated_at (optional): the note's updated_at, verbatim, from the get_note the item
// numbers came from. Compared as the exact string (microseconds included): if the note
// has changed since, nothing is changed (409).
if (b.updated_at !== undefined && (typeof b.updated_at !== 'string' || b.updated_at.length > 40)) {
// updated_at: the note's updated_at, verbatim, from the get_note the item numbers came
// from. Required whenever an item number is used (a number only means something for the
// version it was read from); optional for text-only and add-only requests. Compared as the
// exact string (microseconds included): if the note has changed since, 409, nothing changes.
if (b.updated_at !== undefined && (typeof b.updated_at !== 'string'
|| !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,6})?(Z|[+-]\d{2}:?\d{2})$/.test(b.updated_at))) {
throw bad('updated_at must be the updated_at string from get_note, unchanged');
}
const list = (v: unknown, field: string) => {
@@ -476,6 +478,7 @@ const routes: Record<string, Handler> = {
// note changes (lines can move, and identical lines can swap places), so a request with
// any number is never retried: it answers 409 and changes nothing.
const numeric = [...check, ...uncheck].some((x) => Number.isInteger(x));
if (numeric && b.updated_at === undefined) throw bad('updated_at is required when using checklist item numbers');
for (let attempt = 0; attempt < 4; attempt++) {
const { data: cur, error: readErr } = await db.from('notes').select('body,updated_at').eq('user_id', c.userId).eq('id', id).maybeSingle();
if (readErr) throw new ApiError(500, 'db_error', 'Could not read note');