Skip to content

fix(port): the documented datastore contract omitted the method documents() calls - #315

Merged
Polichinel merged 1 commit into
developmentfrom
fix/312-followup-port-contract
Sep 29, 2026
Merged

Polichinel merged 1 commit into
developmentfrom
fix/312-followup-port-contract

Conversation

@Polichinel

Copy link
Copy Markdown
Collaborator

Follow-up to #312.

/code-review's finding 4 said the port documented itself as four-method when documents made it five. I fixed the module header and missed the thing that mattered: the class docstring also enumerates the datastore methods a caller must supply, and get_predictions_by_metadata was absent.

Measured, not reasoned about — a double built to the documented contract:

AttributeError: 'DocumentedContract' object has no attribute 'get_predictions_by_metadata'

Mid-delivery, after the upload. The one place this port exists to prevent a surprise.

How it surfaced

While verifying — for this repo, rather than taking a peer's word — that a pipeline-core fix to get_latest_file_id's missing sort would actually reach us.

It does. This repo vendors no copy of the Appwrite client, calls search_files_by_metadata nowhere, and the port accepts any duck-typed datastore with pipeline-core's DatastoreModule passed in production. So that fix arrives with a pin bump and no change here. views-faoapi and views-crafdapi each carry their own copy of that module and are not covered.

The guard

Derived from the source rather than hardcoded: it collects every self._dsm.<method>( the port calls and asserts each appears in a docstring. Prose cannot drift from code without failing — which is exactly how this rotted. It also asserts it found calls at all, so renaming _dsm can't leave it silently scanning nothing (ADR-014 §2).

Mutation-proven by removing the fifth name: fails both partners.

Verification

526 passing, ruff clean. Both partner packages unchanged at 690 and 699.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9

…ents() calls

Follow-up to #312. /code-review's finding 4 said the port documented itself as
four-method when `documents` made it five. I fixed the module header and missed
the thing that mattered: the CLASS docstring also enumerates the datastore methods
a caller must supply, and `get_predictions_by_metadata` was absent from it.

Measured rather than reasoned about — a double built to the documented contract:

    class DocumentedContract:
        def get_latest_file_id(self, filters): ...
        def get_file_metadata(self, fid): ...
        def download_prediction(self, fid): ...
        def upload_data(self, **kw): ...

    AttributeError: 'DocumentedContract' object has no attribute
    'get_predictions_by_metadata'

Mid-delivery, after the upload has happened — which is the one place this port
exists to prevent a surprise.

Found while verifying, for this repo rather than taking it on trust, that a
pipeline-core fix to `get_latest_file_id`'s missing sort would actually reach us.
It does: this repo vendors no copy of the Appwrite client, calls
`search_files_by_metadata` nowhere, and the port takes any duck-typed datastore
with `views_pipeline_core.modules.datastore.DatastoreModule` passed in production.
So the ordering fix reaches us with a pin bump and no change here. faoapi and
crafdapi each carry their own copy of that module and are not covered.

The guard is derived from the source, not a hardcoded list: it collects every
`self._dsm.<method>(` the port calls and asserts each appears in the module or
class docstring. Prose cannot drift from the code without failing, which is how
this one rotted. Mutation-proven by removing the fifth name, which fails both
partners. ADR-014 §2 — the guard also asserts it found calls at all, so a
refactor that renames `_dsm` cannot leave it silently scanning nothing.

526 passing. Both partner packages unchanged at 690 and 699.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9
@Polichinel
Polichinel merged commit da303f2 into development Sep 29, 2026
4 checks passed
@Polichinel
Polichinel deleted the fix/312-followup-port-contract branch September 29, 2026 20:10
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