Skip to content

S3 (#359): funnel the six store-construction sites into one factory per partner - #367

Merged
Polichinel merged 1 commit into
developmentfrom
seam/362-one-store-factory-per-partner
Nov 28, 2026
Merged

Polichinel merged 1 commit into
developmentfrom
seam/362-one-store-factory-per-partner

Conversation

@Polichinel

Copy link
Copy Markdown
Collaborator

Closes #362. Story 3 of epic #359, and the last. Pure restructuring — Fowler's two hats: no behaviour change, and no new behaviour tests. The same 636 tests pass before and after, which is the evidence that matters.

What changed

A seam you cannot switch from outside the code is not a seam (Feathers, ch. 4). The store was built in six places, three per partner, so there was no single point at which a later change could choose a different implementation. Each partner now has one:

def _datastore(config: AppwriteConfig, *, keep_model_path: bool) -> DatastoreModule:

keep_model_path has no default, deliberately. The two settings are two different query behaviours and the wrong one is silent:

  • False clears model_path, suppressing pipeline-core's automatic name == model_name filter — which overwrites a name the caller supplied rather than narrowing it (C-77, measured on the real store in S2 (#359): characterize the model_path filter semantics #361).
  • True keeps it, which only the two partner write stores want, because upload_data falls back to model_path.model_name when name is None.

So adding a fourth store to either package means deciding which it is, in the open, at the call site.

Acceptance — all checked

Criterion Result
grep -rn "DatastoreModule(" views_postprocessing 2 sites, one per partner, down from 6
Full suite 636 passed / 1 failed / 3 skipped / 41 xfailed — the same counts as before the refactor
ruff 0.14.13 clean
The suppressions survive and are provable 4 mutations, 4 caught, each by the right test and the right partner
No new abstraction crosses the two partners _datastore defined separately in each package; nothing imports it across the boundary
store_port.py untouched both copies unchanged and still byte-identical (same md5)

The one failure is test_the_installed_runtime_dependencies_match_the_lockfile, pre-existing and failing identically on clean development (views-models#757).

Mutations: the factory never suppressing; the shelf reader asking to keep; the write store asking to clear; the read-back asking to keep.

Two consequences handled rather than worked around

⭐ The first two stories paid for themselves here. tests/test_findability.py asserted this property by searching the builder's source text for store.model_path = None. Moving that line into the factory broke the check while changing no behaviour — the weakness of a textual guard, and /code-review high had predicted this exact failure on #361 before the refactor existed. #361 had already added a behavioural, mutation-verified test of the same property, so the textual assertion is gone.

It is replaced by a structural check on the call's argument rather than on a line of text. That matters for a reason review found: the behavioural test sits behind importorskip("views_pipeline_core"), so deleting the textual guard outright would have left C-77 asserted by nothing in an environment without pipeline-core. The structural one needs no dependency, and I verified it fires by flipping the argument.

⚠️ The factory's docstring was condensed rather than raising the line budget a third time this month. The reasoning it repeated now lives in tests/test_store_construction.py, where it is measured. The manager budget passes with four lines spare.

One expectation missed, stated plainly

The story expected net lines slightly negative. They are +33. The epic requires the two partners to share nothing, so the factory and its explanation exist twice. I shortened the explanation to fit the budget but did not pretend the number.

Found by review, outside this story

/code-review high widened to the whole unreleased diff and surfaced findings in code this story does not touch. Two are real and are mine, from #327, already released in 1.5.0 — filed separately rather than smuggled in here, since this is a pure-refactor commit:

  • 🔴 contract/audience.py reports "distinct credentials" having compared nothing when both credentials are absent or blank — the same self-certifying polarity the project-id branch twenty lines above refuses. Measured and confirmed.
  • ⚠️ the audience credential is passed to the client raw while the project id beside it is passed checked and stripped.

One review finding I checked and rejected: it claimed this diff makes region a newly mandatory launch-config key that views-models does not declare. region did become mandatory, but in 1.5.0, not here — and both views-models postprocessors already declare it, derived from a single source with an assertion. No run is at risk. What survives is a documentation gap, filed separately.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9

Story 3 of epic #359. Pure restructuring — Fowler's two hats, no behaviour
change, no new behaviour tests. The same 636 tests pass before and after.

A seam you cannot switch from outside the code is not a seam (Feathers, ch. 4).
The store was constructed in six places, three per partner, so there was no
single point at which a later change could choose a different implementation.
Each partner now has one `_datastore(config, *, keep_model_path)`.

`keep_model_path` has no default, deliberately. The two settings are two
different query behaviours and the wrong one is silent:

  - False clears model_path, suppressing pipeline-core's automatic
    name == model_name filter, which OVERWRITES a name the caller supplied
    rather than narrowing it (C-77, measured on the real store in #361)
  - True keeps it, which only the two partner WRITE stores want, because
    upload_data falls back to model_path.model_name when name is None

So adding a fourth store means deciding which it is, at the call site.

The two partners are NOT unified, as the story requires: `_datastore` is
defined separately in each package, nothing imports it across the boundary,
and both copies of store_port.py are untouched and still byte-identical.

Acceptance, all checked:

  - `grep -rn "DatastoreModule(" views_postprocessing` returns TWO sites, one
    per partner, down from six
  - full suite 636 passed / 1 failed / 3 skipped / 41 xfailed, the same counts
    as before the refactor. The failure is
    test_the_installed_runtime_dependencies_match_the_lockfile, pre-existing
    and failing identically on clean development (views-models#757)
  - ruff 0.14.13 clean
  - four mutations through the new factory, each caught by exactly the right
    test and the right partner: the factory never suppressing; the shelf
    reader asking to keep; the write store asking to clear; the read-back
    asking to keep
  - no new abstraction crosses the two partners

Two consequences handled rather than worked around:

  - tests/test_findability.py asserted this property by searching the
    builder's SOURCE TEXT for `store.model_path = None`. Moving that line into
    the factory broke the check while changing no behaviour, which is the
    weakness of a textual guard. #361 already added a behavioural, mutation-
    verified test of the same property, so the textual assertion is replaced
    by a structural one on the call's argument — and that one fires where the
    behavioural test skips, which /code-review high pointed out would
    otherwise have left C-77 unguarded in an environment without
    pipeline-core.
  - the factory's docstring was condensed to stay inside the manager line
    budget rather than raising the budget a third time this month. The
    reasoning it used to repeat lives in tests/test_store_construction.py,
    which is where it is measured.

Net lines are +33, not the "slightly negative" the story expected: the epic
requires the two partners to share nothing, so the factory and its
explanation exist twice. Said rather than massaged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9
@Polichinel
Polichinel merged commit 34fbfbf into development Nov 28, 2026
4 checks passed
@Polichinel
Polichinel deleted the seam/362-one-store-factory-per-partner branch December 1, 2026 01:37
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