facet-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. facet_mcp-0.1.0/LICENSE +21 -0
  2. facet_mcp-0.1.0/PKG-INFO +22 -0
  3. facet_mcp-0.1.0/README.md +211 -0
  4. facet_mcp-0.1.0/pyproject.toml +50 -0
  5. facet_mcp-0.1.0/setup.cfg +4 -0
  6. facet_mcp-0.1.0/tests/test_t01_index_verify.py +73 -0
  7. facet_mcp-0.1.0/tests/test_t02_selftest.py +133 -0
  8. facet_mcp-0.1.0/tests/test_t03_emit_guard.py +70 -0
  9. facet_mcp-0.1.0/tests/test_t04_discovery_guards.py +65 -0
  10. facet_mcp-0.1.0/tests/test_t05_claims_sweep.py +98 -0
  11. facet_mcp-0.1.0/tests/test_t06_line_endings.py +48 -0
  12. facet_mcp-0.1.0/tests/test_t07_finalize_replay.py +57 -0
  13. facet_mcp-0.1.0/tests/test_t08_ceiling.py +75 -0
  14. facet_mcp-0.1.0/tests/test_t09_elevated.py +48 -0
  15. facet_mcp-0.1.0/tests/test_t10_projection.py +61 -0
  16. facet_mcp-0.1.0/tests/test_t11_edge_mode.py +91 -0
  17. facet_mcp-0.1.0/tests/test_t12_mesh_stats.py +68 -0
  18. facet_mcp-0.1.0/tests/test_t13_det_race.py +48 -0
  19. facet_mcp-0.1.0/tests/test_t16_registry_sweep.py +80 -0
  20. facet_mcp-0.1.0/tests/test_t18_interpreter_precheck.py +97 -0
  21. facet_mcp-0.1.0/tests/test_t19_record_mcp_readonly.py +252 -0
  22. facet_mcp-0.1.0/tests/test_t20_record_mcp_certificate.py +265 -0
  23. facet_mcp-0.1.0/tests/test_t21_record_mcp_health.py +311 -0
  24. facet_mcp-0.1.0/tests/test_t22_record_mcp_tools.py +334 -0
  25. facet_mcp-0.1.0/tests/test_t23_mount_path.py +119 -0
  26. facet_mcp-0.1.0/tests/test_t24_index_parsers.py +527 -0
  27. facet_mcp-0.1.0/tests/test_t25_mask_geometry.py +279 -0
  28. facet_mcp-0.1.0/tests/test_t26_finalize_lookup.py +267 -0
  29. facet_mcp-0.1.0/tests/test_t27_packaging_shape.py +165 -0
  30. facet_mcp-0.1.0/tools/facet_index.py +2042 -0
  31. facet_mcp-0.1.0/tools/facet_mcp.egg-info/PKG-INFO +22 -0
  32. facet_mcp-0.1.0/tools/facet_mcp.egg-info/SOURCES.txt +35 -0
  33. facet_mcp-0.1.0/tools/facet_mcp.egg-info/dependency_links.txt +1 -0
  34. facet_mcp-0.1.0/tools/facet_mcp.egg-info/entry_points.txt +3 -0
  35. facet_mcp-0.1.0/tools/facet_mcp.egg-info/requires.txt +1 -0
  36. facet_mcp-0.1.0/tools/facet_mcp.egg-info/top_level.txt +2 -0
  37. facet_mcp-0.1.0/tools/record_mcp.py +1015 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mcp-tool-shop
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: facet-mcp
3
+ Version: 0.1.0
4
+ Summary: Query a governed decision record instead of reading it — facet's four-leg-verified SQLite+FTS5 index, served over MCP.
5
+ Author-email: mcp-tool-shop <64996768+mcp-tool-shop@users.noreply.github.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://mcp-tool-shop-org.github.io/facet/
8
+ Project-URL: Handbook, https://mcp-tool-shop-org.github.io/facet/handbook/
9
+ Project-URL: Source, https://github.com/mcp-tool-shop-org/facet
10
+ Project-URL: Issues, https://github.com/mcp-tool-shop-org/facet/issues
11
+ Project-URL: Changelog, https://github.com/mcp-tool-shop-org/facet/blob/main/CHANGELOG.md
12
+ Keywords: mcp,model-context-protocol,sqlite,fts5,provenance,decision-record,index
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Documentation
18
+ Classifier: Topic :: Text Processing :: Indexing
19
+ Requires-Python: >=3.11
20
+ License-File: LICENSE
21
+ Requires-Dist: mcp>=2.0.0
22
+ Dynamic: license-file
@@ -0,0 +1,211 @@
1
+ <p align="center">
2
+ <a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a> | <a href="README.es.md">Español</a> | <a href="README.fr.md">Français</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.pt-BR.md">Português (BR)</a>
3
+ </p>
4
+
5
+ <p align="center">
6
+ <img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/facet/readme.png" alt="facet" width="400">
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="https://github.com/mcp-tool-shop-org/facet/actions/workflows/ci.yml"><img src="https://github.com/mcp-tool-shop-org/facet/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
11
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License"></a>
12
+ <a href="docs/experiments/"><img src="https://img.shields.io/badge/record-spec%20%E2%86%92%20report%20%E2%86%92%20ruling-8a6f3f" alt="The record"></a>
13
+ <a href="https://mcp-tool-shop-org.github.io/facet/"><img src="https://img.shields.io/badge/landing%20page-live-2ea043" alt="Landing page"></a>
14
+ </p>
15
+
16
+ <p align="center">
17
+ <strong>A styled 2D concept goes in. A textured 3D asset comes out.</strong><br>
18
+ Local hardware end to end · no non-commercial licence anywhere in the chain
19
+ </p>
20
+
21
+ ---
22
+
23
+ The style is applied **on the asset**, in texture space — not painted per view and
24
+ stitched together afterwards. Feed the route a form-exaggerated clay concept and it
25
+ returns a textured mesh whose colour came from a styled reference of *that* mesh,
26
+ with everything the reference could not see filled by a masked inpainting brush and
27
+ a surface-aware dilation.
28
+
29
+ Named for both halves of the problem: the polygons, and the face they have to hold.
30
+
31
+ ## Where it stands
32
+
33
+ **Four accepted assets, across four subject classes, at zero credits.** Each was ruled
34
+ by the Director at his own zoom — on the GLB, or on full-size sheets — not by a metric
35
+ clearing a threshold.
36
+
37
+ | subject | class | accepted | reference / brush / dilation |
38
+ |---|---|---|---|
39
+ | **Character (W3)** | humanoid | [2026-08-04](docs/experiments/E08-ruling-gate0.md) | 68.8 / 4.2 / 27.0 |
40
+ | **Galleon** | vehicle, thin rigging | [2026-08-05](docs/experiments/E04-ruling.md) | 36.89 / 6.87 / 56.24 |
41
+ | **Dragon** | beast, wing membranes | [2026-08-07](docs/experiments/E12-ruling.md) | 44.15 / 3.07 / 52.78 |
42
+ | **Longsword** | prop, near-2D, grey-on-grey | [2026-08-08](docs/experiments/E14-ruling.md) | 45.25 / 2.07 / 52.68 |
43
+
44
+ Shares are of valid texels, and **they are not comparable across subjects** — a ship
45
+ hides most of itself from eye level and an animal hides half. Read each against its own
46
+ pre-registered reach ceiling, against which they land **86–93%**: the difference between
47
+ the rows is geometry, not regression. [Full numbers, with their
48
+ denominators](docs/handbook/subjects.md).
49
+
50
+ **It is a pipeline, not a one-character generator.** Contradict the specification on
51
+ eight named elements and the prompt wins **8 of 8** — median ΔE 46.3 against 6.2 on five
52
+ held controls — while the figure stays the same man. Structure is held by the mesh and
53
+ control; named attributes ride the prompt.
54
+
55
+ ## The route
56
+
57
+ ```
58
+ form-exaggerated clay concept ──► image-to-3D ──► weld ──► density allocation
59
+ │
60
+ cull what no camera can see ◄────────────┘
61
+ │
62
+ ▼
63
+ twins, generated from THIS mesh ──► project ──► brush the holes ──► fill
64
+ ```
65
+
66
+ Stage by stage, with the reasoning for each: **[the handbook](docs/handbook/index.md)**.
67
+
68
+ ## What makes it work
69
+
70
+ Six findings, each of which cost an experiment and each of which generalises beyond the
71
+ subject that produced it. [The long form, with the
72
+ measurements](docs/findings.md).
73
+
74
+ - **Form first, style second.** Reconstructors read surface noise as geometry. A clean
75
+ sculpt-like clay with deliberately exaggerated planes comes back with better topology
76
+ than a stylized sprite does; the styled twin is generated alongside and becomes the
77
+ colour reference.
78
+ - **Frame the face, get a face.** A bust crop puts **3.1–4.5×** more polygons on the
79
+ head, and the difference is structural — separated eyelids, a brow furrow, modelled
80
+ nostril cavities — not sharper blur.
81
+ - **Twins belong to a mesh, not a character.** Reuse a twin across meshes and coverage
82
+ collapses **62% → 22.7%**, because the arms project into empty space beside the model.
83
+ Generate twins from the mesh you are about to texture, every time.
84
+ - **Identity belongs to the prompt.** A canon element not named in the prompt is arriving
85
+ by accident and will leave the same way — measured when gold knee plates turned out to
86
+ be reaching the image only through noise in a broken ControlNet.
87
+ - **Ask geometry, not a threshold.** Replacing a keyed mask with the exact raycast
88
+ silhouette moved reference coverage **28.4% → 39.1%** of valid texels — strictly
89
+ additive, no diffusion, no GPU. Corner-median keying has now failed three times here
90
+ and is retired.
91
+ - **Cull what no camera can see, from the atlas and never the mesh.** 49% of atlas texels
92
+ are invisible from outside; excluding those faces cut interpolation **68%**. Excluding
93
+ rather than deleting makes the failure impossible instead of merely detectable.
94
+
95
+ ## What is not solved
96
+
97
+ Named and measured, on the front page rather than in a footnote. [All of them, located in
98
+ code](docs/known-defects.md).
99
+
100
+ - **The blade band takes 0.00% of stage-1 reference** on all eight cameras — steel on a
101
+ grey backdrop sits exactly on the key's own threshold. The union rescues 55.72%.
102
+ - **Stroke seams are not levelled.** A provenance boundary steps **5.5×** ordinary texture
103
+ variation; the region the Director named steps **9.5×**.
104
+ - **Dilation bleeds between unrelated atlas islands** — 74.9% of dilated texels take their
105
+ colour from another island, from a median 0.177 away on a figure 1.0 tall.
106
+ - **Every reconstruction on this route is a hollow double-walled shell**, walls ~two
107
+ voxels. No volumetric predicate is valid on one.
108
+
109
+ ## How this repo is run
110
+
111
+ The discipline is as much the product as the pipeline is, and it exists for a reason: an
112
+ earlier arc ran ten sessions that each judged their own output and wrote conclusions the
113
+ next session read as established fact. Nothing in that loop was checkable.
114
+
115
+ - **Spec before the work, report after, ruling last** — and the session that designs an
116
+ experiment never grades its own results. Twenty experiments are in
117
+ [the record](docs/experiments/).
118
+ - **Corrections land in place, beside the measurement that overturned them**, never as
119
+ quiet deletions. Six inherited claims were falsified in the founding session alone, and
120
+ all six are still readable next to what replaced them.
121
+ - **Failures stay in the repo with their reason.** [`tools/superseded/`](docs/tools.md)
122
+ is not an archive — anyone can run those tools and watch them fail the same way.
123
+ - **A negative result is a full success**, reported and closed rather than tuned toward a
124
+ number.
125
+ - **Tests ride the commit that touches the code** — 213 passing at two seats' hands, with
126
+ paths-gated CI on the 205 hermetic ones.
127
+ - **The record is queryable.** A SQLite + FTS5 index over the whole trail, verified on
128
+ four legs. It found a ruling count the prose had wrong at three sites, by counting the
129
+ record itself.
130
+
131
+ ## Where everything is
132
+
133
+ | | |
134
+ |---|---|
135
+ | **[The handbook](docs/handbook/index.md)** | the guide — the route stage by stage, the subjects, the profile system |
136
+ | **[The record](docs/experiments/)** | twenty experiments: spec, report, ruling, and every prediction stated before the measurement |
137
+ | **[What the route learned](docs/findings.md)** | the durable findings and the hard-won rules, in full |
138
+ | **[Status of every tool](docs/tools.md)** | what works, what is superseded, and the evidence for each |
139
+ | **[Known defects](docs/known-defects.md)** | everything not solved, measured and located in code |
140
+ | **[The arc, as it happened](docs/arc-history.md)** | the chronological history, corrections intact |
141
+ | **[CLAUDE.md](CLAUDE.md)** | how to work here — the roles, the rules, and what each one cost |
142
+
143
+ ## Licence position
144
+
145
+ Every stage runs local and commercially clean: SDXL (OpenRAIL++), MV-Adapter (open),
146
+ open3d (Apache-2.0), spandrel (MIT), RealESRGAN anime6B (BSD-3), Blender, numpy, scipy,
147
+ trimesh.
148
+
149
+ Deliberately excluded, with the reason: **nvdiffrast** (non-commercial — enforced here
150
+ by a structural tripwire, not by attestation), **Hunyuan3D-Paint** (licence void in the
151
+ EU, UK and South Korea), **MVPaint** and **TEXGen** (no licence at all), and
152
+ **UltraSharp / SUPIR / StableSR** (non-commercial upscalers).
153
+
154
+ ## Trust and threat model
155
+
156
+ facet runs entirely on your own machine — every tool is a script you invoke against
157
+ paths you type, so the useful question is not *what permissions does this app request*
158
+ but *what do these scripts do to your machine*. Answered by measurement, with every
159
+ sweep re-runnable; the full policy is in [SECURITY.md](SECURITY.md):
160
+
161
+ - **Data touched:** meshes, textures, images and JSON on local disk, at paths you
162
+ pass on the command line. Plus `docs/index/facet.db`, which is *derived* — it holds
163
+ nothing that was not already a file in this repo, and `facet_index.py build`
164
+ regenerates it from scratch.
165
+ - **Data NOT touched:** no credentials, ever. Nothing here reads, stores or transmits
166
+ a token, key or password, and none is present in the tree — swept for
167
+ provider-prefixed keys, GitHub PATs, Slack tokens, AWS key ids, private-key blocks,
168
+ bearer tokens and inline `api_key`/`password` assignments, **zero matches**, no
169
+ credential-shaped file tracked.
170
+ - **No telemetry.** None collected, none sent. There is no opt-out because there is
171
+ nothing to opt out of.
172
+ - **Network egress:** two tools of thirty-four open a socket — `restylize_views.py`
173
+ and `texpass_brush.py` — and both call a ComfyUI HTTP API at `--host`, **default
174
+ `127.0.0.1:8188`**. Nothing else in `tools/` makes a network call.
175
+ - **Permissions:** ordinary user. No elevation, no service install, no system-settings
176
+ or registry writes.
177
+
178
+ Three sharp edges are disclosed rather than claimed away, because a security note that
179
+ only lists reassurances is not a threat model: **file operations are not sandboxed**
180
+ (a tool writes wherever its arguments say); **absolute local paths are baked into many
181
+ tools and docs** — 114 occurrences across 26 files, not secrets but a disclosure of one
182
+ machine's layout, and the reason most tools will not run unmodified elsewhere; and
183
+ **unexpected failures surface as Python tracebacks**, with no `--debug` gate and no
184
+ structured error shape. Deliberate halts are `ANDON:` messages carrying the measurement
185
+ that fired them. That is the research-instrument contract, and
186
+ [SHIP_GATE.md](SHIP_GATE.md) records exactly when it stops being good enough.
187
+
188
+ **Support status:** this repo is developed in the open, at one rig, by one director
189
+ and a rotating pair of advisor and executor sessions. `main` is the only supported
190
+ state. There is no release channel, no backport policy, and no SLA — what there is
191
+ instead is the record: every claim sits next to the code that produces it, and
192
+ [docs/experiments](docs/experiments/) carries the spec, the report and the ruling for
193
+ each one.
194
+
195
+ ## Requirements
196
+
197
+ Blender 5.x, Python 3.11+ with `numpy`, `scipy`, `trimesh`, `open3d`, `Pillow`,
198
+ `spandrel`, `torch`. A local ComfyUI install is needed only for the inpainting brush.
199
+ Developed against an RTX 5090; VRAM headroom matters more than raw speed.
200
+
201
+ CI runs the hermetic subset of the suite on **ubuntu-latest / Python 3.12** with
202
+ pinned installs (`.github/workflows/ci.yml`); the artifacts tier needs the recorded
203
+ trees under `E:\AI\training`, which are not in git, so CI deselects them by design.
204
+ Locally, `python -m pytest` runs all **213** tests and `python -m pytest -m "not artifacts"`
205
+ runs the **205** CI reproduces.
206
+
207
+ ---
208
+
209
+ <p align="center">
210
+ Built by <a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a>
211
+ </p>
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "facet-mcp"
7
+ version = "0.1.0"
8
+ description = "Query a governed decision record instead of reading it — facet's four-leg-verified SQLite+FTS5 index, served over MCP."
9
+ requires-python = ">=3.11"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [
13
+ { name = "mcp-tool-shop", email = "64996768+mcp-tool-shop@users.noreply.github.com" },
14
+ ]
15
+ keywords = ["mcp", "model-context-protocol", "sqlite", "fts5", "provenance", "decision-record", "index"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Topic :: Software Development :: Documentation",
22
+ "Topic :: Text Processing :: Indexing",
23
+ ]
24
+ dependencies = [
25
+ "mcp>=2.0.0",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://mcp-tool-shop-org.github.io/facet/"
30
+ Handbook = "https://mcp-tool-shop-org.github.io/facet/handbook/"
31
+ Source = "https://github.com/mcp-tool-shop-org/facet"
32
+ Issues = "https://github.com/mcp-tool-shop-org/facet/issues"
33
+ Changelog = "https://github.com/mcp-tool-shop-org/facet/blob/main/CHANGELOG.md"
34
+
35
+ # Two commands, both already written and both already under test:
36
+ # facet-mcp the stdio MCP server (six tools, the four-leg verify as a
37
+ # REFUSING health surface) -> record_mcp.main
38
+ # facet-index the index itself: build / verify / q / claims -> facet_index.main
39
+ [project.scripts]
40
+ facet-mcp = "record_mcp:main"
41
+ facet-index = "facet_index:main"
42
+
43
+ # The two modules ship AS THEY ARE, from tools/, as top-level modules. This is
44
+ # deliberate and it is the whole reason extraction costs nothing here: making
45
+ # tools/ a package would rewrite the `python tools/<name>.py` invocation that
46
+ # every recorded command in this repo's record uses, and those commands are
47
+ # citable evidence. py-modules + package-dir moves nothing.
48
+ [tool.setuptools]
49
+ package-dir = { "" = "tools" }
50
+ py-modules = ["facet_index", "record_mcp"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,73 @@
1
+ """T1 / T1b - the four-leg index verify and E16-1's encoding matrix.
2
+
3
+ Source: the E15 ritual (build + verify, seeded set 19); E16-1's anchor
4
+ (Ruling 31f - verify crashed under cp1252 at the completeness branch, and a
5
+ verifier whose FAILURE report cannot print is a check that cannot fail).
6
+
7
+ The PASSED line is read FROM ITS POSITION - the last non-empty line of the
8
+ verify output - never matched anywhere in prose, because verify quotes the
9
+ record and the record contains the word PASSED.
10
+
11
+ Both tests build/verify a per-run scratch --db, so the derived tracked DB is
12
+ never touched and leg 1's det temps get per-run paths. What the `fold` marker
13
+ still covers: the CORPUS itself is read live, and in a shared working copy a
14
+ concurrent fold writing docs/ between leg 1's two builds is a real race.
15
+ """
16
+ import pytest
17
+
18
+ from conftest import run_py, last_nonempty
19
+
20
+ PASSED_LINE = "VERIFY PASSED - all four legs"
21
+
22
+
23
+ def _assert_verify_passed(rc, out, err, label):
24
+ assert rc == 0, "%s: verify exited %d\nstdout:\n%s\nstderr:\n%s" % (label, rc, out, err)
25
+ last = last_nonempty(out)
26
+ assert last == PASSED_LINE, (
27
+ "%s: the last non-empty line is not the PASSED line.\n"
28
+ "expected: %r\ngot: %r" % (label, PASSED_LINE, last))
29
+ # the seeded set is 19 (the E15 ritual). A larger seeded set is a
30
+ # deliberate change and updates this line in the same commit, per the law.
31
+ assert any(ln.strip() == "19 / 19" for ln in out.splitlines()), (
32
+ "%s: seeded-set summary '19 / 19' not found in verify output" % label)
33
+
34
+
35
+ @pytest.mark.fold
36
+ def test_t01_build_and_verify(built_db):
37
+ rc, out, err = run_py("facet_index.py", ["verify", "--db", built_db])
38
+ _assert_verify_passed(rc, out, err, "T1")
39
+ # the discovery rule must be auditable in the transcript (E16-9): verify
40
+ # prints what each glob found, so a document that stops matching is
41
+ # visible rather than inferred from a count that looks plausible
42
+ assert "[corpus] ruling documents discovered by the sorted glob" in out
43
+ assert "[corpus] kickoff documents discovered by the sorted glob" in out
44
+ # T15 (E17 amendment) and T15b (E17 Ruling 3e): the E16 and E17 arcs' count
45
+ # legs are present and passing. The COUNT itself is not pinned here -
46
+ # verify's own grep==db comparison is the invariant; this asserts the legs
47
+ # exist and hold, so a leg silently dropped from COUNT_CHECKS is caught.
48
+ import re
49
+ for leg in ("E16 numbered rulings", "E16 lettered sub-rulings",
50
+ "E17 numbered rulings", "E17 lettered sub-rulings"):
51
+ assert re.search(re.escape(leg) + r"\s+grep\s+\d+\s+db\s+\d+\s+ok", out), (
52
+ "count leg %r missing or not ok in verify output" % leg)
53
+ assert re.search(r"E16 sequence\s+ruling 1-7 gaps: none", out), (
54
+ "E16 sequence check missing or gapped")
55
+ assert re.search(r"E17 sequence\s+ruling 1-4 gaps: none", out), (
56
+ "E17 sequence check missing or gapped")
57
+ # reported, not asserted: which determinism leg held (the .dump fallback is
58
+ # pre-registered and legal; byte-identity is what this rig has measured)
59
+ det = [ln for ln in out.splitlines() if ln.startswith("determinism leg that held:")]
60
+ print("T1 %s" % (det[0] if det else "determinism-leg line not found"))
61
+
62
+
63
+ @pytest.mark.fold
64
+ @pytest.mark.parametrize("enc", ["utf-8", "cp1252"])
65
+ def test_t01b_encoding_matrix(built_db, enc):
66
+ # cp1252 is FORCED rather than inherited so the leg reproduces Ruling
67
+ # 31f's crash condition on any platform - on ubuntu CI the platform
68
+ # default is utf-8 and a "default encoding" leg would silently test
69
+ # nothing. Before E16-1 the cp1252 leg dies at facet_index.py:1768.
70
+ rc, out, err = run_py(
71
+ "facet_index.py", ["verify", "--db", built_db],
72
+ env_extra={"PYTHONIOENCODING": enc}, encoding=enc)
73
+ _assert_verify_passed(rc, out, err, "T1b[%s]" % enc)
@@ -0,0 +1,133 @@
1
+ """T2 - texpass_iter's selftest: exit 0, styled texels byte-identical
2
+ (max delta 0.000000), the write-head lossless.
3
+
4
+ Source: the tool's own selftest; E16-4's anchor table measured it on the
5
+ sword's anchor state (PASS, write-head lossless, 377 texels committed).
6
+
7
+ TIER CORRECTION, a finding against the dispatch: the kickoff lists this test
8
+ as hermetic and the tests-required law commit calls the selftest "re-runnable
9
+ from a fresh clone". It is not: --state, --prep and (via emit's unconditional
10
+ load_scene) --glb are required, and the repo tracks no fixture state - the
11
+ smallest real inputs are the recorded trees. Ported at the artifacts tier;
12
+ whether a tiny in-repo fixture state should exist is the advisor's call, not
13
+ a fixture this session invents.
14
+
15
+ -> RULED (E17 Ruling 3d): the fixture was COMMISSIONED to the index-MCP build
16
+ session, which built it at tests/fixtures/selftest_min (40 KB, one flat
17
+ quad, generated by tests/fixtures/make_selftest_fixture.py). T2b below is
18
+ that hermetic twin. The ruling is explicit that it ADDS: the artifacts
19
+ tier keeps anchoring the REAL recorded state, and T2 is unchanged.
20
+
21
+ The selftest COMMITS into --state, so the state is copied to scratch and the
22
+ recorded tree is read-only (Ruling 33's ledger).
23
+ """
24
+ import hashlib
25
+ import os
26
+ import re
27
+ import shutil
28
+
29
+ import numpy as np
30
+ import pytest
31
+
32
+ from conftest import REPO, copy_state, need, run_py, last_nonempty
33
+
34
+
35
+ @pytest.mark.artifacts
36
+ def test_t02_selftest_write_head_lossless(assets, tmp_path):
37
+ prep = need(assets, "facet_next/E14_prep")
38
+ glb = need(assets, "facet_next/E14_prep/prep_uv.glb")
39
+ state_src = need(assets, "facet_next/E14_strokes/run/final/rstate_s8anchor")
40
+ state = copy_state(state_src, tmp_path / "state")
41
+
42
+ rc, out, err = run_py(
43
+ "texpass_iter.py",
44
+ ["selftest", "--state", state, "--prep", prep, "--glb", glb])
45
+ assert rc == 0, "selftest exited %d\n%s\n%s" % (rc, out, err)
46
+
47
+ delta_lines = [ln for ln in out.splitlines()
48
+ if ln.startswith("[selftest] styled-texel max delta")]
49
+ assert len(delta_lines) == 1, "delta line not found:\n%s" % out
50
+ assert "max delta 0.000000" in delta_lines[0], (
51
+ "styled texels moved: %s" % delta_lines[0])
52
+
53
+ assert last_nonempty(out).startswith("[selftest] PASS"), (
54
+ "last line is not the selftest PASS:\n%s" % out)
55
+
56
+ # reported, not asserted: the committed count (E16-4 measured 377 on this
57
+ # state; the dispatch anchors exit code and delta, and the count depends
58
+ # on the fake-inpaint blur, i.e. on scipy - a version drift there would
59
+ # move the count without touching the write-head property under test)
60
+ m = re.search(r"committed ([\d,]+)", delta_lines[0])
61
+ print("T2 committed texels: %s (E16-4 recorded 377)" % (m.group(1) if m else "?"))
62
+
63
+
64
+ # ---------------------------------------------------------------------------
65
+ # T2b - the hermetic twin (E17 Ruling 3d, built E18 D2)
66
+ # ---------------------------------------------------------------------------
67
+
68
+ FIXTURE = REPO / "tests" / "fixtures" / "selftest_min"
69
+
70
+
71
+ def _tree_hashes(root):
72
+ out = {}
73
+ for base, dirs, names in os.walk(str(root)):
74
+ dirs.sort()
75
+ for n in sorted(names):
76
+ p = os.path.join(base, n)
77
+ with open(p, "rb") as fh:
78
+ out[os.path.relpath(p, str(root)).replace("\\", "/")] = \
79
+ hashlib.sha256(fh.read()).hexdigest()
80
+ return out
81
+
82
+
83
+ def test_t02b_selftest_hermetic_twin(tmp_path):
84
+ """The same property as T2, on a synthetic in-repo state, in CI.
85
+
86
+ NON-VACUOUS BY ASSERTION, not by hope. `max delta 0.000000` over an EMPTY
87
+ styled set is 0 for free, and `holes did not shrink` passes when nothing
88
+ was committed - so this pins both populations: the fixture carries styled
89
+ texels before the run, and the run writes texels. That pairing is what the
90
+ kickoff meant by a fixture rather than a file that loads.
91
+ """
92
+ assert FIXTURE.is_dir(), (
93
+ "the hermetic fixture is missing at %s - regenerate it with "
94
+ "tests/fixtures/make_selftest_fixture.py" % FIXTURE)
95
+ before = _tree_hashes(FIXTURE)
96
+
97
+ styled_pre = np.load(str(FIXTURE / "state" / "styled_mask.npy"))
98
+ assert styled_pre.any(), (
99
+ "the fixture carries no styled texels, so the selftest's own assertion "
100
+ "would pass over an empty set - a check that cannot fail")
101
+
102
+ state = tmp_path / "state"
103
+ shutil.copytree(str(FIXTURE / "state"), str(state))
104
+ rc, out, err = run_py(
105
+ "texpass_iter.py",
106
+ ["selftest", "--state", state,
107
+ "--prep", FIXTURE / "prep", "--glb", FIXTURE / "mesh_uv.glb"])
108
+ assert rc == 0, "hermetic selftest exited %d\n%s\n%s" % (rc, out, err)
109
+
110
+ delta_lines = [ln for ln in out.splitlines()
111
+ if ln.startswith("[selftest] styled-texel max delta")]
112
+ assert len(delta_lines) == 1, "delta line not found:\n%s" % out
113
+ assert "max delta 0.000000" in delta_lines[0], (
114
+ "styled texels moved: %s" % delta_lines[0])
115
+ assert last_nonempty(out).startswith("[selftest] PASS"), out
116
+
117
+ m = re.search(r"committed ([\d,]+)", delta_lines[0])
118
+ assert m, "no committed count in:\n%s" % delta_lines[0]
119
+ committed = int(m.group(1).replace(",", ""))
120
+ # 512 is the WHOLE hole half of a 32x32 atlas. It is a structural number,
121
+ # not a tuned one: every hole texel on this quad is visible, faces the
122
+ # camera at 1.0 and projects far more than --edge-dist from the rendered
123
+ # figure edge, so a partial count is a real change in the write head's
124
+ # acceptance rather than a tolerance to widen.
125
+ assert committed == 512, (
126
+ "hermetic selftest committed %d texels, expected the full hole half "
127
+ "(512). A partial commit is a finding, not a tolerance." % committed)
128
+ assert "holes 512 -> 0" in out, out
129
+
130
+ # the committed fixture is an INPUT and must come back untouched: the tool
131
+ # writes into --state, which is why --state is the copy
132
+ assert _tree_hashes(FIXTURE) == before, (
133
+ "the run modified the committed fixture tree")
@@ -0,0 +1,70 @@
1
+ """T3 - an unprofiled `emit` refuses loudly, before it touches any input.
2
+
3
+ Source: E16-4's anchor (Ruling 29c). An unprofiled emit used to succeed at
4
+ --aspect's default 752x1024 - one subject's portrait framing, 3.1x too wide
5
+ for the prop - with nothing in the output distinguishing a right frame from a
6
+ wrong one.
7
+
8
+ Hermeticity is PROVEN, not assumed (the dispatch's own open tier call:
9
+ "hermetic if the guard fires pre-load - verify that"): --state and --prep
10
+ point at paths that do not exist, so the run can only refuse via the guard,
11
+ which sits after parse_args and before the first file open. If the guard were
12
+ downstream of input loading, this test would see FileNotFoundError instead of
13
+ the ANDON text.
14
+
15
+ The exit code alone is NOT the assertion - on CI a missing dependency would
16
+ also exit non-zero, which would make this a check that cannot fail. The
17
+ guard's own message is asserted, and a control run with an explicit --aspect
18
+ proves the message assertion can discriminate.
19
+ """
20
+ from conftest import run_py
21
+
22
+
23
+ def test_t03_unprofiled_emit_refuses(tmp_path):
24
+ state = tmp_path / "no_such_state"
25
+ prep = tmp_path / "no_such_prep"
26
+ rc, out, err = run_py(
27
+ "texpass_iter.py", ["emit", "--state", state, "--prep", prep])
28
+ assert rc != 0, "unprofiled emit did not refuse (rc 0)\n%s\n%s" % (out, err)
29
+ text = out + err
30
+ assert "ANDON" in text and "E14 Ruling 29c" in text, (
31
+ "refusal is not the emit guard's message:\n%s" % text)
32
+ # the message names the repair
33
+ assert "--profile" in text and "--aspect" in text, (
34
+ "guard message does not name the repair:\n%s" % text)
35
+ # it refused BEFORE any output: no job dir, no state dir materialised
36
+ assert not state.exists(), "guard fired but a state path was created"
37
+
38
+
39
+ def test_t03_control_explicit_aspect_passes_the_guard(tmp_path):
40
+ """The can-fail proof: with --aspect explicit the guard stands down, and
41
+ the same dummy paths now fail DOWNSTREAM (loading state) without the
42
+ ANDON text - so the guard, not an import error, produced T3's refusal.
43
+
44
+ HARDENED at T18, having been measured passing for the wrong reason: under
45
+ an interpreter without open3d this control PASSED, because a
46
+ ModuleNotFoundError satisfies both "exits non-zero" and "carries no ANDON
47
+ text" - a check that cannot fail, sitting inside the control that exists
48
+ to prove another check CAN. It was the eighth open3d-touching test in the
49
+ 7-failed/20-passed run and the reason that count is 7 and not 8. T18's
50
+ session refusal makes the state unreachable; this asserts the reason
51
+ directly as well, because the repo's rule is to fix a root cause at every
52
+ consumer rather than only where it was noticed.
53
+ """
54
+ state = tmp_path / "no_such_state"
55
+ prep = tmp_path / "no_such_prep"
56
+ rc, out, err = run_py(
57
+ "texpass_iter.py",
58
+ ["emit", "--state", state, "--prep", prep, "--aspect", "752,1024"])
59
+ assert rc != 0 # dummy paths cannot load
60
+ text = out + err
61
+ assert "E14 Ruling 29c" not in text, (
62
+ "the guard fired despite an explicit --aspect - the legacy path is gone:\n%s"
63
+ % text)
64
+ assert "ModuleNotFoundError" not in text and "ImportError" not in text, (
65
+ "this control passed on an import failure, not on the guard standing "
66
+ "down - the environment cannot drive the tool (see T18):\n%s" % text)
67
+ # it must have got far enough to fail on the ABSENT INPUTS, which is the
68
+ # only failure that proves the guard let it through
69
+ assert "FileNotFoundError" in text or "No such file" in text, (
70
+ "expected a missing-input failure downstream of the guard:\n%s" % text)
@@ -0,0 +1,65 @@
1
+ """T4 - document discovery and BOTH inverse guards, proven able to fail.
2
+
3
+ Source: E16-9 (kickoff documents are discovered, not listed - and the glob
4
+ found the two E15 dispatches the hardcoded list had lost); E15 Ruling 8b /
5
+ 9a's class for the ruling documents (a gate must test the operation's failure
6
+ mode - a list can show a listed file lost a row, never that a file was
7
+ missing from the list).
8
+
9
+ The synthetic miss is injected by E16-9's own method - a TRUNCATED discovered
10
+ list - never by writing a decoy .md into the shared working copy another
11
+ session builds from.
12
+ """
13
+ import pytest
14
+
15
+
16
+ def test_t04_discovery_covers_the_current_corpus(facet_index_mod):
17
+ m = facet_index_mod
18
+ rd = dict(
19
+ (rel, arc) for arc, rel in m.ruling_documents())
20
+ # known members, with the arc labels the derivation rule must preserve:
21
+ # E10-offsurface must NOT merge into E10 (the load-bearing strip rule)
22
+ assert rd.get("docs/experiments/E14-ruling.md") == "E14"
23
+ assert rd.get("docs/experiments/E12-ruling.md") == "E12"
24
+ assert rd.get("docs/experiments/E15-ruling.md") == "E15"
25
+ assert rd.get("docs/experiments/E10-offsurface-ruling.md") == "E10-offsurface"
26
+ hd = dict((rel, arc) for arc, rel in m.handoff_documents())
27
+ # the file the old list was missing (E16-9's finding), plus the arcs
28
+ # dispatched since - each arc keyed by leading E-number
29
+ assert hd.get("docs/experiments/E15-context-index-kickoff.md") == "E15"
30
+ assert hd.get("docs/experiments/E16-errands-kickoff.md") == "E16"
31
+ assert hd.get("docs/experiments/E17-harness-kickoff.md") == "E17"
32
+
33
+
34
+ def test_t04_ruling_doc_miss_fails_verify(facet_index_mod, built_db, monkeypatch, capsys):
35
+ """The rulings-side inverse guard lives inside verify (the orphans check):
36
+ rows indexed from a file the glob no longer discovers must FAIL the run."""
37
+ m = facet_index_mod
38
+ full = m.ruling_documents()
39
+ dropped = [(a, r) for a, r in full if r != "docs/experiments/E14-ruling.md"]
40
+ assert len(dropped) == len(full) - 1, "E14-ruling.md was not in the discovery set"
41
+ monkeypatch.setattr(m, "ruling_documents", lambda: dropped)
42
+ rc = m.verify(str(built_db))
43
+ out = capsys.readouterr().out
44
+ assert rc == 1, "verify returned %d on a synthetic undiscovered-file miss" % rc
45
+ assert "ROWS FROM UNDISCOVERED FILES" in out
46
+ assert "E14-ruling.md" in out, "the miss report does not name the dropped file"
47
+
48
+
49
+ def test_t04_handoff_guard_passes_on_the_real_set(facet_index_mod):
50
+ m = facet_index_mod
51
+ m.assert_no_undiscovered_handoffs(m.handoff_documents())
52
+
53
+
54
+ def test_t04_handoff_guard_fires_on_a_synthetic_miss(facet_index_mod):
55
+ """E16-9's demonstrated method verbatim: hand the guard a discovery list
56
+ missing a file that carries `## Session handoff` headers."""
57
+ m = facet_index_mod
58
+ full = m.handoff_documents()
59
+ target = "docs/experiments/E15-context-index-kickoff.md" # carries TWO headers
60
+ truncated = [(a, r) for a, r in full if r != target]
61
+ assert len(truncated) == len(full) - 1
62
+ with pytest.raises(AssertionError) as exc:
63
+ m.assert_no_undiscovered_handoffs(truncated)
64
+ msg = str(exc.value)
65
+ assert "ANDON" in msg and "E15-context-index-kickoff.md" in msg