softschema 0.9.0__tar.gz → 0.10.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 (74) hide show
  1. softschema-0.9.0/README.md → softschema-0.10.0/PKG-INFO +53 -0
  2. softschema-0.9.0/PKG-INFO → softschema-0.10.0/README.md +25 -28
  3. {softschema-0.9.0 → softschema-0.10.0}/docs/development.md +9 -5
  4. {softschema-0.9.0 → softschema-0.10.0}/docs/installation.md +34 -19
  5. softschema-0.10.0/docs/softschema-collection-design.md +199 -0
  6. {softschema-0.9.0 → softschema-0.10.0}/docs/softschema-guide.md +153 -20
  7. {softschema-0.9.0 → softschema-0.10.0}/docs/softschema-python-design.md +25 -11
  8. {softschema-0.9.0 → softschema-0.10.0}/docs/softschema-typescript-design.md +25 -6
  9. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/__init__.py +10 -0
  10. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/_portable.py +83 -20
  11. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/cli.py +80 -9
  12. softschema-0.10.0/packages/python/src/softschema/collection.py +521 -0
  13. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/conform.py +23 -10
  14. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/models.py +5 -1
  15. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/schema_view.py +36 -0
  16. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/validate.py +19 -2
  17. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_c_parser.py +297 -1
  18. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_cli.py +0 -43
  19. softschema-0.10.0/packages/python/tests/test_collection.py +221 -0
  20. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_core.py +4 -0
  21. softschema-0.10.0/packages/python/tests/test_doctor.py +231 -0
  22. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_metadata_rules.py +7 -1
  23. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_schema_view.py +20 -0
  24. {softschema-0.9.0 → softschema-0.10.0}/pyproject.toml +9 -5
  25. softschema-0.10.0/skills/softschema/SKILL.md +206 -0
  26. softschema-0.9.0/skills/softschema/SKILL.md +0 -161
  27. {softschema-0.9.0 → softschema-0.10.0}/.gitignore +0 -0
  28. {softschema-0.9.0 → softschema-0.10.0}/LICENSE +0 -0
  29. {softschema-0.9.0 → softschema-0.10.0}/docs/agent-repair.runbook.md +0 -0
  30. {softschema-0.9.0 → softschema-0.10.0}/docs/e2e-testing.runbook.md +0 -0
  31. {softschema-0.9.0 → softschema-0.10.0}/docs/publishing-npm.md +0 -0
  32. {softschema-0.9.0 → softschema-0.10.0}/docs/publishing.md +0 -0
  33. {softschema-0.9.0 → softschema-0.10.0}/docs/softschema-spec.md +0 -0
  34. {softschema-0.9.0 → softschema-0.10.0}/examples/__init__.py +0 -0
  35. {softschema-0.9.0 → softschema-0.10.0}/examples/movie_page/README.md +0 -0
  36. {softschema-0.9.0 → softschema-0.10.0}/examples/movie_page/__init__.py +0 -0
  37. {softschema-0.9.0 → softschema-0.10.0}/examples/movie_page/host_integration.py +0 -0
  38. {softschema-0.9.0 → softschema-0.10.0}/examples/movie_page/model.py +0 -0
  39. {softschema-0.9.0 → softschema-0.10.0}/examples/movie_page/movie-page.schema.yaml +0 -0
  40. {softschema-0.9.0 → softschema-0.10.0}/examples/movie_page/spirited-away.md +0 -0
  41. {softschema-0.9.0 → softschema-0.10.0}/examples/parity/__init__.py +0 -0
  42. {softschema-0.9.0 → softschema-0.10.0}/examples/parity/model.py +0 -0
  43. {softschema-0.9.0 → softschema-0.10.0}/examples/parity/parity.schema.yaml +0 -0
  44. {softschema-0.9.0 → softschema-0.10.0}/packages/python/README.md +0 -0
  45. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/_identity.py +0 -0
  46. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/canonicalize.py +0 -0
  47. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/compile.py +0 -0
  48. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/enforcement.py +0 -0
  49. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/errors.py +0 -0
  50. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/generate.py +0 -0
  51. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/pipeline.py +0 -0
  52. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/py.typed +0 -0
  53. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/registry.py +0 -0
  54. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/repair.py +0 -0
  55. {softschema-0.9.0 → softschema-0.10.0}/packages/python/src/softschema/soft_field.py +0 -0
  56. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/fixtures/execution_model.py +0 -0
  57. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_canonicalize.py +0 -0
  58. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_doc_topics_resolve.py +0 -0
  59. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_enforced_extras.py +0 -0
  60. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_enforcement_clarity.py +0 -0
  61. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_errors.py +0 -0
  62. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_generate.py +0 -0
  63. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_identity.py +0 -0
  64. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_json_fast_path.py +0 -0
  65. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_movie_page_example.py +0 -0
  66. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_parity.py +0 -0
  67. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_repair_conform.py +0 -0
  68. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_skill_mirror_drift.py +0 -0
  69. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_soft_field.py +0 -0
  70. {softschema-0.9.0 → softschema-0.10.0}/packages/python/tests/test_warning_codes.py +0 -0
  71. {softschema-0.9.0 → softschema-0.10.0}/packages/typescript/LICENSE +0 -0
  72. {softschema-0.9.0 → softschema-0.10.0}/packages/typescript/README.md +0 -0
  73. {softschema-0.9.0 → softschema-0.10.0}/tests/golden/README.md +0 -0
  74. {softschema-0.9.0 → softschema-0.10.0}/tests/vectors/README.md +0 -0
@@ -1,3 +1,31 @@
1
+ Metadata-Version: 2.4
2
+ Name: softschema
3
+ Version: 0.10.0
4
+ Summary: Gradual contracts for YAML data, with optional Markdown context
5
+ Project-URL: Homepage, https://github.com/jlevy/softschema
6
+ Project-URL: Repository, https://github.com/jlevy/softschema
7
+ Project-URL: Issues, https://github.com/jlevy/softschema/issues
8
+ Author: Joshua Levy
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: <4.0,>=3.11
22
+ Requires-Dist: frontmatter-format>=0.5.1
23
+ Requires-Dist: jsonschema>=4.20
24
+ Requires-Dist: pydantic>=2
25
+ Requires-Dist: ruamel-yaml!=0.19.0,>=0.18
26
+ Requires-Dist: strif>=3.1.0
27
+ Description-Content-Type: text/markdown
28
+
1
29
  # softschema
2
30
 
3
31
  `softschema` applies gradual contracts to YAML data.
@@ -347,6 +375,29 @@ so a document cannot silently redirect a host’s validation; a contract registe
347
375
  without a schema path lets self-describing documents bind themselves.
348
376
  See the [softschema Guide](docs/softschema-guide.md) for the full playbooks.
349
377
 
378
+ ## Performance
379
+
380
+ Write clean, readable YAML by default.
381
+ A document of tens of KB parses in milliseconds (up to about 50 ms in pure Python), and
382
+ starting the CLI (0.2–0.4 s installed, about 0.7 s through `uvx` and 1.3 s through
383
+ `npx`) costs more than reading the file.
384
+ The format matters only for megabytes parsed often, in a hot loop, CI over many files,
385
+ or a service:
386
+
387
+ | 1 MB of records | Python | TypeScript (Node or Bun) |
388
+ | --- | --- | --- |
389
+ | Block YAML | ~1 s with `ruamel.yaml.clib`, ~6 s without | ~0.7–1 s |
390
+ | JSON syntax (valid YAML) | ~75 ms | ~0.7–1 s |
391
+
392
+ Then, in order: write the data as JSON syntax (Python reads strict JSON with the
393
+ standard `json` module); keep tabs out of block YAML, which send a Python document from
394
+ the C parser to the slower pure one; in Python, install `ruamel.yaml.clib`, not
395
+ `ruamel.yaml[libyaml]` (`softschema doctor` should report `yaml parser: c-first`); and
396
+ validate many files in one process through the library rather than one CLI run per file.
397
+ Results are the same on every path; only speed changes.
398
+ The [guide](docs/softschema-guide.md#performance) has the measurements and exactly what
399
+ keeps a file on each fast path.
400
+
350
401
  ## Use as an Agent Skill
351
402
 
352
403
  Both packages ship the same [`SKILL.md`](https://agentskills.io) following the open
@@ -407,6 +458,8 @@ They release together under the same version number on PyPI and npm.
407
458
  playbooks.
408
459
  - [softschema Spec](docs/softschema-spec.md): the exact artifact format and validation
409
460
  rules.
461
+ - [Collection Design](docs/softschema-collection-design.md) describes file references,
462
+ optional lazy reads, and scanning and reconciliation for small and large collections.
410
463
  - [Movie Page Example](examples/movie_page/README.md): the complete example backing the
411
464
  snippets above.
412
465
  - [Installation](docs/installation.md): pinned vs zero-install, uv and Node setup.
@@ -1,31 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: softschema
3
- Version: 0.9.0
4
- Summary: Gradual contracts for YAML data, with optional Markdown context
5
- Project-URL: Homepage, https://github.com/jlevy/softschema
6
- Project-URL: Repository, https://github.com/jlevy/softschema
7
- Project-URL: Issues, https://github.com/jlevy/softschema/issues
8
- Author: Joshua Levy
9
- License-Expression: MIT
10
- License-File: LICENSE
11
- Classifier: Development Status :: 4 - Beta
12
- Classifier: Intended Audience :: Developers
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Programming Language :: Python
15
- Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Classifier: Programming Language :: Python :: 3.14
20
- Classifier: Typing :: Typed
21
- Requires-Python: <4.0,>=3.11
22
- Requires-Dist: frontmatter-format>=0.5.0
23
- Requires-Dist: jsonschema>=4.20
24
- Requires-Dist: pydantic>=2
25
- Requires-Dist: ruamel-yaml>=0.18
26
- Requires-Dist: strif>=3.1.0
27
- Description-Content-Type: text/markdown
28
-
29
1
  # softschema
30
2
 
31
3
  `softschema` applies gradual contracts to YAML data.
@@ -375,6 +347,29 @@ so a document cannot silently redirect a host’s validation; a contract registe
375
347
  without a schema path lets self-describing documents bind themselves.
376
348
  See the [softschema Guide](docs/softschema-guide.md) for the full playbooks.
377
349
 
350
+ ## Performance
351
+
352
+ Write clean, readable YAML by default.
353
+ A document of tens of KB parses in milliseconds (up to about 50 ms in pure Python), and
354
+ starting the CLI (0.2–0.4 s installed, about 0.7 s through `uvx` and 1.3 s through
355
+ `npx`) costs more than reading the file.
356
+ The format matters only for megabytes parsed often, in a hot loop, CI over many files,
357
+ or a service:
358
+
359
+ | 1 MB of records | Python | TypeScript (Node or Bun) |
360
+ | --- | --- | --- |
361
+ | Block YAML | ~1 s with `ruamel.yaml.clib`, ~6 s without | ~0.7–1 s |
362
+ | JSON syntax (valid YAML) | ~75 ms | ~0.7–1 s |
363
+
364
+ Then, in order: write the data as JSON syntax (Python reads strict JSON with the
365
+ standard `json` module); keep tabs out of block YAML, which send a Python document from
366
+ the C parser to the slower pure one; in Python, install `ruamel.yaml.clib`, not
367
+ `ruamel.yaml[libyaml]` (`softschema doctor` should report `yaml parser: c-first`); and
368
+ validate many files in one process through the library rather than one CLI run per file.
369
+ Results are the same on every path; only speed changes.
370
+ The [guide](docs/softschema-guide.md#performance) has the measurements and exactly what
371
+ keeps a file on each fast path.
372
+
378
373
  ## Use as an Agent Skill
379
374
 
380
375
  Both packages ship the same [`SKILL.md`](https://agentskills.io) following the open
@@ -435,6 +430,8 @@ They release together under the same version number on PyPI and npm.
435
430
  playbooks.
436
431
  - [softschema Spec](docs/softschema-spec.md): the exact artifact format and validation
437
432
  rules.
433
+ - [Collection Design](docs/softschema-collection-design.md) describes file references,
434
+ optional lazy reads, and scanning and reconciliation for small and large collections.
438
435
  - [Movie Page Example](examples/movie_page/README.md): the complete example backing the
439
436
  snippets above.
440
437
  - [Installation](docs/installation.md): pinned vs zero-install, uv and Node setup.
@@ -9,7 +9,7 @@ clean-environment checks CI cannot run—is codified in the
9
9
  Set up the repo (Python deps, Node tooling for hooks, and the git hooks themselves):
10
10
 
11
11
  ```bash
12
- make install # uv sync --all-extras + npm install (lefthook)
12
+ make install # uv sync --all-extras + npm install (lefthook) + bun install
13
13
  make hooks-install # install the lefthook pre-commit hooks
14
14
  ```
15
15
 
@@ -57,8 +57,9 @@ Hooks are managed by [lefthook](https://lefthook.dev) (`lefthook.yml`), installe
57
57
  `make hooks-install`. The `pre-commit` hook formats staged changes so commits stay
58
58
  clean:
59
59
 
60
- - **Markdown:** delegates to `make format` (pinned `flowmark-rs` and
61
- `softschema generate`); the single source of truth, the same command you run locally.
60
+ - **Markdown:** delegates to `make format` (pinned `flowmark-rs`, `softschema generate`,
61
+ and the skill-mirror install); the single source of truth, the same command you run
62
+ locally.
62
63
  - **Python:** `ruff format` and `ruff check --fix` on staged `*.py`.
63
64
  - **TypeScript:** `biome check --write` on staged files in `packages/typescript`.
64
65
 
@@ -247,7 +248,7 @@ The parity invariants, and where each is enforced:
247
248
  | Structurally equal JSON and exact stable human output | the shared golden corpus (run twice via `SOFTSCHEMA_IMPL`) |
248
249
  | Equal flag/command surface | per-impl and neutral golden scenarios |
249
250
  | Bundled docs/skill resolve from the package | the standalone test (`packages/typescript/test/standalone.test.ts`) |
250
- | Skill mirrors never go stale | the mirror drift test (`tests/test_skill_mirror_drift.py`) |
251
+ | Skill mirrors never go stale | the mirror drift tests (`packages/python/tests/test_skill_mirror_drift.py`, `packages/typescript/test/mirror-drift.test.ts`) |
251
252
 
252
253
  Semantic invariants that JSON Schema cannot express (Pydantic validators ↔ Zod
253
254
  refinements) are implementation-specific by design and tested per-language, not in the
@@ -270,7 +271,10 @@ through a different number of records, and normalizing the difference away would
270
271
  real information. Two cases ship today, both in the `engine_deviations` section of
271
272
  `tests/vectors/hardening.yaml`: `dependentSchemas` (ajv adds a closure record for a
272
273
  property that top-level `properties` already evaluated) and `anyOf` multiplicity (ajv
273
- reports each branch’s failure alongside the `anyOf`).
274
+ reports each branch’s failure alongside the `anyOf`). Execution and verdict differences
275
+ on degenerate schemas, such as a lone `if` or a `$dynamicRef` with no matching anchor,
276
+ are pinned the same way in the `engine_deviations` list of
277
+ `tests/vectors/validation-execution.yaml`; the spec lists them.
274
278
 
275
279
  The mechanism is deliberately not a tolerance.
276
280
  Each runtime asserts *its own* listed record set exactly, so:
@@ -36,25 +36,40 @@ npx softschema --help # resolves the local pinned copy
36
36
 
37
37
  ### Faster YAML Parsing in Python
38
38
 
39
- The Python implementation reads YAML with ruamel.yaml.
40
- Its C extension, `ruamel.yaml.clib`, is optional in ruamel.yaml 0.19, while the 0.18.x
41
- releases declare it as a dependency on CPython (0.18.10 below Python 3.13, 0.18.17 below
42
- 3.15), so an install that resolves to 0.18 gets it without asking.
43
- With the extension present, large YAML artifacts parse several times faster; a 0.19
44
- install adds it with `uv add --dev ruamel.yaml.clib`. Results do not change: softschema
45
- uses the C parser only where it reads a document exactly as the pure parser does, and
46
- the pure parser decides everything else.
47
- It also uses the C parser only for the libyaml build and ruamel releases it was checked
48
- against (libyaml 0.1.7 as bundled by `ruamel.yaml.clib` 0.2.8 through 0.2.15, with
49
- ruamel.yaml 0.18 and 0.19) and reads everything with the pure parser on any other
50
- combination. Install `ruamel.yaml.clib` itself (ruamel.yaml’s `oldlibyaml` extra), not
51
- the `libyaml` extra: that one installs `ruamel.yaml.clibz`, which ruamel.yaml 0.19 does
52
- not use, so softschema stays on the pure parser.
53
- A `uv tool install softschema` user adds the extension with `--with ruamel.yaml.clib`.
54
- `softschema.yaml_parser_mode()` returns `"c-first"` when the C parser is in use and
55
- `"pure"` otherwise, `softschema doctor` reports the same with the reason (not installed,
56
- another build or release, or turned off), and `SOFTSCHEMA_PURE_YAML=1` turns the C
57
- parser off.
39
+ The Python implementation reads YAML with ruamel.yaml, which can use an optional C
40
+ extension, `ruamel.yaml.clib`: a Cython wrapper around a lightly patched libyaml 0.1.7,
41
+ with prebuilt wheels for CPython 3.9–3.14 on Linux, macOS, and Windows.
42
+ ruamel.yaml 0.18 depended on it on CPython below a Python-version cap (below 3.13 for
43
+ 0.18.0–0.18.10, below 3.14 for 0.18.11–0.18.16, and below 3.15 for 0.18.17), so most
44
+ 0.18 releases install without it on Python 3.13 and 3.14. ruamel.yaml 0.19.0 depended on
45
+ `ruamel.yaml.clibz` instead, and since 0.19.1 the C extension is opt-in (the
46
+ `oldlibyaml` extra).
47
+ The newer `ruamel.yaml.clibz` is the same libyaml, compiled with Zig at install time and
48
+ published only as source; ruamel’s `YAML()` API does not use it, so it gives no speedup
49
+ here. softschema never reads with clibz, and requires ruamel.yaml 0.18 or later except
50
+ 0.19.0, the one release that builds clibz by default.
51
+
52
+ libyaml parses YAML 1.1 and pure ruamel YAML 1.2, so they disagree on some texts.
53
+ softschema gives libyaml only the texts on which the two were shown to agree, and reads
54
+ the rest, and anything libyaml rejects, with pure ruamel.
55
+ It uses libyaml only for clib’s libyaml 0.1.7 on ruamel.yaml 0.18–0.19, so results are
56
+ the same either way; only speed changes, several times faster on large documents (see
57
+ [Performance](softschema-guide.md#performance) in the guide).
58
+
59
+ To get the speedup, install `ruamel.yaml.clib` (`uv add ruamel.yaml.clib`, or
60
+ `--with ruamel.yaml.clib` for `uv tool install` and `uvx`), not `ruamel.yaml[libyaml]`:
61
+
62
+ ```bash
63
+ uv add ruamel.yaml.clib # in a project
64
+ uv tool install softschema --with ruamel.yaml.clib # persistent CLI
65
+ uvx --with ruamel.yaml.clib softschema@latest doctor # zero-install
66
+ ```
67
+
68
+ A bare `uvx softschema@latest` runs the pure parser.
69
+ `softschema.yaml_parser_mode()` returns `"c-first"` when libyaml is in use and `"pure"`
70
+ otherwise, `softschema doctor` reports the same with the reason (not installed, clibz
71
+ installed but unused, another build or release, or turned off), and
72
+ `SOFTSCHEMA_PURE_YAML=1` forces the pure parser.
58
73
 
59
74
  ## Zero-Install
60
75
 
@@ -0,0 +1,199 @@
1
+ # SoftSchema Collection Design
2
+
3
+ **Status:** The bounded eager scan is implemented in the collection API change.
4
+ The reference, streaming, and reconciliation APIs below are proposed.
5
+ Their names describe capabilities and are subject to implementation review.
6
+
7
+ A collection is a read-only view of a root and a discovery policy.
8
+ Its source files contain records and compiled schemas.
9
+ A notebook with ten records can load them in one call.
10
+ A table backed by many directories can identify files, catalog contracts, index selected
11
+ cells, and load a record on demand.
12
+ Each caller chooses how much data to inspect and how long to retain it.
13
+
14
+ ## References and Observations
15
+
16
+ | Concept | Minimum information | When it can be known |
17
+ | --- | --- | --- |
18
+ | Collection scope | Root identity and discovery policy, including an ignore-policy identity for refresh | At open |
19
+ | File candidate | Scope-relative normalized path, candidate kind, and observed file revision | From enumeration and file metadata |
20
+ | Record reference | Candidate locator plus the declared contract, profile, status, envelope, and optional schema pointer | After portable declaration inspection, or from a matching cached observation |
21
+ | Schema reference | Locator, declared contract if present, and canonical parsed schema identity | After schema inspection |
22
+ | Materialized record | Payload, requested host metadata and body, and any requested validation verdict and repair diagnostics | After reading the referenced revision and resolving the requested validation context |
23
+
24
+ A path identifies a location within its scope.
25
+ A rename is a removal and an addition at that level.
26
+ A business identifier such as a typed `id` lives in the payload.
27
+ A host can index it for links and check for duplicates.
28
+ A file revision describes which input was observed, and a binding revision records which
29
+ schema and selection rules determined a verdict.
30
+ A file stamp is a cheap cache key.
31
+ Use a content digest when a client requires exact byte identity.
32
+
33
+ Discovery can enumerate candidates without opening files.
34
+ Certifying collection membership requires enough of the portable reader to find and
35
+ check the declaration.
36
+ An unreadable file, a truncated declaration, or an exhausted read budget leaves
37
+ membership unknown. A file that was successfully inspected and had no declaration can be
38
+ reported as outside the SoftSchema record set.
39
+
40
+ Reading a reference can return the observed revision, `stale`, `gone`, or an input
41
+ diagnostic. A live filesystem can provide a newer observation after a change.
42
+ Reading an older version requires a host that retained those bytes.
43
+ Revision checks apply before and after reading, and resolution uses the same root
44
+ boundary and symlink policy as the scan.
45
+
46
+ ## Optional Library Operations
47
+
48
+ | Operation | Result | Work the caller opts into |
49
+ | --- | --- | --- |
50
+ | Open a collection | A handle defining root, discovery policy, and bounds | Resolve the scope |
51
+ | Enumerate candidates | A stream of file references and terminal coverage | List and stat files |
52
+ | Inspect a declaration or schema | A record or schema reference, absence, an unknown result, or a diagnostic | Inspect selected files without retaining their values |
53
+ | Load a record | A payload and requested host metadata or body | Open and parse one referenced revision |
54
+ | Bind, validate, or repair | Schema selection, execution, verdict, and optional in-memory repairs | Apply the compiled schema to one payload |
55
+ | Scan and reconcile | Observations and a revisioned set of input changes | Compare covered observations with optional prior state |
56
+ | Eager scan | Records, schemas, summary, and runtime-local refresh state | Collect and validate a bounded tree in memory |
57
+
58
+ Hosts can take a simple path through these operations.
59
+ A CLI audit can consume observations and retain only counts and problem paths.
60
+ An inspector can list references and load one on activation.
61
+ A table indexer can inspect the schema catalog, stream record payloads through a
62
+ projection, and drop each payload as soon as its cells and links have been indexed.
63
+
64
+ The eager Python `scan_collection` and TypeScript `scanCollection` calls already provide
65
+ the last row of the table above.
66
+ They return parsed payloads and bodies and can retain them for refresh.
67
+ Their entry, per-file, and aggregate-byte limits protect the bounded call.
68
+ The independently callable operations and the streaming implementation are follow-up
69
+ work. They should reuse the same portable readers, binding rules, and validation states.
70
+ [Current collection usage](softschema-guide.md#inspecting-a-collection)
71
+
72
+ ## Scanning and Reconciliation
73
+
74
+ Scanning observes files under a scope.
75
+ Reconciliation compares those observations against a previously committed index for the
76
+ same scope. A scan can stream in filesystem order with bounded buffering, cancellation,
77
+ and backpressure from its consumer.
78
+ Sorting a complete catalog requires retaining references or using an external sort.
79
+ User-facing stable pagination belongs on a committed index generation.
80
+
81
+ Track directory-listing coverage, declaration-inspection coverage, and schema discovery
82
+ coverage independently.
83
+ A completed directory listing can establish a known file’s removal even if the
84
+ payload-read budget is exhausted.
85
+ An unreadable subtree leaves files previously known under that subtree unresolved.
86
+ Cancellation, early iterator exit, and interrupted walks leave the prior membership
87
+ available.
88
+ The host can stage observations and commit updates for a scope after observing
89
+ its terminal coverage.
90
+ A cap reached before terminal coverage produces a reason and the affected scope.
91
+
92
+ Report file additions, changes, and removals separately from record or verdict updates.
93
+ A schema edit can change many verdicts even when every record file is unchanged.
94
+ A new same-contract schema can invalidate a previously unique fallback.
95
+ A host that persists outcomes should key them on the input revision, the binding context
96
+ and selected schema, and the validation policy.
97
+ A host that wants to reconform without reopening a file needs the original input or its
98
+ relevant scalar spellings, since conformance can depend on how the source represented a
99
+ value.
100
+
101
+ An observed usable pointer can bind once its target has been inspected.
102
+ Unique fallback requires a closed schema catalog for the applicable scope.
103
+ A typed or bound verdict that depends on an open catalog remains pending.
104
+ An unreadable ordinary record does not by itself invalidate completed schema discovery.
105
+ A host that needs final verdicts as rows stream can catalog schemas first and defer
106
+ record work. A single traversal can stage candidates and resolve deferred bindings once
107
+ catalog coverage closes.
108
+
109
+ ## What Tables Need
110
+
111
+ A table needs a stable row locator, a full contract identity for grouping, and the
112
+ compiled field description for columns.
113
+ An initial file inventory can return only references and catalog information.
114
+ Showing cell values requires a payload read or an existing projection of that revision.
115
+
116
+ For a small collection, the host can hold the references and whichever values it wants
117
+ to display. For a large collection, the host can keep a disk-backed projection of
118
+ selected cells, labels, source paths, and diagnostics.
119
+ Filtering and ordering across an entire table may require examining every relevant row,
120
+ even when the page itself is small.
121
+ Build the projection incrementally and serve pages from a stable generation.
122
+ Fetch complete values and Markdown prose for record detail on demand.
123
+
124
+ Linked tables can add a host index from a typed target ID to its matching row locations
125
+ and an index from a source row and field to its target ID. This supports forward links
126
+ and backlinks without loading all payloads.
127
+ Report duplicate targets explicitly.
128
+ An incomplete index has unknown coverage for omitted links and counts.
129
+ A table’s visible folder can be narrower than the scope used for link resolution.
130
+ The host owns the projection, link policy, persistence, query semantics, and UI.
131
+
132
+ ## Schema Discovery Conventions
133
+
134
+ The default collection policy discovers `.schema.json`, `.schema.yaml`, and
135
+ `.schema.yml` files throughout the root.
136
+ Retaining all three suffixes lets the same scan work with existing compiled YAML schemas
137
+ and machine-generated JSON schemas.
138
+
139
+ A host that controls the tree can put compiled schemas in a dedicated directory such as
140
+ `_schemas/` and use an optional catalog policy to restrict fallback discovery to that
141
+ directory and its chosen suffixes.
142
+ A JSON-only catalog is one such policy.
143
+ Its closed coverage means all candidates under the configured catalog were examined.
144
+ An explicit relative schema pointer can still be resolved safely inside the collection
145
+ root and checked for contract compatibility, even outside the fallback catalog.
146
+ Catalog policy and its identity belong in the refresh scope.
147
+
148
+ Schema-first discovery exposes known contracts and column definitions early.
149
+ The presence of a schema gives the host a known contract to present.
150
+ Record discovery still reads declarations, including declarations whose schema is absent
151
+ or unresolved. An application can use an explicit configuration or a catalog hit to show
152
+ a collection entry point before opening record payloads.
153
+
154
+ ## Formats and Performance
155
+
156
+ - **Markdown with YAML frontmatter.** Inspect through the closing fence for declarations
157
+ and frontmatter fields.
158
+ A header-only request leaves body decoding unverified.
159
+ Preserve the existing fence, source offset, and line ending rules.
160
+ A fenceless file can still be a pure-YAML artifact under the profile rules.
161
+ - **Pure YAML.** Declaration keys and values can appear anywhere in a mapping.
162
+ Inspection may require processing the whole artifact.
163
+ Parsing one bounded file and discarding its payload still keeps memory independent of
164
+ the number of files.
165
+ - **JSON.** JSON uses the pure-YAML profile today.
166
+ A native JSON fast path is an implementation option for that profile if it preserves
167
+ its portable restrictions, including duplicate keys, safe numbers, and structural
168
+ limits. A suffix alone neither authenticates the declaration nor narrows accepted
169
+ syntax. An explicitly strict JSON source could be a separate host choice if measured
170
+ gains justify it.
171
+
172
+ The declaration detector looks for a root `softschema` key in bare YAML or JSON, or in
173
+ the opening fenced metadata block of Markdown.
174
+ A JSON object written inside the fence is a YAML flow mapping and follows the same
175
+ frontmatter rules. Escaped keys, quoted keys, and late properties can carry real
176
+ declarations. A nested key, a body mention, or a substring in a value does not establish
177
+ membership. A lexical check can skip content only when it can prove that the declaration
178
+ is absent. The portable reader confirms membership and reports malformed declarations.
179
+
180
+ Bound retained state separately from total work.
181
+ A stream can limit outstanding bytes, per-file parsing, and concurrent reads while
182
+ continuing through a large tree.
183
+ Consumers may retain all references when that is practical, or write them to a
184
+ disk-backed sink. A limit or cancellation must leave explicit coverage, so consumers can
185
+ tell a partial result from a complete one.
186
+
187
+ Before treating the streaming path as large-directory support, measure incremental
188
+ results on a large flat directory and a deep mixed tree.
189
+ Include JSON, frontmatter, large unread Markdown bodies, and schema-only edits.
190
+ Record time to first reference and first table page, aggregate bytes read, peak memory,
191
+ index size, and cold and warm refresh time.
192
+ Compare streamed complete membership, bindings, and verdicts with the eager result where
193
+ both fit the bounds.
194
+ Exercise unreadable scopes, cancellation, renames and deletes, declaration and schema
195
+ changes, and optional native parsers on the same fixtures in both runtimes.
196
+
197
+ <!-- This document follows common-doc-guidelines.md.
198
+ See github.com/jlevy/practical-prose and review guidelines before editing.
199
+ -->