292 lines
17 KiB
Markdown
292 lines
17 KiB
Markdown
# Shared glossary and Audita adoption review
|
|
|
|
Reviewed Narratio commit `4f27331636b44bd75e402c12fc6ab4c16fcb3899`
|
|
against all 19 stages of [implementation.md](implementation.md) and the
|
|
[feature roadmap](audita.md). The catalog checkout was
|
|
`ff26b24172ff5efddbcf666c5179268ea1372b01`; its embedded schema source is
|
|
`ecad94a5a53f87847b1fd81fd042eee9c8d3ea08`. Native compatibility was checked
|
|
with Audita v4.2.0 at `973b24e46618dc785751fa7c803e7c16c900353f`.
|
|
|
|
This document records required remediations and separately identified algorithmic
|
|
improvements for consideration. Implementation code and upstream repositories
|
|
were left unchanged during review.
|
|
|
|
## 1. Reject empty paths for explicitly selected catalog entries
|
|
|
|
Priority: P2
|
|
|
|
Status: Complete
|
|
|
|
Selected blank catalog paths now fail with kind/ID context. Acquisition and
|
|
prepare-only regression tests cover empty/null values in both catalog groups
|
|
and successful empty roles with unused empty or uninstalled entries. Focused
|
|
configuration and application tests passed with Go 1.27.4.
|
|
|
|
Affected stages: 3 and 5; prepare and downstream vocabulary coverage are affected.
|
|
|
|
### Finding
|
|
|
|
`internal/config/reference_catalog.go:19-23` distinguishes unknown IDs from
|
|
known IDs, but returns a known entry's value without checking whether it names
|
|
a source. For example:
|
|
|
|
```yaml
|
|
reference_catalog:
|
|
settings:
|
|
broken: ""
|
|
```
|
|
|
|
A campaign selecting `inputs.setting: broken` passes combined acquisition.
|
|
The empty path then reaches `internal/glossary/resolve.go:73-74`, which treats
|
|
it like an omitted setting and prepares an empty collection. An explicit null
|
|
catalog path, by contrast, already fails native decoding with `decode.null`;
|
|
retain that correct behavior.
|
|
|
|
The CLI reproduction used ordinary valid campaign/session inputs and a
|
|
prepare-only invocation. It exited zero with `complete: true` and wrote:
|
|
|
|
```yaml
|
|
setting:
|
|
entries: []
|
|
```
|
|
|
|
This contradicts the selected-source contract: omitted selections may be empty,
|
|
while explicitly selected invalid sources must fail. It can silently remove
|
|
expected correction vocabulary, particularly because all four runtime lists
|
|
replace their same-named Audita lists.
|
|
|
|
### Required remediation
|
|
|
|
Reject a selected catalog entry whose value does not identify a usable source,
|
|
with context naming the catalog kind and selected ID. Preserve ordinary source
|
|
loading errors for nonempty nonexistent or unreadable paths. Keep an omitted
|
|
setting/system selection valid, and do not impose eager file-existence checks
|
|
on unselected catalog entries.
|
|
|
|
Add behavioral coverage through full configuration acquisition and preparation
|
|
for selected empty and null paths in both catalog groups. Verify that invalid
|
|
selection cannot become successful empty vocabulary, while omitted selections
|
|
still prepare empty roles. Cover native decoding rejection as an acceptable
|
|
outcome where the selected value is invalid before domain selection.
|
|
|
|
## 2. Preserve native acceptance of a null aliases list
|
|
|
|
Priority: P2
|
|
|
|
Status: Complete
|
|
|
|
Catalog commit `a1a87edafd59a1de545a1c0b4efe5feeb80348e0` corrects
|
|
the canonical schema and format description. Narratio pins its verbatim copy
|
|
and updated notices. File/inline preparation tests preserve omitted, null, empty,
|
|
and populated aliases; schema tests retain invalid-type/null-scalar rejection.
|
|
Focused tests and controlled real-Audita/catalog compatibility checks passed
|
|
with Go 1.27.4, including native inspection/preflight with null aliases.
|
|
|
|
Affected stages: 1, 2, and 5. This is an inadvertently strengthened input
|
|
restriction in the shared schema and its embedded copy.
|
|
|
|
### Finding
|
|
|
|
The catalog schema and `internal/glossary/glossary-v1.schema.json:30-36`
|
|
require `aliases` to be an array whenever supplied. Audita v4.2 accepts an
|
|
explicit null aliases list through its native typed configuration, so valid
|
|
native glossary input is rejected by Narratio's new shared format validator.
|
|
|
|
This minimal glossary was used for the comparison:
|
|
|
|
```yaml
|
|
campaign:
|
|
entries:
|
|
- id: watch
|
|
name: Silver Watch
|
|
category: organization
|
|
aliases: null
|
|
```
|
|
|
|
With a valid Audita main configuration:
|
|
|
|
```sh
|
|
audita config validate --scope app --config MAIN --glossary-file VOCABULARY
|
|
```
|
|
|
|
returned `app: valid` and exit zero. Selecting the same file as Narratio's
|
|
campaign glossary made `prepare` fail with:
|
|
|
|
```text
|
|
at '/campaign/entries/0/aliases': got null, want array
|
|
```
|
|
|
|
The requested format follows native Audita fields and preserves supported
|
|
presence semantics. A blanket non-null restriction on optional aliases was
|
|
not selected. This finding is specific to aliases: the same probe confirmed
|
|
that Audita rejects null `instruction` and `description` strings, so those
|
|
fields must not be broadened merely by analogy.
|
|
|
|
### Required remediation
|
|
|
|
Correct the catalog-owned schema to accept the supported null aliases value
|
|
alongside its existing array shape. Update the embedded schema verbatim, its
|
|
recorded catalog revision, applicable notices, and the canonical format
|
|
description as needed. Keep the schema locally pinned and preserve the normal
|
|
native handoff; no compatibility parser or custom alias-merging rule is needed.
|
|
|
|
Test omitted, null, empty, and populated aliases through resolved file and
|
|
inline vocabulary and preparation. Include the null case in the controlled
|
|
native Audita compatibility check. Retain rejection of genuinely invalid alias
|
|
types and upstream-invalid null scalar fields. Default tests remain offline.
|
|
|
|
## 3. Index prepared-input records for resume comparison
|
|
|
|
Priority: P3
|
|
|
|
Status: Pending consideration
|
|
|
|
Affected stage: 8. This is an inherited algorithm extended by the glossary
|
|
cutover, rather than a newly introduced regression.
|
|
|
|
### Finding and complexity
|
|
|
|
`internal/stage/prepare_resume.go:254-269` scans every manifest input for each
|
|
expected input. The `matched` map prevents a record from being consumed twice,
|
|
but the inner loop still visits every record, including after finding a match.
|
|
For E expected inputs and M manifest inputs, successful matching performs
|
|
Theta(E*M) record visits. With N audio files, both lists grow with N, giving
|
|
Theta(N^2) matching work, separately from file hashing and vocabulary resolution.
|
|
The existing count checks do not eliminate this successful-case cost.
|
|
|
|
The sprint added four glossary kinds and normalized configuration-snapshot
|
|
comparison to this path. Neither the roadmap nor Stage 8 selects the nested
|
|
matching algorithm as a requirement. Ordinary D&D sessions may have few audio
|
|
files; this is a scalability and simplification opportunity, not evidence of a
|
|
measured production bottleneck or incorrect resume decisions.
|
|
|
|
### Potential refactoring
|
|
|
|
Build a single index using the existing matching identity: kind, with the
|
|
destination basename for audio records. Retain record multiplicity explicitly
|
|
and compare checksums, normalized snapshots, or remote object identity within
|
|
the appropriate entry. Managed-kind cardinality and ambiguity checks can remain
|
|
linear. The intended result is expected O(E+M) matching time with O(E+M)
|
|
auxiliary space; the current matcher already allocates O(E) consumed-record state.
|
|
String normalization and file-content processing remain additional costs.
|
|
|
|
Preserve rejection of missing, extra managed, ambiguous, and reused records;
|
|
a map assignment that silently overwrites duplicates would change behavior.
|
|
Preserve case-insensitive checksum comparison and the existing remote-audio
|
|
identity fields. Retain representative local/remote and snapshot cases, and add
|
|
synthetic reordered/duplicate-record coverage when making this refactor. A
|
|
benchmark or a real audio workload is unnecessary to establish the complexity.
|
|
|
|
## 4. Validate report bounds without buffering discarded contents
|
|
|
|
Priority: P3
|
|
|
|
Status: Pending consideration
|
|
|
|
Affected stages: 10 and 11, principally the new polish-stage report check.
|
|
|
|
### Finding and complexity
|
|
|
|
`internal/adapters/audita/subprocess.go` reads each discovered report with
|
|
`fileops.ReadFileBounded` and discards the returned bytes. The new check at
|
|
`internal/stage/polish.go:115-117` repeats that operation. The helper uses
|
|
`io.ReadAll(io.LimitReader(...))` in `internal/fileops/read_bounded.go`.
|
|
Neither caller parses or retains report content; they retain only its path.
|
|
|
|
For a report of B bytes within the existing limit L, each validation performs
|
|
O(B) I/O and O(B) temporary allocation. An oversized report can allocate O(L)
|
|
before rejection. The normal subprocess path performs two such reads. These
|
|
are fixed linear passes, not quadratic work, and the existing 16 MiB per-report
|
|
cap already bounds their memory exposure.
|
|
|
|
### Potential refactoring
|
|
|
|
Use a small shared bounded-file validation helper that retains the existing
|
|
regular/readable-file and path checks while streaming at most L+1 bytes to
|
|
`io.Discard`. This preserves read-error detection and limit enforcement with
|
|
O(B) time and O(1) auxiliary memory relative to report length. It can replace
|
|
the discarded-content reads at both boundaries without weakening stage-side
|
|
validation of another runner implementation. A broader file-operations
|
|
abstraction or cross-boundary validation cache is unnecessary.
|
|
|
|
Keep the limit in its existing central constant, preserve optional-report and
|
|
nonzero-exit behavior, and retain errors identifying the responsible Audita
|
|
boundary and limit. Test below/at/above-limit files and existing invalid-file
|
|
cases when implementing the helper. Content-consuming bounded reads elsewhere
|
|
are outside this finding.
|
|
|
|
## Stage-by-stage review coverage
|
|
|
|
| Stage | Evidence examined and result |
|
|
| --- | --- |
|
|
| 1 | Catalog format/schema, minimal relative-import bundle, examples, CC0 grant, and check script. Finding 2 affects the native format match. |
|
|
| 2 | Local schema compilation, offline loader, partial/complete validation, extension retention, and collection-scoped identity checks. Finding 2 affects accepted aliases. |
|
|
| 3 | Native pipeline catalog acquisition, source-origin path adaptation, lookup behavior, and imported catalog tests. Finding 1 affects selected values. |
|
|
| 4 | Independent campaign/session defaults, pointer/null handling, inline replacement, native-result preservation, and snapshot rendering tests. No additional actionable finding. |
|
|
| 5 | Native layered resolution, imports/sibling inheritance, whole-record upsert/replacement, party projection, deterministic output, and selection errors. Findings 1 and 2 surface here. |
|
|
| 6 | Four descriptors/paths, manifest-backed resolution, retired-source rejection, and unchanged roster/player/spell-overlay identities. No additional actionable finding. |
|
|
| 7 | Preparation writes, input sizes/digests/provenance, workspace modes, empty roles, and failure handling. Finding 1 can incorrectly yield empty selected vocabulary. |
|
|
| 8 | Versioned prepare evidence, effective-content comparison, source relocation, imported changes, and missing/tampered prepared records. No additional actionable finding. |
|
|
| 9 | Verified prepared-input archival, nested remote/local mapping, manifest-last restore, and round-trip tests. No additional actionable finding. |
|
|
| 10 | Native arguments, removed module surface, independent report/debug paths, credential handling, and omission semantics. No additional actionable finding. |
|
|
| 11 | Shared polish request construction, four-input evidence, resume metadata, report bounds/paths, and transcript promotion failures. No additional actionable finding. |
|
|
| 12 | Embedded synthetic transcript, native preflight arguments, isolated temporary captures, cleanup, redaction, and cancellation. No additional actionable finding. |
|
|
| 13 | Selected Audita/Scriptorium checks, native error propagation, existing prompt findings, and empty/cancelled checks. No additional actionable finding. |
|
|
| 14 | Post-prepare reprojection, lazy adapter composition, bounded runs, force/failure authority, preparation reuse, and fully reused invocations. No additional actionable finding. |
|
|
| 15 | Validation against existing prepared evidence, probe namespace, provider side effects, source independence, and unchanged manifest tests. No additional actionable finding. |
|
|
| 16 | Explicit consumer source changes, maintained native authoring/catalog examples, and retired-field tests. No additional actionable finding. |
|
|
| 17 | Real catalog acquisition/preparation and controlled native Audita inspection/preflight checks. Checks pass, but did not cover Findings 1 and 2. |
|
|
| 18 | Public/internal integration, configuration, migration, lifecycle, and attribution updates. Schema documentation needs coordination for Finding 2. |
|
|
| 19 | Full tests/race tests, vet/build, native compatibility, recovery round trip, and cutover review. Checks pass; the two reproduced edge cases still require remediation. |
|
|
|
|
## Verification performed
|
|
|
|
- `go test ./...` and `go test -race ./...` passed with Go 1.27.4.
|
|
- `go vet ./...` and `go build ./...` passed.
|
|
- Opt-in `TestReferenceCatalogCompatibility` and `TestAuditaBinaryCompatibility`
|
|
passed against the actual catalog and a fresh Audita v4.2 build. Provider
|
|
requests used a controlled loopback server, not paid services.
|
|
- The embedded schema matches the catalog schema byte for byte.
|
|
- CLI probes independently reproduced both findings using temporary synthetic
|
|
data. Native Audita acceptance of null aliases was checked directly.
|
|
|
|
Automatic provider checks, synthetic-transcript feasibility errors, all-four-role
|
|
runtime authority, and the clean source/format cutover are explicit user-selected
|
|
scope. They are not findings or reasons to restore the earlier behavior.
|
|
|
|
## Algorithmic review coverage
|
|
|
|
The follow-up review used Narratio `54ba768a28eee317985b0be4bb284d5f77ff00f1`
|
|
and the same implementation and catalog revisions described above. Findings 1
|
|
and 2 remain pending; Findings 3 and 4 are lower-priority refactoring opportunities.
|
|
No additional ordinary correctness bug was found in this pass.
|
|
|
|
| Stage | Algorithmic assessment |
|
|
| --- | --- |
|
|
| 1 | Reviewed the catalog schema and offline check script. Neither adds a pairwise entry comparison or runtime catalog traversal. |
|
|
| 2 | Schema compilation uses `sync.Once`; collection ID uniqueness uses a hash set. JSON conversion and validation traverse the data. |
|
|
| 3 | Catalog path adaptation traverses sorted IDs; selection is a map lookup. No eager vocabulary-file loading was added. |
|
|
| 4 | Campaign/session selection visits a fixed set of fields. Native composition remains ConfigKit-owned. |
|
|
| 5 | Party sorting is explicitly prescribed. Vocabulary uses native composition, hash-based duplicate checks, and deterministic serialization; those selected algorithms were retained. |
|
|
| 6 | Four descriptors are fixed-size. Each prepared-input lookup scans manifest inputs and streams its file digest; four lookups remain linear in manifest size and total bytes. |
|
|
| 7 | Preparation materializes four documents using existing change detection and deterministic record ordering. No growing cross-product of glossary entries is added. |
|
|
| 8 | Finding 3 identifies quadratic record matching in the extended resume path. Effective vocabulary comparison and content hashing are explicit design choices. |
|
|
| 9 | Publication adds a fixed four verified input kinds; archival streams file contents. Restore uses a fixed-size descriptor lookup per object. |
|
|
| 10 | Argument construction visits the supplied files; report discovery checks three fixed names. Finding 4 covers discarded-content buffering. |
|
|
| 11 | Glossary evidence covers four files and a fixed-size digest input. Finding 4 covers the additional whole-report read. |
|
|
| 12 | Synthetic transcript size is fixed. Preflight uses one native invocation and invocation-scoped temporary files. |
|
|
| 13 | Sequential downstream checks are explicitly selected. Requirement processing uses map lookups rather than comparing every requirement with every binding. |
|
|
| 14 | The runner performs one post-preparation reprojection over the fixed canonical stage set; the new hook does not repeat it before every stage. |
|
|
| 15 | Validation loads one manifest and resolves four prepared documents; it does not resolve live vocabulary or run preparation. |
|
|
| 16 | Consumer binding changes use existing resolvers. Examples and source-ID rejection add no new growing algorithm. |
|
|
| 17 | Compatibility checks use explicit local inputs and controlled providers. Catalog fixture copying visits each file once. |
|
|
| 18 | Documentation changes add no runtime algorithm. |
|
|
| 19 | Reviewed the assembled paths and focused recovery tests. No additional asymptotic issue was identified in the newly added orchestration. |
|
|
|
|
Focused glossary, configuration, artifact-policy, artifacts, stage, preflight,
|
|
Audita-adapter, and application tests passed with Go 1.27.4. Complexity findings
|
|
come from the implemented loops and allocation paths; no real-world performance
|
|
measurements or paid provider calls were used. The proposed refactorings retain
|
|
native ConfigKit semantics, required ordering, content verification, and the
|
|
selected preflight policy.
|