The feeder-v1 contract, its fixtures and a fake Feeder (#8) #29

Merged
svc-agent-writer merged 3 commits from issue-8-feeder-contract into main 2026-11-13 02:55:54 +00:00

Closes #8.

What this adds

The feeder-v1 contract in contracts/feeder-v1/: every field that can leave the Source Mac, as a closed list. No real Feeder exists yet. The real Feeder must pass the tests in this directory before a release.

File What it is
contracts/feeder-v1/README.md The contract document. It gives each field its meaning in the words of GLOSSARY.md.
contracts/feeder-v1/operations.json Eight operations, all GET: path, parameters, grammar and largest page. Six error codes.
contracts/feeder-v1/schema.json A JSON Schema (2020-12) for each response. Every object is closed and every field is required.
contracts/feeder-v1/fixtures/ A synthetic history in 8 steps, 30 recorded exchanges and 45 refusals.
contracts/feeder-v1/conformance.py The contract tests. They run against any Feeder, on a port or on a Unix socket.
src/messages_mind_mcp/wire.py The service's reading of the contract: closed, strict, frozen models. It holds no client.
tests/feeder_fake.py A fake Feeder. It is a test program and is not in the package.

The acceptance criteria

  • A schema for every operation. schema.json and operations.json.
  • Fixtures for each named case. Both Transports in one Chat, a group Chat, an Edit, an Unsend, a Tapback, a reply, a row with an attachment, a move to Recently Deleted, a hard deletion whose record is gone while the count has moved, and a row with a redacted code. One test names each case.
  • A serialisation test refuses any field outside the closed list. The test adds a field and removes a field at every depth of every recorded response. The schema and the wire models both refuse each one.
  • The fake Feeder passes the same contract tests that the real Feeder must pass. It passes at every step, on a port and on a Unix socket of mode 0600 (ADR 0011). 54 Feeders that each break one rule fail, each with its code.
  • The contract document lists each field with its meaning. A test checks that the document names every field, operation, error code and step.

Rulings that this change records

  • A hard-deletion record holds a hash of the guid, and not the guid. The row is gone, so the Feeder cannot apply the deny list to the record. ADR 0006 is amended.
  • Redaction applies to the name of a Chat. ADR 0005 is amended.

Choices to read in the diff

The contract holds more than the issue named. Each of these is in "The operations", "A row" or "What this contract does not settle" of the contract document.

  • Every parameter is required, appears once and is a decimal number. No parameter has a default.
  • The Feeder checks the token first, so a request with no valid token gets 401 for every path and every method.
  • A Chat has a name and a group flag. A Tapback has an action, and the kinds emoji, sticker and other.
  • check names the contract and lists the columns of a schema-pin fault.
  • A Tapback whose target the Feeder does not serve is not served. A reply to such a message has a reply_to of null.
  • A time position is the time of the last item of the page in Unix milliseconds, a dot and the row id of that item.
  • rcs is a value of transport, and no fixture holds an RCS row.
  • A message whose Transport the Feeder does not know is not served, and nothing counts those messages.
  • newest_date is the date of the newest row that the Feeder serves, and a Tapback is a row.

What the tests do not cover

  • The synthetic history is small. The tests do not exercise the rule that ends a page at 1 MiB, and they do not reach the values of the Limits table.
  • The Mirror has no column for a reply target, an attachment or a Tapback action. The sync slice adds them.

Checks

make check passes on macOS: ruff, ruff format, mypy in strict mode over src, tests and contracts, and 414 tests. The two-axis review ran, and its findings are closed in the second commit.

🤖 Generated with Claude Code

Closes #8. ## What this adds The `feeder-v1` contract in `contracts/feeder-v1/`: every field that can leave the Source Mac, as a closed list. No real Feeder exists yet. The real Feeder must pass the tests in this directory before a release. | File | What it is | |---|---| | `contracts/feeder-v1/README.md` | The contract document. It gives each field its meaning in the words of `GLOSSARY.md`. | | `contracts/feeder-v1/operations.json` | Eight operations, all `GET`: path, parameters, grammar and largest page. Six error codes. | | `contracts/feeder-v1/schema.json` | A JSON Schema (2020-12) for each response. Every object is closed and every field is required. | | `contracts/feeder-v1/fixtures/` | A synthetic history in 8 steps, 30 recorded exchanges and 45 refusals. | | `contracts/feeder-v1/conformance.py` | The contract tests. They run against any Feeder, on a port or on a Unix socket. | | `src/messages_mind_mcp/wire.py` | The service's reading of the contract: closed, strict, frozen models. It holds no client. | | `tests/feeder_fake.py` | A fake Feeder. It is a test program and is not in the package. | ## The acceptance criteria - **A schema for every operation.** `schema.json` and `operations.json`. - **Fixtures for each named case.** Both Transports in one Chat, a group Chat, an Edit, an Unsend, a Tapback, a reply, a row with an attachment, a move to Recently Deleted, a hard deletion whose record is gone while the count has moved, and a row with a redacted code. One test names each case. - **A serialisation test refuses any field outside the closed list.** The test adds a field and removes a field at every depth of every recorded response. The schema and the wire models both refuse each one. - **The fake Feeder passes the same contract tests that the real Feeder must pass.** It passes at every step, on a port and on a Unix socket of mode 0600 (ADR 0011). 54 Feeders that each break one rule fail, each with its code. - **The contract document lists each field with its meaning.** A test checks that the document names every field, operation, error code and step. ## Rulings that this change records - **A hard-deletion record holds a hash of the `guid`, and not the `guid`.** The row is gone, so the Feeder cannot apply the deny list to the record. ADR 0006 is amended. - **Redaction applies to the name of a Chat.** ADR 0005 is amended. ## Choices to read in the diff The contract holds more than the issue named. Each of these is in "The operations", "A row" or "What this contract does not settle" of the contract document. - Every parameter is required, appears once and is a decimal number. No parameter has a default. - The Feeder checks the token first, so a request with no valid token gets `401` for every path and every method. - A Chat has a `name` and a `group` flag. A Tapback has an `action`, and the kinds `emoji`, `sticker` and `other`. - `check` names the contract and lists the columns of a schema-pin fault. - A Tapback whose target the Feeder does not serve is not served. A reply to such a message has a `reply_to` of `null`. - A time position is the time of the last item of the page in Unix milliseconds, a dot and the row id of that item. - `rcs` is a value of `transport`, and no fixture holds an RCS row. - A message whose Transport the Feeder does not know is not served, and nothing counts those messages. - `newest_date` is the date of the newest row that the Feeder serves, and a Tapback is a row. ## What the tests do not cover - The synthetic history is small. The tests do not exercise the rule that ends a page at 1 MiB, and they do not reach the values of the Limits table. - The Mirror has no column for a reply target, an attachment or a Tapback action. The sync slice adds them. ## Checks `make check` passes on macOS: ruff, ruff format, mypy in strict mode over `src`, `tests` and `contracts`, and 414 tests. The two-axis review ran, and its findings are closed in the second commit. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The contract states everything that can leave the Source Mac. It is a
directory, contracts/feeder-v1, that a Feeder in another language can
read and test against with no code of this package.

The contract
- Eight operations, all GET, under /v1: check, new rows, backfill,
  changed rows, Recently Deleted, hard deletions, the Reconcile listing
  and Chats. operations.json lists each path, each parameter and the
  largest page. schema.json is the closed list of fields of each answer.
- Every parameter is required, appears once and is a decimal number. A
  parameter outside the list is refused, and so is a token in the query.
- The Feeder checks a request in one order: token, path, method,
  parameters, schema pin. An answer to a refused request holds one code
  and repeats nothing of the request.
- A message has twelve fields. No field holds a file path, a file name,
  the text before an Edit, the text of an unsent message, or the text
  that a Tapback copies. An Unsend is a message with an edit time and no
  body.
- A wrong schema pin answers 503 for every operation but check.
- The transport is HTTP over one TCP port or over one Unix socket of
  mode 0600 (ADR 0011). The rules are the same for both.

The fixtures
- A synthetic history in eight steps: both Transports, a group Chat, an
  Edit, an Unsend, a Tapback, a reply, an attachment, a move to Recently
  Deleted, a hard deletion whose record is gone while the count moved, a
  redacted code, a denied Handle, a denied Chat and two schema changes.
- Each step states the text that no answer may hold. 30 recorded
  exchanges state the exact answers. 45 refusals state each fault and
  its status.

The contract tests
- conformance.py runs against a Feeder at a URL or a Unix socket. It
  needs httpx and jsonschema only. It prints one line with a code and a
  place, and never a response or the token.
- The fake Feeder passes at every step on a port and on a socket. 41
  broken Feeders each fail with a named code.

The package
- wire.py holds the closed models that `sync` will use to read an
  answer. A test holds the models and the schema to the same fields, and
  a field added at any depth is refused by both.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The two-axis review found that the contract tests passed a Feeder
with no token check on six of the eight paths, and that four claims
were wider than their controls.

The contract tests:
- They make the common refusals for each operation from
  operations.json: 90 requests beside the 45 of refusals.json. No
  path can skip the token check, the parameter check or its largest
  page.
- They search the headers of every response for a withheld text, and
  not only the body.
- They read a last `$` of a schema pattern as the end of the text,
  and a number with a fraction part is not an integer. The schema as
  the tests read it was looser than the wire models.
- A request from the end of an operation must return no item and the
  same position.
- 53 broken Feeders fail, each with its code. 41 failed before.

The contract:
- A time position is the time of the last item of the page in Unix
  milliseconds, a dot and the row id of that item. It was called a
  text that sync cannot read, while the recorded exchanges fixed its
  form. It never names a row that the Feeder does not serve.
- `reply_to` is null when the Feeder does not serve the message that
  the row replies to. A reply named a withheld row before.
- The documents state the one exception to the deny list: a
  hard-deletion record holds the guid of the deleted row and nothing
  else, so it can hold the guid of a row in a denied Chat.
- The document lists what the contract does not settle: RCS, the
  name of a group Chat, a reply whose target leaves, and one item
  that is larger than 16 MiB.

The fixtures:
- An Edit whose new body holds a One-time code.
- A reply to a row of a denied Handle.
- A name for each attachment, in the withheld list.

The wire models hide their input in the text of a validation error.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Hash the guid of a hard-deleted row; redact the name of a Chat (#8)
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
ci/woodpecker/push/validation Pipeline was successful
a37042ab80
Two rulings of the operator on the feeder-v1 contract.

A hard-deletion record now holds `guid_hash`, the SHA-256 of the
guid of the deleted row, in place of the guid. The row is gone, so
the Feeder cannot apply the deny list to the record. With the hash,
no identifier of a row that the Feeder never served leaves the
Source Mac. sync matches a record by the hash of each guid that the
Mirror holds. ADR 0006 records the ruling.

Redaction now applies to the name of a Chat, which any Member can
set. The fixtures hold a group Chat whose name holds a One-time
code, and a Feeder that serves that name before Redaction fails the
contract tests. ADR 0005 records the ruling.

54 broken Feeders fail the contract tests, each with its code.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign in to join this conversation.
No description provided.