oficina / suite Public

Revision 10, after review (GPT-6 Astra): operative sections, harness, strictness, logs

- The doctrine's operative text now follows revision 10: the contract
  table, provenance table, leak list item 1, gate 3 (revision 10's rule,
  revision 9's kept as history), gate 6b, S6, the link row of §13, §14's
  ruling 15, A.2 and A.4 — which told memoria to restore the custody
  intersection. New gate 3c: a consumer rules every surface that names a
  document before it ingests private items.
- Harness: superseded S3 revisions, S2 one revision ahead (UNKNOWN for a
  person who may open it, s2_result_ahead in the fixture), a stranger at
  every revision, feed rows asserted (live at current revision, gone only
  for deletion), refusal headers compared. The reference server stops
  serving superseded revisions and answering STALE ahead; five new broken
  variants refused.
- server/: fixed log strings, never a producer's error text; a real EOF
  check in place of Decoder.More (trailing ] or } passed); consumers
  config must be a non-empty list (null disabled the routes). Survivors
  re-run: seven red; the eighth (a header on every refusal alike) is not
  an oracle.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 53b79d50971f8e572f32776cdd1585b628a0c3f3 parent 12848f8
8 files changed, +342 −45
  • conformance/conformance.go +88 −9
  • conformance/conformance_test.go +42 −4
  • docs/superpowers/specs/2026-09-05-suite-sharing-doctrine.md +73 −12
  • fixtures.go +4 −0
  • fixtures/custody.json +15 −1
  • server/consumers.go +7 −1
  • server/server.go +19 −7
  • server/server_test.go +94 −11

CI passed — run details

CI log
=== gate ===
ok  	amadan.net/oficina/suite	0.011s
ok  	amadan.net/oficina/suite/conformance	0.010s
ok  	amadan.net/oficina/suite/server	0.012s
diff --git a/conformance/conformance.go b/conformance/conformance.go
index 5988096..9e0e6d9 100644
--- a/conformance/conformance.go
+++ b/conformance/conformance.go
@@ -14,7 +14,9 @@ import (
"fmt"
"net/http"
"net/http/httptest"
+ "sort"
"strconv"
+ "strings"
"testing"
"amadan.net/oficina/suite"
@@ -58,7 +60,7 @@ func Check(h http.Handler) Report {
checkS3(h, fixture, &r)
checkS2(h, fixture, &r)
- checkS1(h, &r)
+ checkS1(h, fixture, &r)
return r
}
@@ -76,6 +78,18 @@ func checkS3(h http.Handler, f suite.CustodyFixture, r *Report) {
r.fail("S3 for an item that does not exist: got %d, want 404", baseline.Code)
}
+ // A superseded revision is never served: a consumer asking for revision
+ // 6 of an item now at 7 gets the refusal, not today's bytes under
+ // yesterday's number (Astra, 2026-11-01: the reference server served it).
+ for _, c := range f.Cases {
+ rec := do(h, "GET", suite.RouteS3+"/"+c.ItemID+"?revision="+strconv.FormatInt(c.Revision-1, 10), nil)
+ r.Checked++
+ if refusal(rec) != refusal(baseline) {
+ r.fail("S3 %s at superseded revision %d: %s, want the refusal for an item that does not exist (%s)",
+ c.ItemID, c.Revision-1, refusal(rec), refusal(baseline))
+ }
+ }
+
for _, c := range f.Cases {
url := suite.RouteS3 + "/" + c.ItemID + "?revision=" + strconv.FormatInt(c.Revision, 10)
rec := do(h, "GET", url, nil)
@@ -100,12 +114,13 @@ func checkS3(h http.Handler, f suite.CustodyFixture, r *Report) {
continue
}
- // A refusal must be byte-identical to the refusal for an item that
- // never existed. Anything a server adds here — a reason, a name, a
- // revision — tells the caller the item is real.
- if body != baseline.Body.String() {
- r.fail("S3 %s: refusal body %q differs from the refusal for an item that does not exist (%q), so the answer reveals that this item exists",
- c.ItemID, body, baseline.Body.String())
+ // A refusal must be identical to the refusal for an item that never
+ // existed — body AND headers. Anything a server adds here, a reason
+ // in the body or a title in a header, tells the caller the item is
+ // real (headers: Astra, 2026-11-01).
+ if refusal(rec) != refusal(baseline) {
+ r.fail("S3 %s: refusal %s differs from the refusal for an item that does not exist (%s), so the answer reveals that this item exists",
+ c.ItemID, refusal(rec), refusal(baseline))
}
}
}
@@ -132,8 +147,23 @@ func checkS2(h http.Handler, f suite.CustodyFixture, r *Report) {
askS2(h, f, r, "the fixture's asker, one revision behind", f.Asker, behind,
func(c suite.CustodyCase) suite.Authorization { return c.S2ResultSuperseded })
+ ahead := make([]suite.ItemRevision, 0, len(f.Cases))
+ for _, c := range f.Cases {
+ ahead = append(ahead, suite.ItemRevision{ItemID: c.ItemID, Revision: c.Revision + 1})
+ }
+ askS2(h, f, r, "the fixture's asker, one revision ahead", f.Asker, ahead,
+ func(c suite.CustodyCase) suite.Authorization { return c.S2ResultAhead })
+
askS2(h, f, r, "a person with no team standing", f.Stranger, current,
func(c suite.CustodyCase) suite.Authorization { return c.S2ResultStranger })
+
+ // The stranger at the other revisions too: a server that checks the
+ // revision before the person tells a stranger STALE where it owes them
+ // NOT_VISIBLE (Astra, 2026-11-01).
+ askS2(h, f, r, "a person with no team standing, one revision behind", f.Stranger, behind,
+ func(c suite.CustodyCase) suite.Authorization { return c.S2ResultStranger })
+ askS2(h, f, r, "a person with no team standing, one revision ahead", f.Stranger, ahead,
+ func(c suite.CustodyCase) suite.Authorization { return c.S2ResultStranger })
}
func askS2(h http.Handler, f suite.CustodyFixture, r *Report, what string, asker suite.Subject, pairs []suite.ItemRevision, want func(suite.CustodyCase) suite.Authorization) {
@@ -162,13 +192,62 @@ func askS2(h http.Handler, f suite.CustodyFixture, r *Report, what string, asker
// Gate 1 for the feed, and the leak memoria's draft 1 shipped. The decoder
// refuses unknown fields, so a row carrying a title, a body or a visibility
// flag fails here rather than in a store somebody greps a year later.
-func checkS1(h http.Handler, r *Report) {
+//
+// And what the rows say (Astra, 2026-11-01). Under revision 10 the feed
+// carries every live item at its current revision, not gone, and `gone`
+// means deleted and nothing else: a server still marking private items gone
+// would keep a person's own documents out of their search. The last row for
+// an item is its state; a deleted item may be absent or gone, never live.
+func checkS1(h http.Handler, f suite.CustodyFixture, r *Report) {
rec := do(h, "GET", suite.RouteS1+"?cursor=", nil)
r.Checked++
- if _, err := suite.DecodeS1(rec.Code, rec.Body.Bytes()); err != nil {
+ feed, err := suite.DecodeS1(rec.Code, rec.Body.Bytes())
+ if err != nil {
r.fail("S1: %v", err)
+ return
+ }
+ last := map[string]suite.FeedRow{}
+ for _, row := range feed.Rows {
+ last[row.ItemID] = row
+ }
+ for _, c := range f.Cases {
+ r.Checked++
+ row, ok := last[c.ItemID]
+ if c.Rung == suite.RungDeleted {
+ if ok && !row.Gone {
+ r.fail("S1 %s: a deleted item's last row is not gone", c.ItemID)
+ }
+ continue
+ }
+ switch {
+ case !ok:
+ r.fail("S1 %s (%s): a live item is missing from the feed", c.ItemID, c.Name)
+ case row.Gone:
+ r.fail("S1 %s (%s): a live item's last row is gone; gone means deleted", c.ItemID, c.Name)
+ case row.Revision != c.Revision:
+ r.fail("S1 %s: last row at revision %d, want %d", c.ItemID, row.Revision, c.Revision)
+ }
+ }
+}
+
+// refusal is a response as a consumer could compare it: status, body and
+// every header but Date.
+func refusal(rec *httptest.ResponseRecorder) string {
+ var keys []string
+ for k := range rec.Header() {
+ if k != "Date" {
+ keys = append(keys, k)
+ }
+ }
+ sort.Strings(keys)
+ var b strings.Builder
+ b.WriteString(strconv.Itoa(rec.Code))
+ for _, k := range keys {
+ b.WriteString("|" + k + "=" + strings.Join(rec.Header()[k], ","))
}
+ b.WriteString("|" + rec.Body.String())
+ return b.String()
}
func do(h http.Handler, method, url string, body []byte) *httptest.ResponseRecorder {
diff --git a/conformance/conformance_test.go b/conformance/conformance_test.go
index 4c17546..6f94f1b 100644
--- a/conformance/conformance_test.go
+++ b/conformance/conformance_test.go
@@ -26,6 +26,11 @@ type referenceServer struct {
wrongBodyForTeamItem bool // 200, carrying a different item's bytes
tellExistenceApart bool // a different refusal for "never existed"
ignoreAskerAndRevision bool // VISIBLE for any asker, at any revision
+ serveSuperseded bool // 200 with today's bytes for an older revision
+ staleWhenAhead bool // STALE for a revision ahead of the log
+ revisionBeforePerson bool // STALE for a stranger at an old revision
+ privateAsGone bool // revision 9's feed: non-team items gone
+ leakHeaderInRefusal bool // the right 404, with a title in a header
}
func (s *referenceServer) find(itemID string) (suite.CustodyCase, bool) {
@@ -63,8 +68,10 @@ func (s *referenceServer) serveS3(w http.ResponseWriter, r *http.Request) {
}
return
}
- // Revision 10: every live item is held, so every live item is served.
- if c.Rung != suite.RungDeleted {
+ // Revision 10: every live item is held, so every live item is served —
+ // at its current revision only.
+ rev, _ := strconv.ParseInt(r.URL.Query().Get("revision"), 10, 64)
+ if c.Rung != suite.RungDeleted && (rev == c.Revision || s.serveSuperseded) {
w.WriteHeader(200)
if s.wrongBodyForTeamItem {
w.Write([]byte("the bytes of some other document entirely"))
@@ -77,6 +84,9 @@ func (s *referenceServer) serveS3(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(403)
return
}
+ if s.leakHeaderInRefusal {
+ w.Header().Set("X-Item-Title", c.Name)
+ }
w.WriteHeader(404)
if s.leakBodyInRefusal {
// The status the contract demands, and the secret in the body anyway.
@@ -132,13 +142,23 @@ func (s *referenceServer) serveS2(w http.ResponseWriter, r *http.Request) {
answer = suite.VISIBLE
}
+ case stranger && s.revisionBeforePerson && p.Revision < c.Revision:
+ answer = suite.STALE
+
case stranger:
// No team standing reaches nothing, the team rung included.
answer = suite.NOT_VISIBLE
- case mayOpen(c) && p.Revision != c.Revision:
+ case mayOpen(c) && p.Revision < c.Revision:
answer = suite.STALE
+ case mayOpen(c) && p.Revision > c.Revision:
+ // A revision the log does not recognise (§4.3).
+ answer = suite.UNKNOWN
+ if s.staleWhenAhead {
+ answer = suite.STALE
+ }
+
case mayOpen(c):
answer = suite.VISIBLE
}
@@ -155,7 +175,7 @@ func (s *referenceServer) serveS1(w http.ResponseWriter, r *http.Request) {
row := map[string]any{
"item_id": c.ItemID,
"revision": c.Revision,
- "gone": c.Rung == suite.RungDeleted,
+ "gone": c.Rung == suite.RungDeleted || (s.privateAsGone && c.Rung != suite.RungTeam),
"touched_at": "2026-09-05T09:00:00Z",
}
if s.leakVisibilityInFeed {
@@ -293,3 +313,21 @@ func TestHarnessCatchesAFeedRowCarryingVisibility(t *testing.T) {
t.Error("harness passed a feed row carrying a visibility flag")
}
}
+
+// Astra's surviving mutants (2026-11-01), each now a broken server the
+// harness must refuse.
+func TestHarnessCatchesWhatTheFirstRevision10HarnessMissed(t *testing.T) {
+ for name, bend := range map[string]func(*referenceServer){
+ "a superseded revision served": func(s *referenceServer) { s.serveSuperseded = true },
+ "STALE for a revision ahead": func(s *referenceServer) { s.staleWhenAhead = true },
+ "STALE for a stranger": func(s *referenceServer) { s.revisionBeforePerson = true },
+ "private items gone from the feed": func(s *referenceServer) { s.privateAsGone = true },
+ "a title in a refusal's headers": func(s *referenceServer) { s.leakHeaderInRefusal = true },
+ } {
+ s := newReference(t)
+ bend(s)
+ if report := conformance.Check(s); len(report.Failures) == 0 {
+ t.Errorf("%s: the harness passed it", name)
+ }
+ }
+}
diff --git a/docs/superpowers/specs/2026-09-05-suite-sharing-doctrine.md b/docs/superpowers/specs/2026-09-05-suite-sharing-doctrine.md
index 0db6aaa..63095e8 100644
--- a/docs/superpowers/specs/2026-09-05-suite-sharing-doctrine.md
+++ b/docs/superpowers/specs/2026-09-05-suite-sharing-doctrine.md
@@ -46,6 +46,12 @@ alone. A consumer also learns that private items exist, which §4.2's
indistinguishability used to hide from it; it was never a person, and the
person-facing guarantee is S2's.
+**A consumer must be ready before it ingests a private item** (gate 3c,
+§11). Every surface it has that names a document asks S2 for the person in
+the same request — not search alone. memoria found its own document page
+asking nothing on the day of the ruling (memoria §8.13); A.4 makes the
+gate binding.
+
**What is not ruled by this revision:** guests. A guest is never on a
roster, so a consumer never names one as an asker; an item granted only to a
guest is held, and only its owner (and any member it is also granted to)
@@ -738,9 +744,9 @@ spec, which owns them, and are cited here for completeness of direction.
| 7 activity | home → instance | **assertion** for the person, `aud` = instance | who the front door is for | `design-activity-pull` §4–5 owns the wire shape. The home renders and holds rendered output only, under two ages (§4.3). Not in the contract module yet — §12 step 2 is S1, S2 and S3. When it arrives, the fixtures **cite** that spec's gates 10–20 rather than restate them, or this contract rebuilds §2's drift one layer down. |
| 8 roster | instance → home | consumer token | which instance asks | §5.3. Scoped to the caller's team. Paged; the copy has a TTL. |
| S1 change feed | sibling → sibling | consumer token | same-team sibling | `(item_id, revision, gone, touched_at)`. No title, no content, no visibility flag. Per-consumer TTL; past it, full re-announce. |
-| S2 authorization | sibling → sibling | consumer token **+ named asker** | same-team sibling, asking for a person | Four values, total decoder, cap 256 pairs. **Never cached**: a passage crosses no request boundary without an S2 `VISIBLE` in the request that carried it (memoria §8.4, gate 26). Asker is a typed subject (§3); the answer is intersected with custody (§4.3). |
-| S3 content | sibling → sibling | consumer token | same-team sibling | `(id, revision)`, **no person**. Team-visible only. 404, never 403. |
-| S6 aggregate | sibling → Sheets | consumer token + named asker | as S2 | Enumerated function over cell refs, never expression text. Cap 64. Typed subject and the custody intersection, as S2. |
+| S2 authorization | sibling → sibling | consumer token **+ named asker** | same-team sibling, asking for a person | Four values, total decoder, cap 256 pairs. **Never cached**: a passage crosses no request boundary without an S2 `VISIBLE` in the request that carried it (memoria §8.4, gate 26). Asker is a typed subject (§3); the answer is the app's own read check for that person — team rung, ownership, a live grant, never a link — with no custody intersection since revision 10 (§4.3). |
+| S3 content | sibling → sibling | consumer token | same-team sibling | `(id, revision)`, **no person**. Every live item at its current revision since revision 10 (team-visible only before it); one identical 404 for deleted, unknown or superseded. Never 403. |
+| S6 aggregate | sibling → Sheets | consumer token + named asker | as S2 | Enumerated function over cell refs, never expression text. Cap 64. Typed subject and the app's own read check, as S2 (no custody intersection since revision 10). |
| S8 write-as-self | sibling → sibling | consumer token | same-team sibling | §7.2. Into the caller's designated area only; only items the caller authored. |
| hand-off | browser → instance | the **person's own session** | the person | §7.1. A redirect POST, the shape of home call 6. Not a server call. |
@@ -883,7 +889,7 @@ depends on whether the path has a person**, because two of them do not:
| Path | Has an asker? | The check |
|---|---|---|
| An ordinary read, an export, an activity row | Yes | S2 to each app of record, for that person |
-| An onward S3 fetch | **No** — S3 is person-less by definition (§6) | **Custody**: every source still team-visible, or S3 answers 404 |
+| An onward S3 fetch | **No** — S3 is person-less by definition (§6) | **Custody**: every source still live (revision 10; "still team-visible" before it), or S3 answers 404. The person-facing check is the ordinary read's: S2 for every source, for the asker |
| A read through a read-only link | **No** — a link holder is no roster subject | The item carries no link while any source is not itself link-shared |
Revision 3 wrote "the sources still authorize the asker" for all of them,
@@ -1068,7 +1074,15 @@ wording (Appendix A).
Each app keeps its own. These are the costs that exist only because the
apps are a suite, and every one is a consequence of ruling 1 or 4.
-1. **A compromised sibling reads everything team-visible in its team**,
+1. **Since revision 10 (Paul, 2026-11-01), a compromised sibling reads
+ every live item in its team**, private and individually granted ones
+ included, through S3 and from its own store — that is what "Hold
+ private too, check per person" costs, and Paul accepted it knowingly.
+ What follows in this item is revision 9's bound, kept for the record;
+ the claim that a compromised sibling "cannot read an item that was
+ never team-visible" no longer holds.
+
+ *Revision 9:* **A compromised sibling reads everything team-visible in its team**,
across every app, through S3, **and everything that was team-visible
when it was ingested**. This is what "one trust domain" means and there
is no version of ruling 1 without it. Custody buys two things and not a
@@ -1184,7 +1198,21 @@ that cannot be written as stated is a spec bug.
with short, duplicate, malformed and non-2xx responses, and with an
asker subject of a kind the receiver does not key on, which is
`UNKNOWN` for the whole call and never `NOT_VISIBLE`.
-3. **Custody, one fixture per rung.** S3 answers 200 for a `team` item and
+3. **Custody, one fixture per rung — revision 10's rule** (Paul,
+ 2026-11-01; `fixtures/custody.json` is the operative statement). S3
+ answers 200 with the item's own bytes for **every live item** at its
+ current revision, whatever its rung, and one identical 404 — status,
+ headers and body — for a deleted item, an id that never existed, and a
+ superseded revision. S2 is the app's own read check for the named asker:
+ `VISIBLE` for the team rung, the owner and a live grantee; `NOT_VISIBLE`
+ for a link-only, guest-only or moved-to-private item the asker neither
+ owns nor holds a grant on, for a deleted one, and for a stranger at any
+ revision; `STALE` one revision behind and `UNKNOWN` one ahead for a
+ person who may open it. S1 carries every live item at its current
+ revision, and `gone` only for deletion. The paragraph below is revision
+ 9's gate 3, superseded.
+
+ *Revision 9:* **Custody, one fixture per rung.** S3 answers 200 for a `team` item and
404 for `private`, `granted`, guest-only, **link-shared-but-not-team**
(ruling 15) and deleted. The status and body are identical for "not
team-visible" and "does not exist". **S2 answers `NOT_VISIBLE` for the
@@ -1194,6 +1222,14 @@ that cannot be written as stated is a spec bug.
live grant against a deleted row. Add **team-plus-link** (team-visible
because of the rung) and **a link added or revoked after ingest** (no
change to custody either way).
+3c. **A consumer is ready for private items** (revision 10). Before a
+ consumer ingests a sibling's private or granted items, a test seeds one
+ document the asker may open and one they may not, from a sibling that
+ answers S2 per item, and asserts that **every** surface naming a
+ document — search, its suggestions, any generated answer and its
+ citations, the document page, every list, a delete or report path —
+ shows the first and never the second, and withholds loudly when the
+ sibling does not answer. memoria's is `TestEverySurfaceAsksTheAppOfRecord`.
4. **No cross-team dial.** Zero connections to a host whose `<team>` label
differs — `acme-evil`, `acme.docs.oficina.works.evil` — and zero
*follow-up* connections when an allowed host answers with a redirect to
@@ -1225,9 +1261,9 @@ that cannot be written as stated is a spec bug.
6b. **Provenance survives the hop** (§7), one case per path because the
paths differ. Write an item into app B derived from sources in A and C.
Revoke A's source for a person: B's **ordinary read and export** withhold
- the **whole artefact** and name A — never a partial redaction. Make A's
- source non-team-visible: B's **S3** answers 404, on custody, with no
- asker anywhere in the call. Give B's item a read-only link while A's
+ the **whole artefact** and name A — never a partial redaction. Delete A's
+ source (revision 10; "make it non-team-visible" before it): B's **S3**
+ answers 404, on custody, with no asker anywhere in the call. Give B's item a read-only link while A's
source has none: the link is refused. Assert a write is refused when a
source's app of record serves no S2 at all.
7. **The hand-off, through the real middleware.** A handler-level fixture
@@ -1304,7 +1340,8 @@ that cannot be written as stated is a spec bug.
4. **S6, before memoria's slice 2 and not before its slice 1.** Sheets
serves it, memoria calls it, and nobody else does either: an enumerated
aggregate over cell refs, capped at 64, never expression text, carrying
- the typed asker and the custody intersection S2 carries.
+ the typed asker and the read check S2 carries (no custody intersection
+ since revision 10).
**Slice 1 does not need it** — that is S1, S2, S3 and memoria §4.1, all
of which the module already has. Slice 2 is memoria's model layer, and
@@ -1341,7 +1378,7 @@ change to where the list comes from.
| A token exchange so siblings can hold assertions | The home's latency budget can afford being in every search, which §6.1 says it cannot |
| Mail and files as suite apps | A wrapper around keymail or slopbox that serves S1 to S3 and takes a roster |
| An instance-side check on membership changes — refusing a roster addition, or a call-7 arrival, for a person with no recent session; an owner countersignature on roster writes | A designed mechanism. Ruling 13 concedes a compromised home rather than bounding it, and this is the shape a bound would take. Recorded so it reads as absent by decision, not by oversight |
-| A link share that a sibling can index | Never, under ruling 15. A link is a capability, and a capability that becomes searchable by the team is a different grant than the one made |
+| A link share that a sibling can index | Never, under ruling 15. A link is a capability, and a capability that becomes searchable by the team is a different grant than the one made. **Since revision 10** a sibling holds link-shared items like every live item, and this row survives as a rule of S2: a link never makes an item `VISIBLE` to anybody (the fixture's `doc-link` and `doc-link-added-late`) |
---
@@ -1353,7 +1390,11 @@ change to where the list comes from.
different text. Rulings 12, 13 and 14 are Paul's, taken on Fable's
recommendation. **Ruling 15 is this session's proposal from Paul's
product requirement and he has not ruled on it** — a reader should treat
- it as the one rung of §1 that is not yet settled.
+ it as the one rung of §1 that is not yet settled. **Superseded
+ 2026-11-01**: Paul ruled the custody half away (revision 10, *"Hold
+ private too, check per person"*) and kept the ladder for who may open
+ what, with Docs' default *"New docs Team, old private"*. A link is still
+ never a grant.
- **What the second review said**, kept for the record. `CODEX-FINDINGS.md`
is unedited beside this file; the map from its findings to revision 3 is
in the status block. Its six trust-boundary findings were:
@@ -1472,6 +1513,13 @@ instance boundary."* with *"'Sharing is membership' forbids data crossing
a team boundary (suite ruling 2). Same-team siblings may pull
team-visible content under the suite contract (suite §6), and Docs serves
S1 to S3 and S8 **wherever sibling consumer tokens are configured**."*
+
+> **Revision 10 (Paul, 2026-11-01)** changes "team-visible content" to
+> **every live document**: Docs' S1 lists them all, S3 serves any at its
+> current revision, and S2 is Docs' own read check per person. Docs gains
+> a `team` rung for documents, the default for new ones and not for
+> existing ones (*"New docs Team, old private"*). Docs implements the
+> producer through `suite/server` (§6.5).
The sibling switch is independent of shape (suite §3): §12 steps 2 and 3
have Docs and Sheets serving lone peers before the home exists, so "in
suite shape" would forbid the sequencing this document depends on.
@@ -1543,6 +1591,19 @@ retired."*
§1.3: correct the S3 prose to match §6.1: S3 takes no person; the fix
removed the asker rather than adding one.
+> **Revision 10 (Paul, 2026-11-01) reverses the next paragraph's first
+> instruction**: do **not** intersect S2's answer with custody — memoria
+> holds every live sibling item and S2 is the app's own per-person check.
+> Typing the asker subject stands. And add one: **before memoria ingests a
+> sibling's private items, every memoria surface that names a sibling
+> document must obtain a fresh S2 answer for the person in the same
+> request** — search, typeahead, the AI answer and its citations, a
+> document's own page, every list ("Recently updated", the documents
+> list), the delete question, report and feedback links (which reach the
+> document page, so they are ruled there). A surface that names a document
+> without asking is the leak revision 10 moved the risk into. memoria
+> §8.13 records the surfaces and their gate.
+
§4.1: intersect S2's answer with the custody predicate (suite §4.3), and
type the asker subject (suite §3). The grants join as §4.1 states it —
Sheets §4.5's *"plus rows granted to me individually"* — answers `VISIBLE`
diff --git a/fixtures.go b/fixtures.go
index a1bea5d..82b4bca 100644
--- a/fixtures.go
+++ b/fixtures.go
@@ -65,6 +65,10 @@ type CustodyCase struct {
// revision behind. A team item is STALE — readable, but the app of record
// has moved on — and anything custody already refuses stays refused.
S2ResultSuperseded Authorization `json:"s2_result_superseded"`
+ // S2ResultAhead is the answer one revision ahead of the app's own: a
+ // revision its log does not recognise. UNKNOWN for a person who may open
+ // the item (§4.3), NOT_VISIBLE for one who may not.
+ S2ResultAhead Authorization `json:"s2_result_ahead"`
// S2ResultStranger is the answer for a person with no team standing.
S2ResultStranger Authorization `json:"s2_result_stranger"`
}
diff --git a/fixtures/custody.json b/fixtures/custody.json
index 92589fc..1ec285e 100644
--- a/fixtures/custody.json
+++ b/fixtures/custody.json
@@ -18,7 +18,12 @@
"else) and `asker_grant` whether the asker holds a live individual grant",
"on it, so an app can seed the world. What must differ is whether the",
"asker may open the item today; the rung decides that only through the",
- "app's own read check."
+ "app's own read check.",
+ "",
+ "s2_result_ahead is the answer one revision AHEAD of the app's own: a",
+ "revision its log does not recognise is UNKNOWN for a person who may",
+ "open the item (§4.3), and NOT_VISIBLE for one who may not — a person",
+ "with no right to the item learns nothing about its revisions."
],
"team": "acme",
"asker": {
@@ -42,6 +47,7 @@
"s3_status": 200,
"s2_result": "VISIBLE",
"s2_result_superseded": "STALE",
+ "s2_result_ahead": "UNKNOWN",
"s2_result_stranger": "NOT_VISIBLE"
},
{
@@ -56,6 +62,7 @@
"s3_status": 200,
"s2_result": "VISIBLE",
"s2_result_superseded": "STALE",
+ "s2_result_ahead": "UNKNOWN",
"s2_result_stranger": "NOT_VISIBLE"
},
{
@@ -70,6 +77,7 @@
"s3_status": 200,
"s2_result": "VISIBLE",
"s2_result_superseded": "STALE",
+ "s2_result_ahead": "UNKNOWN",
"s2_result_stranger": "NOT_VISIBLE"
},
{
@@ -84,6 +92,7 @@
"s3_status": 200,
"s2_result": "NOT_VISIBLE",
"s2_result_superseded": "NOT_VISIBLE",
+ "s2_result_ahead": "NOT_VISIBLE",
"s2_result_stranger": "NOT_VISIBLE"
},
{
@@ -98,6 +107,7 @@
"s3_status": 200,
"s2_result": "NOT_VISIBLE",
"s2_result_superseded": "NOT_VISIBLE",
+ "s2_result_ahead": "NOT_VISIBLE",
"s2_result_stranger": "NOT_VISIBLE"
},
{
@@ -112,6 +122,7 @@
"s3_status": 200,
"s2_result": "VISIBLE",
"s2_result_superseded": "STALE",
+ "s2_result_ahead": "UNKNOWN",
"s2_result_stranger": "NOT_VISIBLE"
},
{
@@ -126,6 +137,7 @@
"s3_status": 404,
"s2_result": "NOT_VISIBLE",
"s2_result_superseded": "NOT_VISIBLE",
+ "s2_result_ahead": "NOT_VISIBLE",
"s2_result_stranger": "NOT_VISIBLE"
},
{
@@ -140,6 +152,7 @@
"s3_status": 200,
"s2_result": "NOT_VISIBLE",
"s2_result_superseded": "NOT_VISIBLE",
+ "s2_result_ahead": "NOT_VISIBLE",
"s2_result_stranger": "NOT_VISIBLE"
},
{
@@ -154,6 +167,7 @@
"s3_status": 200,
"s2_result": "NOT_VISIBLE",
"s2_result_superseded": "NOT_VISIBLE",
+ "s2_result_ahead": "NOT_VISIBLE",
"s2_result_stranger": "NOT_VISIBLE"
}
]
diff --git a/server/consumers.go b/server/consumers.go
index 13e6be9..b4d0899 100644
--- a/server/consumers.go
+++ b/server/consumers.go
@@ -50,10 +50,16 @@ func ParseConsumers(raw string) ([]Consumer, error) {
if strings.TrimSpace(raw) == "" {
return nil, nil
}
+ // A list and nothing but a list: "null" decodes into a nil slice
+ // without error, and would have read as "no consumers" — the routes
+ // switched off by a typo rather than boot refused (Astra, 2026-11-01).
+ if !strings.HasPrefix(strings.TrimSpace(raw), "[") {
+ return nil, errors.New("suite consumers: not the agreed JSON list")
+ }
dec := json.NewDecoder(bytes.NewReader([]byte(raw)))
dec.DisallowUnknownFields()
var cs []Consumer
- if err := dec.Decode(&cs); err != nil || dec.More() {
+ if err := dec.Decode(&cs); err != nil || !atEOF(dec) || len(cs) == 0 {
return nil, errors.New("suite consumers: not the agreed JSON list")
}
seen := map[string]bool{}
diff --git a/server/server.go b/server/server.go
index 4f7e791..037e8b4 100644
--- a/server/server.go
+++ b/server/server.go
@@ -102,12 +102,14 @@ func serveS1(p Producer, logger *slog.Logger, w http.ResponseWriter, r *http.Req
if err != nil {
// Never an empty feed: an empty page for a failed read would move a
// consumer's cursor past changes it never saw.
- logger.Error("suite S1: feed failed", "err", err)
+ // A fixed string, never the error: a producer's error can carry a
+ // title or a passage, and logs are storage nobody can grep clean.
+ logger.Error("suite S1: the producer's feed failed")
w.WriteHeader(http.StatusServiceUnavailable)
return
}
if err := checkFeed(feed); err != nil {
- logger.Error("suite S1: producer broke the contract", "err", err)
+ logger.Error("suite S1: the producer's page broke the contract", "rule", err.Error())
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -117,7 +119,9 @@ func serveS1(p Producer, logger *slog.Logger, w http.ResponseWriter, r *http.Req
writeJSON(w, feed)
}
-// checkFeed holds the producer to what DecodeS1 will demand, so a mistake
+// checkFeed holds the producer to what DecodeS1 will demand. Its errors are
+// fixed strings of this package's own, never the producer's, so they may be
+// logged., so a mistake
// is a 500 here rather than a consumer stalling on a page it refuses.
func checkFeed(f suite.Feed) error {
if f.Cursor == "" {
@@ -144,7 +148,7 @@ func serveS2(p Producer, logger *slog.Logger, w http.ResponseWriter, r *http.Req
dec := json.NewDecoder(http.MaxBytesReader(w, r.Body, maxS2Body))
dec.DisallowUnknownFields()
var req suite.S2Request
- if err := dec.Decode(&req); err != nil || dec.More() {
+ if err := dec.Decode(&req); err != nil || !atEOF(dec) {
w.WriteHeader(http.StatusBadRequest)
return
}
@@ -163,12 +167,12 @@ func serveS2(p Producer, logger *slog.Logger, w http.ResponseWriter, r *http.Req
if err != nil {
// A non-2xx is UNKNOWN for the whole call on the consumer's side:
// withheld loudly, never silently.
- logger.Error("suite S2: rule failed", "err", err)
+ logger.Error("suite S2: the producer's rule failed")
w.WriteHeader(http.StatusServiceUnavailable)
return
}
if len(answers) != len(req.Pairs) {
- logger.Error("suite S2: producer broke the contract", "err", "answer count differs from pair count")
+ logger.Error("suite S2: the producer answered a different number of pairs")
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -194,7 +198,7 @@ func serveS3(p Producer, logger *slog.Logger, w http.ResponseWriter, r *http.Req
notAvailable(w)
return
case err != nil:
- logger.Error("suite S3: content failed", "err", err)
+ logger.Error("suite S3: the producer's content failed")
w.WriteHeader(http.StatusServiceUnavailable)
return
case len(body) > MaxContentBytes:
@@ -242,3 +246,11 @@ func bearer(r *http.Request) (string, bool) {
func contextWithConsumer(ctx context.Context, c Consumer) context.Context {
return context.WithValue(ctx, contextKey{}, c)
}
+
+// atEOF is the end-of-input check. Decoder.More is not one: it answers false
+// before a stray ']' or '}', so a valid document followed by either passed
+// as strict (Astra, 2026-11-01). Decoding once more must find nothing.
+func atEOF(dec *json.Decoder) bool {
+ var extra json.RawMessage
+ return dec.Decode(&extra) == io.EOF
+}
diff --git a/server/server_test.go b/server/server_test.go
index b2c2f48..c5541cc 100644
--- a/server/server_test.go
+++ b/server/server_test.go
@@ -4,8 +4,10 @@ import (
"bytes"
"context"
"errors"
+ "log/slog"
"net/http"
"net/http/httptest"
+ "sort"
"strconv"
"strings"
"testing"
@@ -19,13 +21,15 @@ import (
// fixtureProducer is a correct Producer built from the custody fixture, the
// same world the conformance harness checks.
type fixtureProducer struct {
- f suite.CustodyFixture
- feedErr error
- ruleErr error
- short bool // Rule answers one fewer than asked
- cursor string // overrides the feed's cursor when set
- content []byte // overrides S3 bytes when set
- lastAsker suite.Subject
+ f suite.CustodyFixture
+ extraRows int // Feed returns this many more rows than the cases
+ contentErr error
+ feedErr error
+ ruleErr error
+ short bool // Rule answers one fewer than asked
+ cursor string // overrides the feed's cursor when set
+ content []byte // overrides S3 bytes when set
+ lastAsker suite.Subject
}
func (p *fixtureProducer) find(id string) (suite.CustodyCase, bool) {
@@ -48,6 +52,9 @@ func (p *fixtureProducer) Feed(_ context.Context, cursor string, limit int) (sui
for _, c := range p.f.Cases {
rows = append(rows, suite.FeedRow{ItemID: c.ItemID, Revision: c.Revision, Gone: c.Rung == suite.RungDeleted, TouchedAt: time.Date(2026, 11, 1, 9, 0, 0, 0, time.UTC)})
}
+ for i := 0; i < p.extraRows; i++ {
+ rows = append(rows, suite.FeedRow{ItemID: "extra-" + strconv.Itoa(i), Revision: 1, TouchedAt: time.Date(2026, 11, 1, 9, 0, 0, 0, time.UTC)})
+ }
next := "end"
if p.cursor != "" {
next = p.cursor
@@ -70,8 +77,10 @@ func (p *fixtureProducer) Rule(_ context.Context, asker suite.Subject, pairs []s
switch {
case !may:
out = append(out, suite.NOT_VISIBLE)
- case pr.Revision != c.Revision:
+ case pr.Revision < c.Revision:
out = append(out, suite.STALE)
+ case pr.Revision > c.Revision:
+ out = append(out, suite.UNKNOWN)
default:
out = append(out, suite.VISIBLE)
}
@@ -83,6 +92,9 @@ func (p *fixtureProducer) Rule(_ context.Context, asker suite.Subject, pairs []s
}
func (p *fixtureProducer) Content(_ context.Context, id string, rev int64) ([]byte, error) {
+ if p.contentErr != nil {
+ return nil, p.contentErr
+ }
c, ok := p.find(id)
if !ok || c.Rung == suite.RungDeleted || rev != c.Revision {
return nil, suite.ErrNotAvailable
@@ -308,7 +320,12 @@ func TestS3RefusesAlike(t *testing.T) {
t.Fatalf("baseline: %d", base.Code)
}
sig := func(r *httptest.ResponseRecorder) string {
- return strconv.Itoa(r.Code) + "|" + r.Header().Get("Content-Type") + "|" + r.Body.String()
+ var hs []string
+ for k, v := range r.Header() {
+ hs = append(hs, k+"="+strings.Join(v, ","))
+ }
+ sort.Strings(hs)
+ return strconv.Itoa(r.Code) + "|" + strings.Join(hs, "|") + "|" + r.Body.String()
}
for name, url := range map[string]string{
"deleted": suite.RouteS3 + "/doc-deleted?revision=6",
@@ -326,7 +343,73 @@ func TestS3RefusesAlike(t *testing.T) {
t.Errorf("too large: %d, want the baseline", rec.Code)
}
p.content = bytes.Repeat([]byte("x"), server.MaxContentBytes)
- if rec := do(h, "GET", suite.RouteS3+"/doc-team?revision=7", "", nil); rec.Code != 200 || !strings.HasPrefix(rec.Header().Get("Content-Type"), "text/plain") {
- t.Errorf("at the limit: %d %s", rec.Code, rec.Header().Get("Content-Type"))
+ if rec := do(h, "GET", suite.RouteS3+"/doc-team?revision=7", "", nil); rec.Code != 200 || !strings.HasPrefix(rec.Header().Get("Content-Type"), "text/plain") || !bytes.Equal(rec.Body.Bytes(), p.content) {
+ t.Errorf("at the limit: %d %s, %d bytes", rec.Code, rec.Header().Get("Content-Type"), rec.Body.Len())
+ }
+ // A producer that fails is not an item that is unavailable: 503, which
+ // the consumer retries, never the 404 it would count as gone.
+ p.content, p.contentErr = nil, errors.New("replay failed")
+ if rec := do(h, "GET", suite.RouteS3+"/doc-team?revision=7", "", nil); rec.Code != 503 {
+ t.Errorf("a failed producer: %d, want 503", rec.Code)
+ }
+}
+
+// Astra's survivors (2026-11-01).
+//
+// MUTATION-TESTED 2026-11-01, each reverted: only the first consumer
+// compared → "a second consumer"; the consumer left out of the context →
+// "context"; the S2 body cap removed → "an oversized body"; the page limit
+// check removed → "a page over the limit"; a producer error logged with its
+// text → "the log"; Decoder.More() back as the end check → "trailing".
+func TestTheSurvivors(t *testing.T) {
+ two := append(consumers(t, token), server.Consumer{ID: "another", Tokens: []server.Token{{Epoch: 1, SHA256: server.TokenHash("another-token")}}})
+ h := server.Handler(producer(t), two, nil)
+ if rec := do(h, "GET", suite.RouteS1, "another-token", nil); rec.Code != 200 {
+ t.Errorf("a second consumer: %d", rec.Code)
+ }
+ who := server.Authenticate(two, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ c, _ := server.ConsumerFrom(r.Context())
+ w.Write([]byte(c.ID))
+ }))
+ if rec := do(who, "GET", "/", "another-token", nil); rec.Body.String() != "another" {
+ t.Errorf("context: the consumer is %q", rec.Body.String())
+ }
+
+ p := producer(t)
+ var logs bytes.Buffer
+ routes := server.Routes(p, slog.New(slog.NewTextHandler(&logs, nil)))
+ big := `{"asker":{"kind":"person_ref","value":"pers_ana"},"pairs":[{"item_id":"` + strings.Repeat("a", 300<<10) + `","revision":1}]}`
+ if rec := do(routes, "POST", suite.RouteS2, "", []byte(big)); rec.Code != 400 {
+ t.Errorf("an oversized body: %d, want 400", rec.Code)
+ }
+ p.extraRows = server.FeedPageLimit
+ if rec := do(routes, "GET", suite.RouteS1, "", nil); rec.Code != 500 {
+ t.Errorf("a page over the limit: %d, want 500", rec.Code)
+ }
+ p.extraRows = 0
+ const secret = "Q3 board pack: acquisition of Acme"
+ p.feedErr, p.ruleErr, p.contentErr = errors.New(secret), errors.New(secret), errors.New(secret)
+ do(routes, "GET", suite.RouteS1, "", nil)
+ do(routes, "POST", suite.RouteS2, "", []byte(`{"asker":{"kind":"person_ref","value":"pers_ana"},"pairs":[{"item_id":"doc-team","revision":7}]}`))
+ do(routes, "GET", suite.RouteS3+"/doc-team?revision=7", "", nil)
+ if strings.Contains(logs.String(), "acquisition") {
+ t.Errorf("the log: a producer's error text was logged: %s", logs.String())
+ }
+ if !strings.Contains(logs.String(), "S1") || !strings.Contains(logs.String(), "S2") || !strings.Contains(logs.String(), "S3") {
+ t.Errorf("the log: failures were not logged at all: %s", logs.String())
+ }
+
+ p.feedErr, p.ruleErr, p.contentErr = nil, nil, nil
+ for _, junk := range []string{"]", "}", "[]", `{"a":1}`} {
+ body := `{"asker":{"kind":"person_ref","value":"pers_ana"},"pairs":[{"item_id":"doc-team","revision":7}]}` + junk
+ if rec := do(routes, "POST", suite.RouteS2, "", []byte(body)); rec.Code != 400 {
+ t.Errorf("trailing %q after an S2 request: %d, want 400", junk, rec.Code)
+ }
+ }
+ good := `[{"consumer_id":"m","tokens":[{"epoch":1,"sha256":"` + server.TokenHash("x") + `"}]}]`
+ for _, bad := range []string{good + "]", good + "}", "null", "[]", `{"consumer_id":"m"}`} {
+ if _, err := server.ParseConsumers(bad); err == nil {
+ t.Errorf("trailing or not a list: %q accepted", bad)
+ }
}
}