Repository navigation
Conversation
Implement issue01 of the Source evidence declarations specification. Bind trusted native and remote declarations to exact Source material and retain per-revision Atomic Memory snapshots in the existing transaction. Preserve neutral fallback, exact identities, scope authorization and public retrieval contracts. Add versioned p0004 migrations and SQLite persistence regressions. Refs oceanbase#1975. Full suite: 5255 passed, 431 skipped, 7 failed; introduced observability adapter failures fixed and its file passes 18 tests. Topic Memory vector failure also reproduces at the unchanged baseline.
Cover persisted declarations, scope isolation, historical neutrality, synthetic model trust claims, and unchanged recall consumers on SQLite and OceanBase.
Preserve the published p0004 artifact handle revision and introduce evidence as p0005. Retain both schema intents, recompute exact SQLite fingerprints, and update MySQL migration head expectations.
hidb4ai
left a comment
There was a problem hiding this comment.
Please address the two native Source evidence issues below before merging. Both reproduce through public SQLite flows and break evidence inspection and projection rebuild after successful Memory generation.
hidb4ai
left a comment
There was a problem hiding this comment.
Native Source evidence inspection and projection rebuild pass the input-alias and model-default scenarios. Remote observation ingestion still fails for serialization aliases; please address the inline P2 before merging.
hidb4ai
left a comment
There was a problem hiding this comment.
The three reported reproduction scenarios now pass. One remote Source regression remains when aliases apply to inherited envelope fields; please address the inline P2 before merging.
Retain native Source identity independently of adapter aliases and mutable description defaults, preserve legacy read/replay behavior, and keep serialized business fields intact. Capture evidence at the shared Atomic Memory body-commit boundary, including restoration revisions, without retroactively attesting state-only writes. Refs oceanbase#1975.
Check native serialization compatibility at acceptance without blocking valid captures or Memory writes. Keep previously accepted incompatible declarations neutral while preserving exact material and digest checks. Reject legacy identities that cannot be decoded exactly instead of supplying a default Definition version.
Preserve Source evidence verification and upstream revision metadata initialization in Atomic Memory projection rebuild.
Reject native serialized material that omits an identity field before journal allocation or persistence, rather than accepting Sources that later fail evidence capture. Preserve strict retained identity checks.
hidb4ai
left a comment
There was a problem hiding this comment.
One native Source acceptance issue remains: a round-trippable identity serializer can be durably accepted but fail later Memory extraction. Please address the inline P2 before merging.
Validate serialized identity values as well as key presence before persistence, matching historical evidence validation. Cover round-trippable codecs for all three identity fields without weakening retained-material checks.
Preserve exact evidence inspection alongside upstream bounded list queries and reuse its authorized read snapshot lifecycle.
hireview001
left a comment
There was a problem hiding this comment.
- CI failed: validate (failure).
- CI failed: E2E harness (failure). Failed steps: validate / Validate harness and Compose definitions.
| (definition.source_class.model_fields[key].serialization_alias or key) != key | ||
| for key in ("name", "definition_version", "materialization") | ||
| ): | ||
| source, _ = self._decode_envelope(reference.source_type, envelope) |
There was a problem hiding this comment.
[P2] Decode canonical historical identity before consulting current aliases
For a pre-upgrade canonical native envelope without a source header, registering a newer Definition with a name alias sends the old material through today's decoder, causing evidence reads and rebuilds using that registry to fail on valid historical data. Resolve retained canonical identity independently of the current decoder and keep missing historical declarations neutral.
There was a problem hiding this comment.
Independently reproduced on 88cd8f23 with SQLite data captured through the public Source and Memory workflow on base e4efb39b. The retained Source has canonical identity keys and no source header. With no current native decoder registered, both memory.evidence(..., revision=1) and projection rebuild succeed. Registering Definition version 2 with name: str = Field(alias="source_name") makes both operations fail with InvalidStoredPayloadError because the old payload is passed to today's model. Exact Memory reads still succeed. Historical identity must remain readable independently of the current Definition, with absent historical declarations treated as neutral.
There was a problem hiding this comment.
[P2] This remains reproducible for non-default historical versions on 2b95df67. I captured a version 2 Source and generated its Memory through public APIs on base 0da4436d, then reopened the same SQLite database on this head. Without a native decoder, evidence inspection and rebuild both succeed. Registering version 3 with name: str = Field(alias="source_name") and a business label aliased to name makes both fail with InvalidSourceDefinitionError: Source declares '2', expected '3'; exact Memory reads still succeed. The unbound fallback in _historical_canonical_source() only recognizes version 1 (sources.py:455-458), so this case still reaches today's decoder. Historical evidence must preserve the retained explicit identity independently of the current registration.
There was a problem hiding this comment.
Fixed in 13517fdd.
_historical_canonical_source() now:
- when no evidence binding exists, accepts the explicit string
definition_versionfrom the retained canonical material instead of only"1"; - when a binding exists, requires the material version to equal the binding version; a mismatch is no longer guessed and falls through to the strict decoder path;
- still rebuilds only a neutral
Sourceidentity, so the declaration remainsuntrusted/unknownand the current aliased Definition is never used to decode historical material.
Regressions:
test_unbound_versioned_canonical_history_ignores_new_definition_aliases— version 2 canonical material with a version 3 Definition wherenameis occupied by a business alias; evidence matches the neutral baseline and reports version"2".test_canonical_historical_evidence_survives_business_alias_rebuild— now parameterized over historical versions1and2, and covers publicevidence()plusrebuild_atomic_memory_projection()before/after equality.
Affected tests: 63 passed, 10 skipped; make check passed. OceanBase parameterizations were skipped locally because no instance is available.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed 88cd8f23. The previous identity-serializer finding is fixed: the unsupported representation is rejected before persistence.
Two P2s remain independently reproducible: remote transport with an explicit identity serialization alias, and historical evidence/rebuild failures after registering a newer aliased Definition. Added reproduction details to the existing threads rather than opening duplicates. Please address both before merging.
The two failing Kimi ARM harness consistency tests also fail on base e4efb39b; I have not attributed that CI failure to this PR.
Canonicalize worker envelope keys and their manifest without changing native persisted schemas. Read retained canonical identities before consulting current adapter aliases, preserving neutral historical evidence.
Only trust retained canonical identity keys when the registered model does not claim those spellings for business fields. Keep headerless business-aliased material on the declared decoder, and format the regression file with the pinned hook version.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed 25d9e7a7. The previous two P2s are fixed. One remote-ingestion regression remains for recursive Source schemas with identity aliases; please address the inline P2 before merging.
Resolve referenced root schemas before canonicalizing transport identity keys while preserving nested serialization aliases. Cover manifest registration, observation submission, and SQLite readback.
Preserve Source evidence persistence alongside upstream Atomic Memory startup vector validation, including both contracts in the observability test index.
Keep remote manifests and payloads on the canonical field-name contract so existing Definition fingerprints remain stable. Preserve native historical identity and retained alias spellings across upgrades, replay, and rebuild.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed 2b95df67. The recursive Source transport regression is fixed. Two P2s remain: an unchanged aliased remote Definition conflicts with its existing manifest after upgrade, and version-2 canonical history still fails evidence inspection and rebuild under a newer aliased Definition. See the inline finding and my follow-up in the existing historical-identity thread. Please address both before merging.
| transport: bool, | ||
| ) -> SourceDefinitionManifest: | ||
| source_schema = _json_object( | ||
| definition.source_class.model_json_schema(mode="validation", by_alias=False) |
There was a problem hiding this comment.
[P2] Preserve registered remote manifest identities when upgrading
An unchanged remote Definition with model_config = ConfigDict(serialize_by_alias=True) and body: str = Field(alias="wire_text") registers and submits successfully on base 0da4436d. After upgrading the same SQLite database, forcing by_alias=False changes its schema from wire_text to body and changes its fingerprint without changing the Definition name/version. register_source_definition() then raises SourceConflictError against the previously accepted manifest, blocking the worker. Preserve existing supported manifest/payload identities or provide an explicit version transition rather than silently redefining the same version.
There was a problem hiding this comment.
Fixed in 13517fdd.
The transport contract now derives both sides from the same alias policy:
_manifest_for_definition(transport=True)usesmodel_json_schema(mode="serialization", by_alias=bool(model_config.get("serialize_by_alias")));project_source_for_transport()usesmodel_dump(mode="json"), whose defaultby_alias=Nonefollows the sameserialize_by_aliasconfig.
For the reported case, serialize_by_alias=True with body: Field(alias="wire_text") now keeps wire_text in both the schema and the payload, and the fingerprint matches the base model_json_schema() result. Definitions that only declare serialization_alias still use field names, also matching base.
test_alias_serialization_remote_manifest_and_payload_remain_upgrade_stable reproduces the upgrade path: register on a fresh SQLite database, reopen the same database, re-register the unchanged manifest, and submit the observation. It asserts the schema equals the base-generated schema, the fingerprint is recomputed from it, and the payload retains wire_text.
Affected tests: 63 passed, 10 skipped; make check passed. OceanBase parameterizations were skipped locally because no instance is available.
There was a problem hiding this comment.
[P2] The original serialize_by_alias=True case is fixed on 3c5c0ecc, but fingerprint compatibility still fails for an ordinary amount: Decimal field with no aliases. On base 2d11abd6, public manifest registration and observation submission succeed: the validation schema allows number/string, and the payload contains "1.25". On this head, mode="serialization" at observations.py:178 produces a string-only schema and changes the fingerprint for the unchanged Definition name/version. Re-registering it on the upgraded SQLite database raises SourceConflictError, blocking the worker even though the payload is identical. Preserve supported pre-upgrade manifest identities or provide an explicit version transition.
There was a problem hiding this comment.
Fixed in 3a8b38be.
The transport schema now keeps the pre-upgrade validation schema unless an alias renames a required payload key, checked recursively for nested models. Optional aliased fields keep the base schema because the canonical key is an allowed extra property while the alias key is not required, which matches pre-upgrade behaviour and preserves the fingerprint. AliasChoices resolves to its first string choice; AliasPath keeps the field name.
Regressions:
test_decimal_source_manifest_fingerprint_survives_upgradeasserts the Decimal Definition keeps the basemodel_json_schema()and fingerprint, and that re-registration and observation submission still succeed after reopening the same SQLite database.test_optional_alias_keeps_the_preexisting_manifest_fingerprintcovers an aliased optional version field and asserts the same fingerprint preservation.
Generate remote transport schemas with the same alias policy as their payloads so existing serialize_by_alias Definitions keep their fingerprint and observations after upgrade. Recover explicit canonical historical versions beyond version 1 instead of handing accepted material to a newer aliased Definition.
Include the versioned evidence tables in the frozen pristine SQLite snapshot produced by atomic-memory-migrate apply, keeping the recovery startup gate's complete-output check intact. Refs oceanbase#1975.
Record trusted-registry and historical annotation checks on a consistent backup of the collected synthetic poisoning catalog. Reuse PR #2004's implementation and record ten real OceanBase conformance cases. Constraint: No admission, ranking, review queue or production prompt changes. Scope-risk: Neutral declarations preserve provenance but do not mitigate poisoning. Tested: Combined SQLite suites 262 passed, 10 external cases skipped; separate OceanBase run 10 passed, zero skipped; full Linux Ty/Python 3.11 and changed-file hooks passed.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed 3c5c0ecc. The original alias-configuration and version-2 historical-read reproductions now pass. One P2 remains: changing transport schema mode changes the fingerprint of an unchanged Decimal-bearing Definition and prevents re-registration after upgrade. Added the reproduction to the existing manifest-compatibility thread. Please address this before merging.
Keep the pre-upgrade validation schema unless aliases rename a required payload key, so unchanged Definitions with Decimal or optional aliased fields retain their registered fingerprints while generated aliases still emit a matching schema.
Which issue or RFC does this PR close?
Closes #1975.
Implements the Source authority and verification prerequisite in RFC #1652, while preserving the Source access and
lineage_onlysemantics in RFC #1458.Rationale for this change
Source generation eligibility does not describe the authority or verification of its material. Atomic Memory needs explicit, versioned evidence declarations that remain inspectable after registration changes, restarts, and projection rebuilds.
This change records those facts without introducing trust scores, ranking bonuses, or additional write authority.
What changes are included in this PR?
MemoryEvidenceDeclarationand exact Source material bindings through the existing Source Definition registry.untrusted/unknownvalues. Missing or corrupt authoritative Source material and database failures remain errors.p0005evidence schema migration for SQLite and MySQL-compatible backends, without backfilling historical trust.Are there any user-facing changes?
This adds optional Source Definition evidence declarations and a Python API for inspecting an exact Atomic Memory revision's evidence.
It does not change Atomic Memory bodies or content hashes, Artifact revision identities, HTTP/OpenAPI search schemas, public search scores, or citation identities. It introduces no quality ranking or new generation eligibility rules.
Persistence gains additive evidence tables. Existing Sources and Memory revisions without accepted declarations remain neutral; current configuration does not retroactively attest them.
How was this change tested?
make check: passed, including lock consistency, pre-commit checks, generated guidance checks, and type checking.make contract-test: 52 passed.make opendal-test: 8 passed; connector lint, formatting, and type checks passed.uv run --frozen --python 3.12 python -m pytest -n 6 --doctest-modules --require-dsh-config-runtimeThe initial full run under the local Python 3.11 / SQLite 3.37.2 environment exposed an existing Topic Memory vector-prefilter compatibility failure. A standalone SQLite reproducer isolated the cause: sqlite-vec's
rowid INKNN prefilter requires SQLite 3.38 or newer. The original test and full suite passed with the newer SQLite runtime, without changing code, assertions, or skip conditions.The complete GitHub Actions Python-version matrix has not been run locally.
AI usage statement
AI assistance was used through Oh My Pi with gpt-6.1sol for implementation, test design and consolidation, code inspection, and validation analysis.