P3-DATA-ENGINE-002: Data Engine v1 implementation + qualification suite (QUALIFIED)
Implements the frozen P3_DATA_ENGINE_V1_SPEC (SHA 84bf0f217ffba51197112a6bbacbcc297058e04b5ca47f0459028fe33e0321e5).
Components: engine/ producer (certify, chunkmap, parse, canonical, worker,
dispatcher, aggregate, storage, journal, checkpoint, lock, evidence, manifest,
run_complete, dataset_builder, cli) + engine/verify independent verifier
(vparse, vaggregate, vinvariants, vcompare); headless CLI sniper-data; golden
corpus G01-G17; unit/property/adversarial/mutation/legacy-diff/CLI suites.
Qualification verdict: QUALIFIED (all 9 mandatory gates pass; independent
verifier accepted). Spec, governance record, and legacy checkpoint untouched.
G-14 NOT AUTHORIZED honored; no real-data processing, no pilot, no workload 46,
no chunk 760 access.
2026-09-07 14:15:25 +07:00 | | | """Strict engine configuration (spec 6.3).
|
| | |
|
| | | Every identity-affecting field participates in ``config_sha256``; operational
|
| | | fields are recorded in the snapshot but excluded from the hash. The exact
|
| | | field classification is fixed in v1 and documented in the implementation map.
|
| | | """
|
| | |
|
| | | import os
|
| | |
|
| | | from . import versions
|
| | | from .util import canonical_json_sha256
|
| | |
|
| | | # Identity-affecting fields (participate in config_sha256). Changing any of
|
| | | # these changes the reproducibility identity of produced data.
|
| | | IDENTITY_FIELDS = (
|
| | | "source_path",
|
 P3-DATA-ENGINE-004: source-grammar correction + re-qualification (QUALIFIED) - spec 1.1.0 controlled amendment (Appendix C): G_TICKSTORY_MT5 six-col YYYYMMDD,HH:MM:SS,bid,ask,last,volume; compact timestamp; mandatory volume; last preserved via source-preservation sidecar (spec 8.6; CTS_V1 unchanged; G-4/G-5 intact); SHA effbaf2624cd46137c22a246fdabff4067052807b6b6224be464366bec4745d9 (machine-verified) - implementation: grammar registry, source_grammar config identity + fail-closed validation, compact timestamp parse, _parse_chunk_tickstory, preservation serialization + sidecars, certificate grammar_id + compact sniffing, init cert/config mismatch BLOCK, independent verifier v_parse_chunk_tickstory + preservation ids, evidence + verify_dataset preservation checks; ENGINE_VERSION 1.1.0, PARSER_V1.1 - CLI defect repair: status/resume on run-less dir exit 4 BLOCKED without traceback (P3-DE-003 NEW_ENGINE_DEFECT) + regression tests - qualification: unit, golden G01-G17, SG01-SG15 + e2e, property, adversarial, mutation 8/8, independent verifier dataset+run-complete ACCEPTED, legacy diff 0 unresolved legacy untouched, dataset-builder determinism, CLI E2E; VERDICT QUALIFIED - G-14 unchanged BLOCKED/NOT AUTHORIZED; no real-data ingestion; no workload 46; no chunk 760+; legacy checkpoint 759/18442355762 untouched
2026-09-07 17:34:57 +07:00 | | | "source_grammar", # amended P3-DE-004: grammar preset binding (identity)
|
P3-DATA-ENGINE-002: Data Engine v1 implementation + qualification suite (QUALIFIED)
Implements the frozen P3_DATA_ENGINE_V1_SPEC (SHA 84bf0f217ffba51197112a6bbacbcc297058e04b5ca47f0459028fe33e0321e5).
Components: engine/ producer (certify, chunkmap, parse, canonical, worker,
dispatcher, aggregate, storage, journal, checkpoint, lock, evidence, manifest,
run_complete, dataset_builder, cli) + engine/verify independent verifier
(vparse, vaggregate, vinvariants, vcompare); headless CLI sniper-data; golden
corpus G01-G17; unit/property/adversarial/mutation/legacy-diff/CLI suites.
Qualification verdict: QUALIFIED (all 9 mandatory gates pass; independent
verifier accepted). Spec, governance record, and legacy checkpoint untouched.
G-14 NOT AUTHORIZED honored; no real-data processing, no pilot, no workload 46,
no chunk 760 access.
2026-09-07 14:15:25 +07:00 | | | "source_tz_offset_minutes",
|
| | | "has_volume",
|
| | | "timeframes",
|
| | | "chunk_bytes_nominal",
|
| | | "workload_bytes_nominal",
|
| | | )
|
| | |
|
| | | # Operational fields (in snapshot only, never in config_sha256).
|
| | | OPERATIONAL_FIELDS = (
|
| | | "output_root",
|
| | | "workers_requested",
|
| | | "checkpoint_every_workload",
|
| | | "retry_limit",
|
| | | "memory_limits_mb",
|
| | | "disk_floor_bytes",
|
| | | "certify_timeout_sec",
|
| | | "reference_now_ms", # test override of certify time; operational
|
| | | )
|
| | |
|
| | | ALL_FIELDS = sorted(set(IDENTITY_FIELDS) | set(OPERATIONAL_FIELDS))
|
| | |
|
| | |
|
| | | class ConfigError(Exception):
|
| | | pass
|
| | |
|
| | |
|
| | | def _check(cond, msg):
|
| | | if not cond:
|
| | | raise ConfigError(msg)
|
| | |
|
| | |
|
| | | def default_config(source_path, output_root=None, source_tz_offset_minutes=0,
|
| | | **overrides):
|
| | | """Produce a fully-populated config dict with v1 defaults.
|
| | |
|
| | | ``source_tz_offset_minutes`` is an explicit, call-site established value
|
| | | (G-6: never silently invented; production value must be established at
|
| | | source initialization in the pilot phase). Synthetic fixtures use 0 (UTC).
|
 P3-DATA-ENGINE-004: source-grammar correction + re-qualification (QUALIFIED) - spec 1.1.0 controlled amendment (Appendix C): G_TICKSTORY_MT5 six-col YYYYMMDD,HH:MM:SS,bid,ask,last,volume; compact timestamp; mandatory volume; last preserved via source-preservation sidecar (spec 8.6; CTS_V1 unchanged; G-4/G-5 intact); SHA effbaf2624cd46137c22a246fdabff4067052807b6b6224be464366bec4745d9 (machine-verified) - implementation: grammar registry, source_grammar config identity + fail-closed validation, compact timestamp parse, _parse_chunk_tickstory, preservation serialization + sidecars, certificate grammar_id + compact sniffing, init cert/config mismatch BLOCK, independent verifier v_parse_chunk_tickstory + preservation ids, evidence + verify_dataset preservation checks; ENGINE_VERSION 1.1.0, PARSER_V1.1 - CLI defect repair: status/resume on run-less dir exit 4 BLOCKED without traceback (P3-DE-003 NEW_ENGINE_DEFECT) + regression tests - qualification: unit, golden G01-G17, SG01-SG15 + e2e, property, adversarial, mutation 8/8, independent verifier dataset+run-complete ACCEPTED, legacy diff 0 unresolved legacy untouched, dataset-builder determinism, CLI E2E; VERDICT QUALIFIED - G-14 unchanged BLOCKED/NOT AUTHORIZED; no real-data ingestion; no workload 46; no chunk 760+; legacy checkpoint 759/18442355762 untouched
2026-09-07 17:34:57 +07:00 | | |
|
| | | ``source_grammar`` (amended P3-DE-004) defaults to the dotted synthetic/
|
| | | corpus preset; the production preset ``tickstory_mt5`` is set explicitly
|
| | | for the real six-column Tickstory MT5 source and is validated against the
|
| | | certificate ``grammar_id`` at init (fail-closed; never silent).
|
P3-DATA-ENGINE-002: Data Engine v1 implementation + qualification suite (QUALIFIED)
Implements the frozen P3_DATA_ENGINE_V1_SPEC (SHA 84bf0f217ffba51197112a6bbacbcc297058e04b5ca47f0459028fe33e0321e5).
Components: engine/ producer (certify, chunkmap, parse, canonical, worker,
dispatcher, aggregate, storage, journal, checkpoint, lock, evidence, manifest,
run_complete, dataset_builder, cli) + engine/verify independent verifier
(vparse, vaggregate, vinvariants, vcompare); headless CLI sniper-data; golden
corpus G01-G17; unit/property/adversarial/mutation/legacy-diff/CLI suites.
Qualification verdict: QUALIFIED (all 9 mandatory gates pass; independent
verifier accepted). Spec, governance record, and legacy checkpoint untouched.
G-14 NOT AUTHORIZED honored; no real-data processing, no pilot, no workload 46,
no chunk 760 access.
2026-09-07 14:15:25 +07:00 | | | """
|
| | | cfg = {
|
| | | "source_path": os.path.abspath(source_path),
|
 P3-DATA-ENGINE-004: source-grammar correction + re-qualification (QUALIFIED) - spec 1.1.0 controlled amendment (Appendix C): G_TICKSTORY_MT5 six-col YYYYMMDD,HH:MM:SS,bid,ask,last,volume; compact timestamp; mandatory volume; last preserved via source-preservation sidecar (spec 8.6; CTS_V1 unchanged; G-4/G-5 intact); SHA effbaf2624cd46137c22a246fdabff4067052807b6b6224be464366bec4745d9 (machine-verified) - implementation: grammar registry, source_grammar config identity + fail-closed validation, compact timestamp parse, _parse_chunk_tickstory, preservation serialization + sidecars, certificate grammar_id + compact sniffing, init cert/config mismatch BLOCK, independent verifier v_parse_chunk_tickstory + preservation ids, evidence + verify_dataset preservation checks; ENGINE_VERSION 1.1.0, PARSER_V1.1 - CLI defect repair: status/resume on run-less dir exit 4 BLOCKED without traceback (P3-DE-003 NEW_ENGINE_DEFECT) + regression tests - qualification: unit, golden G01-G17, SG01-SG15 + e2e, property, adversarial, mutation 8/8, independent verifier dataset+run-complete ACCEPTED, legacy diff 0 unresolved legacy untouched, dataset-builder determinism, CLI E2E; VERDICT QUALIFIED - G-14 unchanged BLOCKED/NOT AUTHORIZED; no real-data ingestion; no workload 46; no chunk 760+; legacy checkpoint 759/18442355762 untouched
2026-09-07 17:34:57 +07:00 | | | "source_grammar": versions.GRAMMAR_DOTTED,
|
P3-DATA-ENGINE-002: Data Engine v1 implementation + qualification suite (QUALIFIED)
Implements the frozen P3_DATA_ENGINE_V1_SPEC (SHA 84bf0f217ffba51197112a6bbacbcc297058e04b5ca47f0459028fe33e0321e5).
Components: engine/ producer (certify, chunkmap, parse, canonical, worker,
dispatcher, aggregate, storage, journal, checkpoint, lock, evidence, manifest,
run_complete, dataset_builder, cli) + engine/verify independent verifier
(vparse, vaggregate, vinvariants, vcompare); headless CLI sniper-data; golden
corpus G01-G17; unit/property/adversarial/mutation/legacy-diff/CLI suites.
Qualification verdict: QUALIFIED (all 9 mandatory gates pass; independent
verifier accepted). Spec, governance record, and legacy checkpoint untouched.
G-14 NOT AUTHORIZED honored; no real-data processing, no pilot, no workload 46,
no chunk 760 access.
2026-09-07 14:15:25 +07:00 | | | "source_tz_offset_minutes": int(source_tz_offset_minutes),
|
| | | "has_volume": False,
|
| | | "timeframes": list(versions.DEFAULT_TIMEFRAMES),
|
| | | "chunk_bytes_nominal": versions.CHUNK_BYTES_NOMINAL,
|
| | | "workload_bytes_nominal": versions.WORKLOAD_BYTES_NOMINAL,
|
| | | "output_root": output_root,
|
| | | "workers_requested": versions.WORKERS_REQUESTED_DEFAULT,
|
| | | "checkpoint_every_workload": True,
|
| | | "retry_limit": 2,
|
| | | "memory_limits_mb": {"parent": 512, "worker": 1024},
|
| | | "disk_floor_bytes": 4 * 2 ** 30,
|
| | | "certify_timeout_sec": 3600,
|
| | | "reference_now_ms": None,
|
| | | }
|
| | | for k, v in overrides.items():
|
| | | if k not in ALL_FIELDS:
|
| | | raise ConfigError("unknown config field %r" % k)
|
| | | cfg[k] = v
|
| | | validate_config(cfg)
|
| | | return cfg
|
| | |
|
| | |
|
| | | def validate_config(cfg):
|
| | | _check(isinstance(cfg, dict), "config must be a JSON object")
|
| | | _check(isinstance(cfg.get("source_path"), str) and os.path.isabs(cfg["source_path"]),
|
| | | "source_path must be an absolute path")
|
 P3-DATA-ENGINE-004: source-grammar correction + re-qualification (QUALIFIED) - spec 1.1.0 controlled amendment (Appendix C): G_TICKSTORY_MT5 six-col YYYYMMDD,HH:MM:SS,bid,ask,last,volume; compact timestamp; mandatory volume; last preserved via source-preservation sidecar (spec 8.6; CTS_V1 unchanged; G-4/G-5 intact); SHA effbaf2624cd46137c22a246fdabff4067052807b6b6224be464366bec4745d9 (machine-verified) - implementation: grammar registry, source_grammar config identity + fail-closed validation, compact timestamp parse, _parse_chunk_tickstory, preservation serialization + sidecars, certificate grammar_id + compact sniffing, init cert/config mismatch BLOCK, independent verifier v_parse_chunk_tickstory + preservation ids, evidence + verify_dataset preservation checks; ENGINE_VERSION 1.1.0, PARSER_V1.1 - CLI defect repair: status/resume on run-less dir exit 4 BLOCKED without traceback (P3-DE-003 NEW_ENGINE_DEFECT) + regression tests - qualification: unit, golden G01-G17, SG01-SG15 + e2e, property, adversarial, mutation 8/8, independent verifier dataset+run-complete ACCEPTED, legacy diff 0 unresolved legacy untouched, dataset-builder determinism, CLI E2E; VERDICT QUALIFIED - G-14 unchanged BLOCKED/NOT AUTHORIZED; no real-data ingestion; no workload 46; no chunk 760+; legacy checkpoint 759/18442355762 untouched
2026-09-07 17:34:57 +07:00 | | | grammar = cfg.get("source_grammar", versions.GRAMMAR_DOTTED)
|
| | | _check(grammar in versions.SUPPORTED_GRAMMARS,
|
| | | "source_grammar must be one of %s" % (versions.SUPPORTED_GRAMMARS,))
|
P3-DATA-ENGINE-002: Data Engine v1 implementation + qualification suite (QUALIFIED)
Implements the frozen P3_DATA_ENGINE_V1_SPEC (SHA 84bf0f217ffba51197112a6bbacbcc297058e04b5ca47f0459028fe33e0321e5).
Components: engine/ producer (certify, chunkmap, parse, canonical, worker,
dispatcher, aggregate, storage, journal, checkpoint, lock, evidence, manifest,
run_complete, dataset_builder, cli) + engine/verify independent verifier
(vparse, vaggregate, vinvariants, vcompare); headless CLI sniper-data; golden
corpus G01-G17; unit/property/adversarial/mutation/legacy-diff/CLI suites.
Qualification verdict: QUALIFIED (all 9 mandatory gates pass; independent
verifier accepted). Spec, governance record, and legacy checkpoint untouched.
G-14 NOT AUTHORIZED honored; no real-data processing, no pilot, no workload 46,
no chunk 760 access.
2026-09-07 14:15:25 +07:00 | | | _check(isinstance(cfg.get("source_tz_offset_minutes"), int),
|
| | | "source_tz_offset_minutes must be an integer")
|
| | | _check(isinstance(cfg.get("has_volume"), bool), "has_volume must be bool")
|
 P3-DATA-ENGINE-004: source-grammar correction + re-qualification (QUALIFIED) - spec 1.1.0 controlled amendment (Appendix C): G_TICKSTORY_MT5 six-col YYYYMMDD,HH:MM:SS,bid,ask,last,volume; compact timestamp; mandatory volume; last preserved via source-preservation sidecar (spec 8.6; CTS_V1 unchanged; G-4/G-5 intact); SHA effbaf2624cd46137c22a246fdabff4067052807b6b6224be464366bec4745d9 (machine-verified) - implementation: grammar registry, source_grammar config identity + fail-closed validation, compact timestamp parse, _parse_chunk_tickstory, preservation serialization + sidecars, certificate grammar_id + compact sniffing, init cert/config mismatch BLOCK, independent verifier v_parse_chunk_tickstory + preservation ids, evidence + verify_dataset preservation checks; ENGINE_VERSION 1.1.0, PARSER_V1.1 - CLI defect repair: status/resume on run-less dir exit 4 BLOCKED without traceback (P3-DE-003 NEW_ENGINE_DEFECT) + regression tests - qualification: unit, golden G01-G17, SG01-SG15 + e2e, property, adversarial, mutation 8/8, independent verifier dataset+run-complete ACCEPTED, legacy diff 0 unresolved legacy untouched, dataset-builder determinism, CLI E2E; VERDICT QUALIFIED - G-14 unchanged BLOCKED/NOT AUTHORIZED; no real-data ingestion; no workload 46; no chunk 760+; legacy checkpoint 759/18442355762 untouched
2026-09-07 17:34:57 +07:00 | | | _check(not (grammar == versions.GRAMMAR_TICKSTORY_MT5 and not cfg.get("has_volume")),
|
| | | "grammar tickstory_mt5 requires has_volume=true (mandatory volume column)")
|
P3-DATA-ENGINE-002: Data Engine v1 implementation + qualification suite (QUALIFIED)
Implements the frozen P3_DATA_ENGINE_V1_SPEC (SHA 84bf0f217ffba51197112a6bbacbcc297058e04b5ca47f0459028fe33e0321e5).
Components: engine/ producer (certify, chunkmap, parse, canonical, worker,
dispatcher, aggregate, storage, journal, checkpoint, lock, evidence, manifest,
run_complete, dataset_builder, cli) + engine/verify independent verifier
(vparse, vaggregate, vinvariants, vcompare); headless CLI sniper-data; golden
corpus G01-G17; unit/property/adversarial/mutation/legacy-diff/CLI suites.
Qualification verdict: QUALIFIED (all 9 mandatory gates pass; independent
verifier accepted). Spec, governance record, and legacy checkpoint untouched.
G-14 NOT AUTHORIZED honored; no real-data processing, no pilot, no workload 46,
no chunk 760 access.
2026-09-07 14:15:25 +07:00 | | | tfs = cfg.get("timeframes")
|
| | | _check(isinstance(tfs, list) and len(tfs) >= 1, "timeframes must be a non-empty list")
|
| | | _check(all(tf in versions.TIMEFRAMES for tf in tfs), "timeframe not in v1 set M1/M5/M15/M30/H1")
|
| | | _check(len(set(tfs)) == len(tfs), "duplicate timeframe in timeframes")
|
| | | _check(isinstance(cfg.get("chunk_bytes_nominal"), int) and cfg["chunk_bytes_nominal"] >= 1,
|
| | | "chunk_bytes_nominal must be a positive integer")
|
| | | _check(isinstance(cfg.get("workload_bytes_nominal"), int)
|
| | | and cfg["workload_bytes_nominal"] >= cfg["chunk_bytes_nominal"],
|
| | | "workload_bytes_nominal must be >= chunk_bytes_nominal")
|
| | | _check(isinstance(cfg.get("workers_requested"), int) and cfg["workers_requested"] >= 1,
|
| | | "workers_requested must be >= 1")
|
| | | _check(isinstance(cfg.get("retry_limit"), int) and cfg["retry_limit"] >= 1,
|
| | | "retry_limit must be >= 1")
|
| | | for f in ("output_root",):
|
| | | v = cfg.get(f)
|
| | | _check(v is None or (isinstance(v, str) and os.path.isabs(v)),
|
| | | "%s must be an absolute path or null" % f)
|
| | | if "timeframes" in cfg:
|
| | | cfg["timeframes"] = [tf for tf in versions.DEFAULT_TIMEFRAMES if tf in tfs]
|
| | |
|
| | |
|
| | | def config_sha256(cfg):
|
| | | """Hash over the identity-affecting subset only (spec 6.3)."""
|
| | | id_subset = {k: cfg[k] for k in IDENTITY_FIELDS if k in cfg}
|
| | | return canonical_json_sha256(id_subset)
|
| | |
|
| | |
|
| | | def config_snapshot(cfg):
|
| | | """Full config snapshot recorded in manifests (identity + operational)."""
|
| | | return {k: cfg[k] for k in ALL_FIELDS if k in cfg}
|