Consolidate the architecture plan into fewer packages
This commit is contained in:
@@ -22,7 +22,7 @@ in core framework packages.
|
||||
|
||||
The application should follow the same broad architecture as Audita:
|
||||
|
||||
- deterministic core packages for config, source documents, artifacts, diagnostics, and reporting;
|
||||
- deterministic core packages for source documents, artifacts, and configuration once needed;
|
||||
- input-stage modules that translate external source formats into a small internal source model;
|
||||
- reusable framework packages for contracts, orchestration, LLM runtime, structured output, and validation;
|
||||
- independent extract-stage modules that own domain-specific behavior;
|
||||
@@ -48,28 +48,14 @@ artifacts rather than proposing and applying transcript corrections.
|
||||
cmd/notarius
|
||||
internal/cli
|
||||
|
||||
internal/core/config
|
||||
internal/core/source
|
||||
internal/core/sourcechunking
|
||||
internal/core/artifacts
|
||||
internal/core/diagnostics
|
||||
internal/core/reporting
|
||||
internal/core/extractorcatalog
|
||||
internal/core/inputcatalog
|
||||
|
||||
internal/framework/contracts
|
||||
internal/framework/extraction
|
||||
internal/framework/runner
|
||||
internal/framework/pipeline
|
||||
internal/framework/merge
|
||||
internal/framework/normalize
|
||||
internal/framework/output
|
||||
internal/framework/validators
|
||||
internal/framework/validate
|
||||
internal/framework/llm
|
||||
internal/framework/responseschema
|
||||
internal/framework/structuredoutput
|
||||
internal/framework/promptcontext
|
||||
internal/framework/warnings
|
||||
internal/framework/prompt
|
||||
|
||||
internal/modules/input/seriatim
|
||||
internal/modules/input/markdown
|
||||
@@ -95,7 +81,6 @@ internal/validators/schema_validity
|
||||
internal/validators/domain_consistency
|
||||
internal/validators/llm_review
|
||||
|
||||
internal/prompts
|
||||
examples
|
||||
docs/internal
|
||||
```
|
||||
@@ -104,6 +89,15 @@ The `markdown` input module and D&D-specific chunk, merge, normalize, and
|
||||
output modules are listed as likely future packages. The MVP should implement
|
||||
only the stage modules needed by the checkpoint sequence.
|
||||
|
||||
`internal/core/config` should be added when production configuration exists.
|
||||
|
||||
The framework package list is intentionally consolidated. `pipeline` should own
|
||||
runner orchestration, stage registries, and small merge/normalize/output helpers
|
||||
until those boundaries prove they need separate packages. `llm` should own
|
||||
structured output and response-schema mechanics until those concerns become too
|
||||
large or import-heavy. `prompt` should own prompt assets and rendering helpers
|
||||
once prompt assets exist.
|
||||
|
||||
## Core Concepts
|
||||
|
||||
### SourceDocument
|
||||
@@ -138,6 +132,13 @@ Initial source-unit assumptions:
|
||||
- adapter-specific metadata may carry speaker, timestamps, heading paths, page
|
||||
numbers, or other source details.
|
||||
|
||||
Core source metadata should remain `map[string]any`. Notarius should not define
|
||||
a universal document model. Instead, the project should document well-known
|
||||
metadata keys, such as `speaker`, `start`, `end`, and `heading_path`, as
|
||||
conventions. Input modules may export typed accessor helpers for their own
|
||||
metadata, such as `seriatim.SpeakerOf(unit)`, without leaking those helpers into
|
||||
core framework contracts.
|
||||
|
||||
### Input Module / Adapter Contract
|
||||
|
||||
Hexagonal boundary for external source formats.
|
||||
@@ -183,6 +184,11 @@ Initial source-reference validation should require:
|
||||
Transcript-oriented output can still present these as transcript segment ranges
|
||||
when the adapter metadata makes that interpretation available.
|
||||
|
||||
Source references should preserve the exact ranges produced by extractors and
|
||||
validators. Overlapping ranges should not be merged or rewritten by generic
|
||||
pipeline code. If a domain module wants a derived compact range later, that
|
||||
should be additional output, not a replacement for the original evidence.
|
||||
|
||||
### Extractor
|
||||
|
||||
Reusable module contract for producing one artifact type.
|
||||
@@ -201,6 +207,13 @@ An extractor should receive either a whole source document or a source chunk,
|
||||
depending on processing mode. It should return typed artifact candidates plus
|
||||
warnings. It should not mutate the source document.
|
||||
|
||||
`ExtractionRequest` should be designed now to carry both the active chunk and
|
||||
optional ambient context, even if the MVP leaves that context empty. Useful
|
||||
ambient context may include a document synopsis, prior-chunk summaries, known
|
||||
entities, or other module-provided state. D&D spell extraction can likely work
|
||||
per chunk, but combat, NPC, and identity-oriented extraction will need broader
|
||||
context. Adding the field later would force churn across every extractor.
|
||||
|
||||
Extract modules own domain concepts. For example, D&D spell extraction should
|
||||
live under `internal/modules/extract/dnd/spells`; a future to-do extractor for
|
||||
notes should live under a different extract-module path and use the same
|
||||
@@ -247,14 +260,41 @@ Validators should cover:
|
||||
Validator output should follow Audita's decision-cardinality model: each
|
||||
candidate artifact receives exactly one decision per validator.
|
||||
|
||||
LLM-backed review should be modeled as part of a module's validator chain, not
|
||||
as a separate global review phase. Extract modules should be able to attach one
|
||||
or more deterministic or LLM-backed validators. Normalize-stage modules may also
|
||||
run validator chains, including LLM-backed validators, when semantic
|
||||
reconciliation needs review.
|
||||
|
||||
### Artifact
|
||||
|
||||
Final approved JSON output from one or more extractors.
|
||||
|
||||
Artifacts should preserve enough metadata to support downstream validation,
|
||||
debugging, and replay. The exact top-level envelope is still open, but should
|
||||
include artifact type, schema version, extracted records, source references, and
|
||||
run manifest data.
|
||||
debugging, and replay.
|
||||
|
||||
The pipeline should carry artifact candidates through a generic envelope with a
|
||||
`json.RawMessage` payload. Extract modules should own typed Go structs at their
|
||||
module boundary, then encode those typed records into the generic artifact
|
||||
candidate envelope before returning to framework code. This keeps stage
|
||||
contracts simple and avoids generic type plumbing across unrelated artifact
|
||||
families.
|
||||
|
||||
Final durable output should be one file per artifact type plus a run-level
|
||||
manifest/index file. This supports partial success and lets downstream consumers
|
||||
read only the artifact types they need. Each artifact file should include its
|
||||
artifact type, extractor key, extractor schema version, envelope format version,
|
||||
records, source references, and enough provenance to connect it to the run
|
||||
manifest.
|
||||
|
||||
Every artifact record should require source references unless that artifact
|
||||
schema explicitly opts into ungrounded fields. Artifact-level metadata, counts,
|
||||
run information, and other derived summary fields are exempt from the per-record
|
||||
grounding rule.
|
||||
|
||||
Schemas should be versioned per extractor, with a separate envelope/manifest
|
||||
format version. A single global schema version would couple unrelated extractor
|
||||
release cadence.
|
||||
|
||||
### RunManifest
|
||||
|
||||
@@ -262,6 +302,7 @@ Per-run provenance record.
|
||||
|
||||
```go
|
||||
type RunManifest struct {
|
||||
EnvelopeVersion string `json:"envelope_version"`
|
||||
InputModule string `json:"input_module"`
|
||||
Chunker string `json:"chunker"`
|
||||
SourceDigests []string `json:"source_digests"`
|
||||
@@ -371,7 +412,7 @@ Proposed runner flow:
|
||||
7. Resolve the configured chunker.
|
||||
8. Chunk source units into deterministic source chunks.
|
||||
9. Resolve configured extractor instances through a registry.
|
||||
10. Process chunks in extractor-defined mode.
|
||||
10. Extract from chunks in extractor-defined mode.
|
||||
11. Merge per-chunk artifact candidates deterministically.
|
||||
12. Normalize merged artifact candidates.
|
||||
13. Run deterministic validators before LLM-backed validators.
|
||||
@@ -401,6 +442,11 @@ Reuse these architectural patterns:
|
||||
- validator decision cardinality and deterministic validator ordering;
|
||||
- CLI tests and fixture-driven integration tests.
|
||||
|
||||
The fixture-driven integration-test pattern should begin at checkpoint 3 with a
|
||||
walking skeleton over fake modules and a fake LLM client. Later checkpoints
|
||||
should replace fake pieces with real Seriatim, runtime, and D&D modules without
|
||||
losing that end-to-end contract coverage.
|
||||
|
||||
Avoid copying these Audita concepts directly:
|
||||
|
||||
- transcript-specific core types;
|
||||
@@ -426,32 +472,47 @@ compiling and targeted tests covering the newly introduced contracts or behavior
|
||||
5. [Seriatim Input Module](5-seriatim-input-module.md)
|
||||
6. [D&D Spells Extractor](6-dnd-spells-extractor.md)
|
||||
|
||||
The first useful vertical slice should arrive at checkpoint 6: Seriatim
|
||||
transcript input to validated D&D spell artifact output. Earlier checkpoints are
|
||||
intentionally contract-first and may not produce useful user output yet.
|
||||
The first contract-level walking skeleton should arrive at checkpoint 3: fixture
|
||||
input through fake input, chunk, extract, merge, normalize, and output modules
|
||||
with a fake LLM client. The first useful vertical slice should arrive at
|
||||
checkpoint 6: Seriatim transcript input to validated D&D spell artifact output.
|
||||
Earlier checkpoints remain contract-first and may not produce useful user output
|
||||
yet.
|
||||
|
||||
## Architecture Decisions
|
||||
|
||||
- Final durable output should use one artifact file per artifact type plus a
|
||||
run-level manifest/index file.
|
||||
- Framework artifact flow should use a generic envelope with `json.RawMessage`
|
||||
payloads. Extract modules should use typed Go structs at their own boundaries.
|
||||
- Schemas should be versioned per extractor, with a separate envelope/manifest
|
||||
format version.
|
||||
- Artifact records should require source references by default. Individual
|
||||
schemas may explicitly opt into ungrounded fields. Artifact-level metadata is
|
||||
exempt.
|
||||
- Source-reference ranges should be preserved exactly. Generic pipeline code
|
||||
should not merge or rewrite overlapping ranges.
|
||||
- `ExtractionRequest` should carry the active chunk plus optional ambient
|
||||
context for document synopsis, prior-chunk summaries, known entities, or
|
||||
similar module-provided state.
|
||||
- LLM-backed review should be part of module-owned validator chains. Extract
|
||||
modules and normalize modules may both use deterministic and LLM-backed
|
||||
validators.
|
||||
- The Seriatim MVP should support only the minimal Seriatim schema. Broader
|
||||
Seriatim schema support should be added later without changing core source
|
||||
contracts.
|
||||
- Core source metadata should remain `map[string]any`. Well-known metadata keys
|
||||
should be documented as conventions, and input modules may expose typed
|
||||
accessor helpers for their own metadata.
|
||||
|
||||
## Open Design Questions
|
||||
|
||||
- Should final output be one combined artifact envelope or one file per
|
||||
extractor?
|
||||
- Should extractor output use typed Go structs per artifact or a generic
|
||||
artifact record with `json.RawMessage` payloads?
|
||||
- Should schemas be versioned per extractor, globally, or both?
|
||||
- Should every record require source references, or should some top-level
|
||||
artifact metadata be allowed without source references?
|
||||
- Should overlapping source-reference ranges be merged, preserved exactly, or
|
||||
both?
|
||||
- Should extraction run independently per source chunk only, or should some
|
||||
extractors receive whole-document context?
|
||||
- Which artifact types can use a generic append-in-chunk-order merger?
|
||||
- Which artifact types should use generic append-in-chunk-order merge, and which
|
||||
should use domain-specific merge?
|
||||
- Which artifact types need domain-specific normalization for deduplication,
|
||||
identity resolution, or consistency?
|
||||
- Should LLM review be part of each extractor's validator chain or a separate
|
||||
review phase?
|
||||
- Should the Seriatim adapter accept only its minimal schema initially or also
|
||||
support richer transcript schemas?
|
||||
- Should source-unit metadata be untyped `map[string]any`, typed extension
|
||||
structs, or both?
|
||||
- What should the configuration model look like for selecting input, chunk,
|
||||
extract, merge, normalize, output, and validator modules?
|
||||
|
||||
## Near-Term Documentation Tasks
|
||||
|
||||
|
||||
Reference in New Issue
Block a user