Answer Fable's review of 95f7ad2: pin every guard its mutations got past
Gate 4 drives /suggest (and its failure path), /documents, / and a document page. /documents is in both Unknown-list team tests; /suggest in the retryable-503 list; a labelled document makes a Try chip to withhold. TestTheTypeaheadNeverGuessesOrCallsTheModel puts both typeahead rules in make ci. Delete only on memoria's own rows; VisibleDocuments' no-asker refusal called directly; under Unknown no list asks an app of record. All ten survivors (M01, M03, M04, M09, M13, M14, M17, M19, M20, M21) re-run and red. Spec §8.14 records gate 4's reach and the CURSOR_RESET handling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 files changed,
+139
−3
docs/superpowers/specs/2026-09-03-memoria-design.md+13 −0internal/memoria/team_access_test.go+16 −3internal/memoria/team_survivors_test.go+27 −0internal/memoria/visible_test.go+23 −0internal/memoriatest/gates_test.go+15 −0internal/memoriatest/suggest_test.go+45 −0
CI passed — run details
diff --git a/docs/superpowers/specs/2026-09-03-memoria-design.md b/docs/superpowers/specs/2026-09-03-memoria-design.md| index 12d7f12..e3f59e4 100644 |
| --- a/docs/superpowers/specs/2026-09-03-memoria-design.md |
| +++ b/docs/superpowers/specs/2026-09-03-memoria-design.md |
| @@ -4696,6 +4696,19 @@ is a list route — `teamReaches` before it lists, `teamPartial` after, |
| the partial notice when standing is Unknown — and `/suggest` needs |
| Member and answers 204 if standing lapsed while it searched. The front |
| page's lists are inside the index's own pair and `withhold` clears them. |
| +Gate 4 (no content or query in logs) drives `/suggest`, `/documents`, `/` |
| +and a document page as well as search (Fable's review of the merge, |
| +2026-11-02, found a query logged in `suggest()` survived it). |
| + |
| +**CURSOR_RESET** (suite doctrine §6.6, revision 11, 91affa1): a sibling |
| +answering 409 to memoria's cursor has every document memoria holds from |
| +it marked `pending`, its feed marked `Reconciling` (which `rule()` |
| +withholds wholesale, with "*Docs* is being re-read after a restore"), |
| +and its cursor discarded. The next wake reads from the start; a document |
| +the re-read fetches is unpended; at the tip the rest are deleted and the |
| +app is shown again. A second reset before the tip is a failure that |
| +re-marks everything pending; a reset answered to the start is a broken |
| +producer and drops nothing (`siblingreset_test.go`). |
| ## 9. Surfaces |
diff --git a/internal/memoria/team_access_test.go b/internal/memoria/team_access_test.go| index 3eaa419..b1b49db 100644 |
| --- a/internal/memoria/team_access_test.go |
| +++ b/internal/memoria/team_access_test.go |
| @@ -313,16 +313,28 @@ func TestTeamStandingEndsAtTheLeaseUnderAFailingRefresh(t *testing.T) { |
| // are no shares to fall back on); every item, the add page, the |
| // correction page and the connectors are a retryable 503; the native |
| // API's JSON list, which cannot carry the notice, is a 503 too. |
| +// |
| +// MUTATION-TESTED 2026-11-02 (Fable's survivors on the search-home merge, |
| +// each seen red and reverted): /documents mounted under member → "Unknown |
| +// /documents = 503"; /suggest under list, and under no standing → 204; |
| +// Try set after withhold → "Unknown / … nothing listed". |
| func TestTeamUnknownListsArePartialAndItemsAreRetryable(t *testing.T) { |
| f := newTeamFixture(t) |
| doc := f.ingest("plan", "Nebula plan", "The nebula plan is ready.") |
| + // A labelled value, so the front page has a Try chip to withhold |
| + // (Fable, 2026-11-02: no team fixture could show one, and a chip set |
| + // after withhold rendered beside the notice unseen). |
| + f.ingest("desk", "Front desk", "## Reception\n\nOffice phone: +353 (0)1 547 9999") |
| f.member(teamSubject('a'), "owner") |
| + if w := f.page("/"); !strings.Contains(w.Body.String(), "rst-home-try") { |
| + t.Fatalf("a Member's front page has no Try chips, so their absence below proves nothing:\n%s", w.Body.String()) |
| + } |
| f.expired() |
| - for _, path := range []string{"/?q=nebula", "/", "/reports"} { |
| + for _, path := range []string{"/?q=nebula", "/", "/documents", "/reports"} { |
| w := f.page(path) |
| body := w.Body.String() |
| - if w.Code != 200 || !isPartial(body) || strings.Contains(body, "Nebula plan") { |
| + if w.Code != 200 || !isPartial(body) || strings.Contains(body, "Nebula plan") || strings.Contains(body, "Front desk") || strings.Contains(body, "rst-home-try") { |
| t.Fatalf("Unknown %s = %d, want the partial notice and nothing listed:\n%s", path, w.Code, body) |
| } |
| if strings.Count(body, partialBody) != 1 { |
| @@ -333,7 +345,7 @@ func TestTeamUnknownListsArePartialAndItemsAreRetryable(t *testing.T) { |
| if frag.Code != 200 || !isPartial(frag.Body.String()) || strings.Contains(frag.Body.String(), "Nebula plan") { |
| t.Fatalf("Unknown search fragment = %d:\n%s", frag.Code, frag.Body.String()) |
| } |
| - for _, path := range []string{"/documents/" + itoa64(doc), "/documents/" + itoa64(doc) + "/delete", "/add", "/facts/correct?q=nebula", "/answer?q=nebula", "/connectors", "/connectors/notion", "/answer/feedback/1", "/api/native/session"} { |
| + for _, path := range []string{"/documents/" + itoa64(doc), "/documents/" + itoa64(doc) + "/delete", "/suggest?q=nebula", "/add", "/facts/correct?q=nebula", "/answer?q=nebula", "/connectors", "/connectors/notion", "/answer/feedback/1", "/api/native/session"} { |
| got := f.page(path) |
| if got.Code != http.StatusServiceUnavailable || got.Header().Get("Retry-After") == "" || got.Header().Get("Cache-Control") != "no-store" { |
| t.Fatalf("Unknown %s = %d %v, want a retryable no-store 503", path, got.Code, got.Header()) |
| @@ -360,6 +372,7 @@ func TestTeamEmptyPartialListSaysPartialNotEmpty(t *testing.T) { |
| f.expired() |
| for path, empty := range map[string][]string{ |
| "/": {"Nothing stored yet", "0 documents"}, |
| + "/documents": {"Nothing stored yet", "0 documents"}, |
| "/?q=nebula": {"No matches", "Nothing stored yet", "0 documents"}, |
| "/reports": {"No corrections yet", "No ratings yet"}, |
| } { |
diff --git a/internal/memoria/team_survivors_test.go b/internal/memoria/team_survivors_test.go| index 3cf9a7f..a5edae8 100644 |
| --- a/internal/memoria/team_survivors_test.go |
| +++ b/internal/memoria/team_survivors_test.go |
| @@ -374,3 +374,30 @@ func TestTeamOffAnUnknownHomeSubjectIsStillRefused(t *testing.T) { |
| t.Fatal("team mode off allocated a person for an unknown Home subject") |
| } |
| } |
| + |
| +// Under Unknown the lists ask nobody: standing is read before a list is |
| +// built (teamReaches), so no S2 question goes out on behalf of a person |
| +// whose standing is not known. /documents' before-check survived removal |
| +// because its after-check withholds anyway (Fable, 2026-11-02); this is |
| +// what it is for. MUTATION-TESTED 2026-11-02: the before-check removed |
| +// from documents() → "asked". |
| +func TestTeamUnknownListsAskNobody(t *testing.T) { |
| + f := newTeamFixture(t) |
| + custody := &fixedCustody{apps: docsRoster(), give: suite.VISIBLE} |
| + f.app.store.custody = custody |
| + if _, err := f.app.store.Ingest(systemWrite(context.Background()), IngestSpec{Source: "Docs", Key: "s", Title: "Shared nebula", Body: "nebula sibling content", ItemID: "doc-one", SiblingRevision: 3}); err != nil { |
| + t.Fatal(err) |
| + } |
| + f.member(teamSubject('a'), "member") |
| + if w := f.page("/documents"); !strings.Contains(w.Body.String(), "Shared nebula") || custody.calls == 0 { |
| + t.Fatalf("a Member's list did not ask (calls=%d), so the absence below proves nothing", custody.calls) |
| + } |
| + f.expired() |
| + custody.calls = 0 |
| + for _, path := range []string{"/documents", "/", "/?q=nebula"} { |
| + f.page(path) |
| + if custody.calls != 0 { |
| + t.Fatalf("%s under Unknown asked the app of record %d times", path, custody.calls) |
| + } |
| + } |
| +} |
diff --git a/internal/memoria/visible_test.go b/internal/memoria/visible_test.go| index e773721..5a46ad2 100644 |
| --- a/internal/memoria/visible_test.go |
| +++ b/internal/memoria/visible_test.go |
| @@ -27,6 +27,7 @@ import ( |
| // "the documents list"; Recently updated left unfiltered → "recently |
| // updated"; ownDocument removed from the delete question → "delete"; |
| // the UNKNOWN branch answering 404 → "an app that did not answer". |
| +// 2026-11-02: Summary.Sibling forced false → "Delete offered". |
| func TestEverySurfaceAsksTheAppOfRecord(t *testing.T) { |
| logger := slog.New(slog.NewTextHandler(io.Discard, nil)) |
| d, err := db.Open(filepath.Join(t.TempDir(), "app.db"), logger) |
| @@ -98,6 +99,11 @@ func TestEverySurfaceAsksTheAppOfRecord(t *testing.T) { |
| if !strings.Contains(list, "rst-withheld") { |
| t.Errorf("the documents list: Docs did not answer for one, and the page does not say so") |
| } |
| + // Delete is offered on memoria's own rows only (Fable, 2026-11-02: |
| + // Summary.Sibling forced false survived; the link then 404s). |
| + if !strings.Contains(list, `href="`+doc(own)+`/delete"`) || strings.Contains(list, `href="`+doc(mine)+`/delete"`) { |
| + t.Errorf("the documents list: Delete offered on another app's row, or not on memoria's own") |
| + } |
| // Recently updated, on the front page. |
| home := get("/").Body.String() |
| @@ -127,3 +133,20 @@ func TestEverySurfaceAsksTheAppOfRecord(t *testing.T) { |
| t.Errorf("delete: another app's document was deleted by the POST") |
| } |
| } |
| + |
| +// VisibleDocuments refuses to rule with no asker: there is nobody to ask |
| +// about. Every caller checks first, so this is called directly — a guard |
| +// nothing can reach is a guard written to pass (AGENTS.md; Fable, |
| +// 2026-11-02). MUTATION-TESTED 2026-11-02: the check removed → red. |
| +func TestVisibleDocumentsRefusesWithNoAsker(t *testing.T) { |
| + s := storeForTest(t) |
| + s.custody = &fixedCustody{apps: docsRoster(), give: suite.VISIBLE} |
| + id, err := s.Ingest(context.Background(), IngestSpec{Source: "Docs", Key: "k", Title: "T", Body: "B", ItemID: "k", SiblingRevision: 1}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + vis, _, err := s.VisibleDocuments(context.Background(), suite.Subject{}, []int64{id}) |
| + if err == nil || vis[id] { |
| + t.Fatalf("no asker: visible=%v err=%v, want a refusal", vis, err) |
| + } |
| +} |
diff --git a/internal/memoriatest/gates_test.go b/internal/memoriatest/gates_test.go| index 0efa0f8..264b9fb 100644 |
| --- a/internal/memoriatest/gates_test.go |
| +++ b/internal/memoriatest/gates_test.go |
| @@ -410,10 +410,25 @@ func TestNoContentInLogs(t *testing.T) { |
| get(t, h, "/?q=revenue") |
| get(t, h, "/search?q="+secret) |
| get(t, h, "/search?q=revenue") |
| + // The typeahead runs on every keystroke, so it is where a query in a |
| + // log line is likeliest to be written next (Fable, 2026-11-02: a |
| + // q logged in suggest() survived this gate; with these lines it is |
| + // red, MUTATION-TESTED the same day and reverted). And the pages that name |
| + // documents: the list, the front page's Recently updated, one page. |
| + get(t, h, "/suggest?q="+secret) |
| + get(t, h, "/suggest?q=revenue") |
| + get(t, h, "/documents") |
| + get(t, h, "/") |
| + if m := regexp.MustCompile(`href="/documents/(\d+)"`).FindStringSubmatch(get(t, h, "/documents").Body.String()); m != nil { |
| + get(t, h, "/documents/"+m[1]) |
| + } |
| // Now a file whose store genuinely fails. Last, because it takes the |
| // database away from everything above. |
| d.Close() |
| + // With the database gone the typeahead's search fails, and its failure |
| + // path is a log line of its own. |
| + get(t, h, "/suggest?q="+secret) |
| reply := readReply(t, submitJSON(t, h, file{secret + "-fails.txt", "A passage about the migration date."})) |
| if reply.Stored != 0 || len(reply.Refused) != 1 || |
| !strings.Contains(reply.Refused[0], secret+"-fails.txt") { |
diff --git a/internal/memoriatest/suggest_test.go b/internal/memoriatest/suggest_test.go| new file mode 100644 |
| index 0000000..fb90c0d |
| --- /dev/null |
| +++ b/internal/memoriatest/suggest_test.go |
| @@ -0,0 +1,45 @@ |
| +package memoriatest |
| + |
| +import ( |
| + "html" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +// The typeahead (§8.14), through the real route: the box's one checked |
| +// answer and the documents, never a best guess and never §8.9's model |
| +// step. Until Fable's review (2026-11-02) its only coverage was a browser |
| +// test and the team lapse test, so `make ci` could not see either rule. |
| +// |
| +// MUTATION-TESTED 2026-11-02, each seen red and reverted: the `Guess == |
| +// nil` condition dropped → "a best guess"; /suggest calling Search for |
| +// SearchWhileTyping → "the model was called". |
| +func TestTheTypeaheadNeverGuessesOrCallsTheModel(t *testing.T) { |
| + m := &countingModel{} |
| + h, _ := appWithModel(t, m) |
| + store(t, h, "Reception", "## Front desk\n\nOffice phone: +353 (0)1 547 9999") |
| + store(t, h, "Contacts", "## Phones\n\nReception: +353 (0)1 547 0001\n\nSales: +353 (0)1 547 0002\n\nFax: +353 (0)1 547 0003\n\nSupport: +353 (0)1 547 0004") |
| + |
| + // The presence half: a checked answer is the answer row. |
| + one := get(t, h, "/suggest?q=office+phone") |
| + if b := html.UnescapeString(one.Body.String()); one.Code != 200 || !strings.Contains(b, "rst-suggest-fact") || !strings.Contains(b, "547 9999") { |
| + t.Fatalf("a checked answer is not the typeahead's answer row (%d):\n%s", one.Code, b) |
| + } |
| + |
| + // Four phones and nothing to choose between them: the results page's |
| + // best guess, never the typeahead's answer. |
| + rec := get(t, h, "/suggest?q=phone+number") |
| + b := html.UnescapeString(rec.Body.String()) |
| + if strings.Contains(b, "rst-suggest-fact") { |
| + t.Errorf("the typeahead shows a best guess as its answer:\n%s", b) |
| + } |
| + if !strings.Contains(get(t, h, "/?q=phone+number").Body.String(), "rst-fact-guess") { |
| + t.Fatal("the results page makes no guess here, so the absence above proves nothing") |
| + } |
| + |
| + before := m.calls |
| + get(t, h, "/suggest?q=office+address") |
| + if m.calls != before { |
| + t.Errorf("the model was called %d times by a keystroke; the typeahead never runs §8.9", m.calls-before) |
| + } |
| +} |