Phase 3B context-build only
- Build a deterministic
OperationalContextfrom an existing.spkgpackage and schema JSON. - Output deterministic context JSON to
artifacts/spark/context.json. - Prevent any raw payload or private field leak (no
applicant,decision_recommendation,extraction.notes/notes,source_pdf_contents, or direct payload dumps).
Allowed in Phase 3B:
- Add context builder logic.
- Add exactly one CLI command:
context-build. - Add unit/integration tests for the
context-buildroutine. - Generate
artifacts/spark/context.jsononly.
Forbidden in Phase 3B:
- No
context-rendercommand. - No
context-validatecommand. - No
context_render.txtfile generation. - No MCP server implementation or integration.
- No new schema files.
- No Phase 3C/3D functionality.
- No broad package structure or API refactoring.
The subsequent implementation prompt may modify/create only the following files:
agy7rust/src/main.rsagy7rust/src/lib.rsagy7rust/src/commands/mod.rsagy7rust/src/commands/context_build.rsagy7rust/src/context/mod.rsagy7rust/src/context/model.rsagy7rust/src/context/build.rsagy7rust/tests/spark_roundtrip.rsartifacts/spark/context.jsonagy7rust/PHASE3B_STATUS.md
Do not read, write, or modify:
agy7rust/src/commands/context_render.rsagy7rust/src/commands/context_validate.rsagy7rust/src/context/render.rsagy7rust/src/context/validate.rsartifacts/spark/context_render.txtschemas/genehmigung_v1.json(unless explicitly blocked/instructed)examples/README.md- Phase snapshots (
PHASE1_SPARK_SNAPSHOT.md,PHASE2_SCHEMA_SIDECAR_SNAPSHOT.md,PHASE3A_CONTEXT_MODEL_SNAPSHOT.md) - Local agent skills (
.agent/skills/*)
Command:
agy7rust context-build -i <package.spkg> -s <schema.json> -o <context.json>Success Output:
OK: context-build passed
context: <context_id>
schema: genehmigung_v1
missing_fields: 0
Failure Output:
ERROR: context-build failed
reason: <stable reason>
- Package Ingestion: Read and parse
.spkgusing existing package verification/package logic. - Schema Ingestion: Read schema JSON using existing schema parsing/checking logic.
- Hash Derivation: Derive
source_package_hashdirectly from existing package integrity hash metadata. - Schema Metadata: Derive
schema_nameandschema_versionfrom the schema JSON. - Required Fields: Copy
required_field_pathsfrom the schema. - Satisfied Fields: Derive
satisfied_field_pathsfrom package field-path metadata. - Missing Fields: Derive
missing_field_pathsasrequired_field_pathsminussatisfied_field_paths. - Context Identifier: Build a deterministic
context_idby hashingsource_package_hash+schema_name+schema_version. - Static Constraints: Fill deterministic, conservative constraints:
no_raw_payload_dumpschema_required_fields_must_existdeterministic_replay_onlysynthetic_fixture_only
- Execution Order: Fill deterministic list:
package_verifiedschema_loadedschema_checkedcontext_built
- Dependency Graph: Fill deterministic dependency pairs:
package_verified -> schema_checkedschema_loaded -> schema_checkedschema_checked -> context_built
- Blockers: Fill deterministic blockers:
missing_required_field -> context_built
- Recovery Paths: Fill deterministic recovery paths:
missing_required_field -> schema_check_failure_reported
- Non-Claims: Copy
non_claimsfrom schemanon_claimswhen present, plus conservative local non-claims. - Pre-write Validation: Call
sort_stable()andvalidate_model_shape()on the constructed context object before serialization. - Serialization: Write canonical, stable pretty JSON with a terminating newline.
- Key Ordering: Stable alphabetical JSON key serialization.
- List Ordering: Stable lexicographical list order (via
sort_stable). - No Volatile Elements: Absolutely no timestamps, system clocks, randomized identifiers, or environmental paths.
- Offline operation: Zero network/web calls.
- Identical Hash: Repeated executions with identical package and schema files must yield byte-identical
context.json.
The generated context.json must NOT contain:
applicantraw values.decision_recommendationraw values.extraction.notes(notes) raw content.source_pdf_contents.- Hidden original payload payload bytes.
- Full raw input extraction JSON structure.
The implementation validation suite must assert:
context-buildcompletes successfully from the defaultextraction.spkg+genehmigung_v1.json.- The output parses and validates cleanly against
OperationalContext::validate_model_shape. - Repeated builds yield identical file hashes.
- Missing schema paths are correctly isolated in
missing_field_paths. context_idremains stable and deterministic.- Context JSON leak test successfully checks that no protected fields are present in
context.json. - No
context-renderorcontext-validateCLI commands are registered.
Before completion, the following command pipeline must execute cleanly:
cd C:\Users\contr\sandbox_workspace\Antigravity-Comptextv7-unified\agy7rust
cargo fmt
cargo fmt --all --check
cargo check
cargo test
cargo clippy -- -D warnings
cargo run -- context-build -i ..\artifacts\spark\extraction.spkg -s ..\schemas\genehmigung_v1.json -o ..\artifacts\spark\context.json
cargo run -- schema-check -i ..\examples\spark\extraction.json -s ..\schemas\genehmigung_v1.json
powershell -File .\demo_spark.ps1Stop execution and report blocked if:
- Existing package metadata format does not support metadata/field path extraction.
- Deriving package hashes requires loading or leaking raw payload contents.
- Schema parsing demands a general architectural crate refactoring.
- The workflow requires introducing
context-renderorcontext-validatecommands. - CLI command routing modification requires modifying other commands.
- Any private raw payload value is found written into
context.json.
Report execution status using this exact block structure:
PHASE: Phase 3B implementation - context-build only
STATUS: success | blocked
SKILLS_USED:
- ...
FILES_CHANGED:
- ...
COMMANDS_RUN:
- ...
TESTS:
- ...
CONTEXT_BUILD:
- ...
DETERMINISM_CHECK:
- ...
LEAK_CHECK:
- ...
DEMO:
- ...
RISKS:
- ...
NEXT:
- Phase 3B audit / snapshot