Skip to content

Commit d4d3848

Browse files
committed
docs(tck): cut comments that restate the spec or the assets
A fact belongs in the repository that owns the thing it describes, so the prose here keeps what is this package's own and points at Appendix F for the rest. Cut: specification rationale (which requirement is a SHOULD and why a capability is therefore optional), other providers' worked examples, review history, row counts that go stale when a feature file moves, and restatements of the signature below them. Kept, trimmed: what each symbol is and what declaring it asserts; why the submodule pin is read from the submodule side, a worktree recording its git directory as an absolute path where a submodule's is relative; and why an unpacked sdist is exempt from the revision check, having no pin and no working tree that could have drifted. Prose only -- every module's AST with docstrings stripped is unchanged. Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
1 parent 886b5b0 commit d4d3848

17 files changed

Lines changed: 565 additions & 1236 deletions

File tree

‎tools/openfeature-tck/hatch_build_sync.py‎

Lines changed: 45 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
Used by `poe sync-spec-assets` for local development and CI testing. The hatch
44
build hook (hatch_build.py) handles inclusion in the wheel and sdist.
55
6-
The assets are owned by open-feature/spec, not by this repository. Copying them
7-
in at build time -- rather than committing copies -- means the spec revision this
8-
package was built against is recorded by the submodule pin and nowhere else, so
9-
the two cannot drift apart unnoticed. An *adopter* installing the wheel still
10-
needs no submodule: the copies are inside the distribution.
6+
The assets are owned by open-feature/spec. Copying them in at build time rather
7+
than committing copies means the submodule pin is the only record of the spec
8+
revision this package was built against, so the two cannot drift apart
9+
unnoticed.
1110
1211
Copying is the second half of the job. The first is making sure the submodule
1312
working tree is at the revision the pin names, because **a rebase moves the
@@ -35,7 +34,7 @@
3534
3635
For the one workflow that legitimately wants it: drafting a change to the
3736
canonical assets in a local spec checkout before there is a revision to pin. It
38-
warns on every sync, and it names the revision actually in use, because a suite
37+
warns on every sync and names the revision actually in use, because a suite
3938
running against assets nobody can identify must not be quiet about it.
4039
"""
4140

@@ -47,12 +46,10 @@
4746

4847
# (source directory or file, destination) relative to SPEC_ASSETS / DEST_BASE.
4948
#
50-
# "gherkin" copies to a directory of the same name on purpose, and the pair is not
51-
# redundant: a canonical feature is identified by its path relative to the asset
52-
# directory, so the destination name *is* the reported uri prefix. Renaming it
53-
# locally -- it used to land in "features" -- silently renamed the uri, which is
54-
# how this suite reported features/errors.feature for the file Go reports as
55-
# gherkin/errors.feature. Keep the two equal.
49+
# "gherkin" copies to a directory of the same name on purpose: a canonical
50+
# feature is identified by its path relative to the asset directory, so the
51+
# destination name *is* the reported uri prefix. Renaming it locally silently
52+
# renames the uri every language's report is keyed by. Keep the two equal.
5653
TREES = [("gherkin", "gherkin"), ("flags", "flag_data")]
5754
FILES = [("openapi/control-api.yaml", "control-api.yaml")]
5855

@@ -61,8 +58,8 @@
6158
6259
A seam, so the decision `checkout_pinned_spec` makes can be tested without a
6360
fixture repository on disk. Failure is ``None`` rather than an exception because
64-
every caller here treats "git could not answer" as a state to report rather than
65-
a crash: building from an unpacked sdist has no repository at all.
61+
every caller treats "git could not answer" as a state to report: building from
62+
an unpacked sdist has no repository at all.
6663
"""
6764

6865

@@ -83,24 +80,21 @@ def _run_git(args: Sequence[str], cwd: Path) -> str | None:
8380
def superproject_git_dir(git: GitRunner = _run_git) -> str | None:
8481
"""The superproject's git directory, asked of the submodule instead.
8582
86-
For the one environment where git cannot find the superproject on its own:
87-
a linked worktree records its git directory as an **absolute** path in the
88-
worktree's ``.git`` file, and a process in a different filesystem namespace
89-
-- WSL reading a worktree that Windows git created, which is where the
90-
stale-asset run below actually happened -- cannot follow it. A submodule's
91-
``.git`` file is *relative*, so git inside the submodule answers there and
92-
git in the superproject does not, and the pin is the half that only the
93-
superproject has.
94-
95-
The derivation is git's own layout rather than a guess about paths: a
96-
submodule's git directory is ``<superproject git dir>/modules/<path in the
97-
superproject>``, so the ancestor named ``modules`` has the answer as its
98-
parent. Read from the bottom, so a submodule inside a submodule resolves to
99-
its immediate superproject rather than the outermost one.
100-
101-
``None`` when there is no submodule repository to ask -- an unpacked sdist
102-
-- or when the layout is not that one, in which case the caller is no worse
103-
off than before.
83+
**For the environment where git cannot find the superproject on its own:** a
84+
linked worktree records its git directory as an **absolute** path in the
85+
worktree's ``.git`` file, which a process in a different filesystem namespace
86+
-- WSL reading a worktree Windows git created -- cannot follow. A submodule's
87+
``.git`` file is *relative*, so git inside the submodule answers where git in
88+
the superproject does not, and the pin is the half only the superproject has.
89+
90+
The derivation is git's own layout: a submodule's git directory is
91+
``<superproject git dir>/modules/<path in the superproject>``, so the
92+
ancestor named ``modules`` has the answer as its parent. Read from the
93+
bottom, so a submodule inside a submodule resolves to its immediate
94+
superproject.
95+
96+
``None`` when there is no submodule repository to ask -- an unpacked sdist --
97+
or when the layout is not that one.
10498
"""
10599
common = git(["rev-parse", "--git-common-dir"], SPEC_ROOT)
106100
if not common:
@@ -131,11 +125,10 @@ def pinned_revision(git: GitRunner = _run_git) -> str | None:
131125
will record and so what a run is about to claim it tested against. ``None``
132126
when there is no repository to ask, which is ordinary: an sdist has none.
133127
134-
Asked twice before giving up, and the second way is not a fallback so much
135-
as the same question routed around an unreachable path: see
136-
:func:`superproject_git_dir`. Only an answer of *nothing* is retried -- an
137-
entry that is present and is not a gitlink is a definite answer, and asking
138-
again would not change it.
128+
Asked twice before giving up, the second way being the same question routed
129+
around an unreachable path -- see :func:`superproject_git_dir`. Only an answer
130+
of *nothing* is retried; an entry that is present and is not a gitlink is a
131+
definite answer.
139132
"""
140133
entry = git(["ls-files", "-s", "--", SPEC_DIRNAME], ROOT)
141134
if not entry:
@@ -179,33 +172,24 @@ def _pin_entry_through_the_submodule(git: GitRunner) -> str | None:
179172
def checkout_pinned_spec(git: GitRunner = _run_git) -> str | None:
180173
"""Bring the submodule working tree to the revision the pin names.
181174
182-
**This is the reason this function exists: a rebase moves the gitlink and
183-
not the submodule's working tree.** So a checkout can have a pin saying one
184-
revision and assets on disk from another, and nothing about the build says
185-
so. That is not hypothetical -- it happened here, the copied Gherkin was one
186-
pin behind the capability the suite was declaring, and a self-test of the
187-
enum against the assets is what caught it. That guard fires for one symptom.
188-
A pin that changes only the *content* of a scenario would pass every guard
189-
in this package and still run the wrong suite, which is what happened in
190-
another language: a whole adoption suite ran against stale assets and
191-
reported byte-identical numbers to the previous pass, and nothing failed and
192-
nothing warned.
193-
194-
So the checkout is part of the copy rather than something the operator is
195-
expected to remember, and the copy is a dependency of the test task. The
196-
suite cannot run against assets it did not just fetch.
175+
**This is why this function exists: a rebase moves the gitlink and not the
176+
submodule's working tree.** So a checkout can have a pin naming one revision
177+
and assets on disk from another, and nothing about the build says so. A pin
178+
that changes only the *content* of a scenario passes every other guard in
179+
this package and still runs the wrong suite. So the checkout is part of the
180+
copy rather than something the operator is expected to remember, and the copy
181+
is a dependency of the test task.
197182
198183
Returns the pinned revision, or ``None`` when there is no pin to read.
199184
200-
**When the pin cannot be read this warns rather than failing.** Building
201-
from an unpacked sdist is the ordinary case -- no repository, no pin, and
202-
the assets are already in the tree. The other case is a git checkout whose
203-
superproject this process cannot reach, which happens for a linked worktree
204-
whose ``.git`` file names a path in another filesystem namespace: git inside
205-
the submodule answers, git in the superproject does not. Warning rather than
206-
failing keeps that environment usable; the warning is what says the
207-
guarantee is not in force, and the remedy is to run the sync from a shell
208-
that can see the superproject.
185+
**When the pin cannot be read this warns rather than failing.** An unpacked
186+
sdist has no pin and no working tree that could have drifted, so there is
187+
nothing to check rather than a check that cannot run -- failing there would
188+
accuse a downstream packager of a defect they cannot fix. The other case is a
189+
checkout whose superproject this process cannot reach (see
190+
:func:`superproject_git_dir`); the warning is what says the guarantee is not
191+
in force, and the remedy is to sync from a shell that can see the
192+
superproject.
209193
"""
210194
if os.environ.get(UNPINNED_ENV):
211195
head = git(["rev-parse", "HEAD"], SPEC_ROOT)

‎tools/openfeature-tck/src/openfeature/contrib/tools/tck/__init__.py‎

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
The suite answers one question: does this provider map its backend onto the
44
OpenFeature provider contract correctly? It is the Python implementation of
55
`Appendix F`_ of the specification, and it runs the same Gherkin scenarios,
6-
against the same canonical flag set, that every other language's TCK runs. That
7-
shared basis is the whole point -- "conformant" only means something if the
8-
question is identical everywhere.
6+
against the same canonical flag set, that every other language's TCK runs.
97
108
**What a provider author writes.** Two fixtures and one call::
119
@@ -42,9 +40,8 @@ def tck_config(tck_backend: RunningBackend):
4240
scenarios(*feature_paths())
4341
4442
The suite owns the container stack: it starts the Compose file once, discovers
45-
the dynamically mapped host ports, builds the HTTP control against the control
46-
API, waits until it accepts commands, and tears down after the last scenario.
47-
See :mod:`~.compose`.
43+
the mapped host ports, builds the HTTP control, waits until it accepts commands,
44+
and tears down after the last scenario. See :mod:`~.compose`.
4845
4946
**A provider with no backend supplies its own control instead** -- in-memory,
5047
environment-variable, file-based -- and needs no Compose file and no container
@@ -63,16 +60,14 @@ def tck_config():
6360
``scenarios()`` is pytest-bdd's own, called directly rather than wrapped: it
6461
injects the generated tests into the *calling module* by walking the stack, so a
6562
convenience wrapper around it would deposit them inside this package instead.
66-
:func:`~.extensions.feature_paths` is the canonical assets plus a
63+
:func:`~.extensions.feature_paths` is the canonical assets plus an
6764
``extensions`` directory beside the calling module, if there is one -- see
6865
:mod:`~.extensions`.
6966
7067
The step definitions arrive through this package's pytest plugin, so there is
7168
nothing to import for them and no ``conftest.py`` to write. Everything else --
7269
registering the provider, awaiting events, resetting the backend between
73-
scenarios, tearing down -- belongs to the TCK. If you find yourself writing test
74-
infrastructure, that is a defect here rather than something for you to work
75-
around.
70+
scenarios, tearing down -- belongs to the TCK.
7671
7772
.. _Appendix F: https://github.com/open-feature/spec/blob/main/specification/appendix-f-provider-conformance.md
7873
"""
@@ -155,23 +150,12 @@ def tck_config():
155150
"run_compose_backend",
156151
]
157152

158-
# NOTE ON THE SOURCE OF TRUTH
159-
#
160-
# The files under gherkin/ and flag_data/, and control-api.yaml, are NOT owned
161-
# by this repository and are NOT committed to it. They are copies of the
162-
# language-agnostic conformance artifacts defined in open-feature/spec under
163-
# specification/assets/provider-tck/, which reaches this package as a git
164-
# submodule at tools/openfeature-tck/spec and is copied in at build
165-
# time by hatch_build.py. The copies are gitignored, so the only record of which
166-
# spec revision this package targets is the submodule pin, and the two cannot
167-
# drift apart unnoticed.
168-
#
169-
# They are copied into the distribution, so an adopter installing this package
170-
# needs no submodule of their own; only a contributor to this package does.
171-
#
172-
# Changes belong in open-feature/spec first, followed by a bump of the submodule
173-
# pin -- editing the copies locally forks the definition of conformance, which is
174-
# the one thing this suite exists to prevent.
153+
# The files under gherkin/ and flag_data/, and control-api.yaml, are copies of
154+
# the conformance assets owned by open-feature/spec, which reaches this package
155+
# as a git submodule and is copied in at build time. The copies are gitignored,
156+
# so the submodule pin is the only record of which spec revision this package
157+
# targets. Changes belong in open-feature/spec first, followed by a bump of the
158+
# pin: editing the copies locally forks the definition of conformance.
175159
# See https://github.com/open-feature/spec/issues/417.
176160

177161
_PACKAGE = "openfeature.contrib.tools.tck"

0 commit comments

Comments
 (0)