Skip to content

S1 (#359): characterize what the prediction store returns, including failure-by-return-value - #365

Merged
Polichinel merged 1 commit into
developmentfrom
seam/360-characterize-store-returns
Nov 28, 2026
Merged

Polichinel merged 1 commit into
developmentfrom
seam/360-characterize-store-returns

Conversation

@Polichinel

Copy link
Copy Markdown
Collaborator

Closes #360. Story 1 of epic #359. Tests only — no production code changed, so no route, output or partner-facing file differs.

Why

The epic moves the Appwrite delivery write behind a gateway. Nothing can be substituted for a contract nobody wrote down, and three of the five store methods the port adapts had no test at all: the fake store carried neither get_latest_file_id nor get_file_metadata, and the upload helper discarded the port's return value. So upload could have returned None on the happy path with all 43 tests in the file still green.

These are characterization tests in Feathers' sense — they record what the code does today, not what it should do. A failure means the behaviour moved.

What is recorded

The asymmetries a substitute has to reproduce:

  • The five methods are not uniform. Three return an OperationResult; get_latest_file_id returns a bare string or None; get_predictions_by_metadata returns a bare list. A gateway that wrapped every answer in one envelope would break two of them; one that unwrapped everything would break three.
  • 🔴 get_predictions_by_metadata RAISES. It throws MetadataSearchIncomplete rather than reporting failure in its return value — the exception to this epic's headline fact. pipeline-core's own comment says why: returning [] would be "a statement about the shelf rather than about the lookup", and the FAO delivery would report nothing to deliver, "a false negative to an external counterparty". The first draft of these tests asserted the opposite for this method. Register C-104 records a review that made the same mistake and declared the handling dead code.
  • upload fails CLOSED on success and OPEN on the file id: anything but True raises, while a successful result with no usable id returns None to a caller that cannot tell it from "no upload happened".
  • latest_file_id forwards a no-match untouched. The refusal lives one layer up in delivery/findability, and moving it down would make the two layers disagree about what an empty answer means.
  • file_metadata is the only one of the five that transforms rather than forwards — it collapses the store document to the four declared identity keys. It also has no caller on the delivery path, which is parked in [Tracking] Epic #359 — make the store seam switchable #363 rather than decided here.

A gap, characterized rather than fixed

⚠ A partial upload's refusal drops the orphan's file id, although the store supplies it in the very result the refusal is built from (data={"file_id": ...}, code="PARTIAL_SUCCESS"). The operator is told an orphan exists and not told which file it is, on a bucket that held 1,007 files at the last count. Filed as #364; the test asserts today's behaviour and carries an instruction to invert the assertion when it is fixed.

Validation

On the supported interpreter — 3.11.15 in views-models/envs/views-postprocessing, not the 3.10 shell default, which is below this project's own declared floor and makes the suite abort at collection (register C-125):

Check Result
tests/test_store_port.py 77 passed, was 43
Full suite 621 passed, 1 failed, 3 skipped, 41 xfailed
ruff 0.14.13 clean
Mutations 10 applied to production code and reverted, 10 caught

The one failure is test_the_installed_runtime_dependencies_match_the_lockfile, pre-existing and confirmed failing identically on clean development: the environment holds pipeline-core 3.3.5 while the lock says 3.6.0, which is views-models#757.

Mutations, each applied to both partner copies and reverted: renaming the key the upload return reads; discarding that return; passing filters positionally; moving findability's refusal into the port; turning an empty list into None; dropping the forwarded file id; making the metadata adapter drop absent keys instead of reporting None; swallowing the search exception; adding the orphan id to the refusal; and editing the filters dict in place.

Four defects in my first draft, fixed rather than shipped

Found by /code-review high, all four verified against the installed source before acting on them:

  1. 🔴 An expectation built out of the actual result ({key: expected.get(key) for key in got}), so it passed on an empty dict and on an adapter that dropped absent keys. Now a literal four-key dict per row — and the mutation that previously slipped through is caught.
  2. 🔴 A docstring that planted a defect that does not exist, hedging over whether file_id vs fileId was a bug. It is not: upload_data builds data={"file_id": ...}, while fileId is Appwrite's spelling inside metadata documents. Both are correct where they appear, and the docstring now says so.
  3. ⚠️ A filters assertion that compared a shared dict with itself, so the port could edit it in place unnoticed. Found to still be unfalsifiable after a first partial fix, by the mutation battery rather than by reading.
  4. ⚠️ A justification claiming findability reads a length and would raise TypeError on None. It iterates with for doc in ... or (). The guard was real; only its stated reason was wrong, and the correction is kept in place rather than deleted.

Two smaller ones also fixed: the double's field order now matches the real OperationResult (success, data, error, code), and a line-number citation was replaced with a citation by file and wording, for the reason store_port.upload gives about its own.

Not in this PR

  • reports/falsification_2026-11-25_nothing_is_broken.py stays untracked. It is from a different story and carries three claims that are now stale.
  • No new register entry. The one new finding is tracked as The orphan-upload refusal drops the file id it was handed #364, and the non-uniform failure convention is already C-104.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9

Story 1 of epic #359. Tests only — no production code changes, no route,
output or partner-facing file differs.

The epic moves the Appwrite delivery write behind a gateway. Nothing can be
substituted for a contract nobody wrote down, so this records the one the port
actually has, in Feathers' sense: what it does today, not what it should do.

Three of the five adapted store methods had no test at all. The fake store
carried no `get_latest_file_id` and no `get_file_metadata`, and the upload
helper discarded the port's return value — so `upload` could have returned
None on the happy path with all 43 tests in the file still green.

Recorded, with the asymmetries a substitute has to reproduce:

- the five methods are not uniform: three return an OperationResult, one a
  bare string or None, one a bare list
- `get_predictions_by_metadata` RAISES MetadataSearchIncomplete rather than
  reporting failure in its return value, which is the exception to this epic's
  headline fact and the thing a gateway author is most likely to miss
- `upload` fails CLOSED on `success` and OPEN on the file id
- `latest_file_id` forwards a no-match untouched; the refusal lives one layer
  up in delivery/findability, and must not be moved down
- `file_metadata` collapses the store document to the four declared identity
  keys and is the only one of the five that transforms rather than forwards

Also characterized as a GAP, not an endorsement: a partial upload's refusal
drops the orphan's file id although the store supplies it. Tracked as #364
with an instruction in the test to invert the assertion when it is fixed.

Validation, on the supported interpreter (3.11.15 in the views-models env,
not the 3.10 shell default — see C-125):

- tests/test_store_port.py: 77 passed, was 43
- full suite: 621 passed, 1 failed, 3 skipped, 41 xfailed. The failure is
  test_the_installed_runtime_dependencies_match_the_lockfile, pre-existing
  and confirmed failing the same way on clean development: the env holds
  pipeline-core 3.3.5 while the lock says 3.6.0 (views-models#757)
- ruff 0.14.13: clean
- ten mutations applied to production code and reverted, each caught:
  renaming the key the upload return reads, discarding that return, passing
  filters positionally, moving findability's refusal into the port, turning an
  empty list into None, dropping the forwarded file id, making the metadata
  adapter drop absent keys instead of reporting None, swallowing the search
  exception, adding the orphan id to the refusal, and editing the filters dict
  in place

Four defects in the first draft of these tests, found by /code-review high and
fixed here rather than shipped: an expectation built out of the actual result
(so it passed on an empty dict), a filters assertion that compared a shared
dict with itself, a docstring that planted a `file_id` vs `fileId` defect that
does not exist, and a justification claiming findability reads a length when it
iterates with `or ()`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9
@Polichinel
Polichinel merged commit 0b09deb into development Nov 28, 2026
4 checks passed
@Polichinel
Polichinel deleted the seam/360-characterize-store-returns branch November 28, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant