Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ci/integration-paths.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ src/tests/adapters/test_minio_corpus_lock_loss.py
src/tests/adapters/test_minio_corpus_publication.py
src/tests/adapters/test_minio_corpus_forget.py
src/tests/adapters/test_minio_corpus_consumption.py
src/tests/adapters/test_minio_storage_capture.py
1 change: 1 addition & 0 deletions .github/ci/unit-paths.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,4 @@ src/tests/adapters/test_object_operations.py
src/tests/surfaces/test_pagination_documentation.py
src/tests/adapters/test_mount_provisioning.py
src/tests/benchmarks/test_locomo_corpus_attestation.py
src/tests/spine/test_storage_capture_profile.py
56 changes: 54 additions & 2 deletions docs/development/storage-capture-managed-assembly.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,70 @@ The typed current profile/source mapping is in
source-rule technical approval is recorded in
[the implementation analysis](../../plan/analysis/managed_storage_profile_20261111.md).
It is not production scope/clock/cost qualification. The assembler matches
native references, hash-bound conversion artifacts, immutable P3 manifests and
native references, hash-bound conversion artifacts, D155 live corpus folders and
all provider items in both directions, preserving actual zero, failed raw
originals, excluded exposure and committed terminal members. Unknown ownership,
unsupported K/link/legacy projection state or missing evidence refuses.

Corpus classification requires the served reading's publication marker to equal
its current DB-input/default-policy digest and `corpus_paths` to contain exactly
that desired folder. Known original copies and reader derivatives count in
`p3_origin`, separately from canonical raw originals. Shared navigation counts
there too; incomplete/orphan folders are excluded staging. Unknown corpus keys
refuse completion. Corpus originals, derivatives and navigation have separate
native classes using the existing `projection_origin` purpose. Capture reads no
snapshot registry or mutable corpus manifest. The native guard and reader require
exact schema head `p9_52_0073`. The historical snapshot relation remains because
`/operations.latest_projections` still reads it; no migration or public API change
is part of this classification update.

Regenerate the synthetic regression documents with
`PYTHONPATH=src:. python scripts/generate_storage_capture_fixture.py` and check
them with the same command plus `--check`. The fixture contains the current
catalog/record schemas, source/schema/native profile digests, class rules,
classification digest and operator mapping. It makes no deployment qualification
claim and does not replace the dated receipts below. The real PostgreSQL/MinIO
classification suite is `src/tests/adapters/test_minio_storage_capture.py`.

When `writeitai/ultimate-memory-cloud` pins this engine:

- Rebuild the pinned engine/runtime artifacts and update `runtime/engine.lock`.
Regenerate the native source, expected schema definition/profile and native
qualification/profile preimages for `p9_52_0073`, including the new corpus
page and `spine/corpus_export.py`'s served selector, plus
`core/corpus_export.py`'s builder policy, reader-kind registry, original naming
and revision function and `model/conversion.py`'s asset-name contract. The
source artifact pin must cover their dependency closure. Regenerate the managed
runtime source digest and producer identity at that actual engine/image pin.
- Feed the resulting `NativeCaptureProfile` and existing provider/clock/run
bounds into `runtime/src/umc_runtime/storage_capture_profile.py`'s
`managed_capture_profile`. Let the engine builder regenerate each deployment's
classification, operator mapping and request identities; register/accept those
exact new profiles in the receiver. Existing completed captures retain their
original bytes and identities. This engine fixture's synthetic hashes are
test inputs and must never be installed as deployment pins.
- Reinstall **both** `install_native_relation_guard` and
`install_native_capture_catalog` on each migrated Project DB under the existing
restricted roles. The fixed catalog now pins `documents`, versions, metadata
and sections in addition to its previous E0 relations, reads the same served
selection as publication, and ignores historical projection rows. Requalify
installed function bytes/owners/search paths/ACLs, original-view timing and
nonempty live-tree quantities before accepting new chargeable evidence.
- Keep the existing `raw`, `artifacts`, `corpus`, `forget` store bindings and
`capture_storage_batch` call. No new store role, runtime callback, corpus
manifest reader, scheduler or wire purpose/component is required. The three
new included native classes use `projection_origin`/`p3_origin`; the incomplete
class maps to excluded `staging`. Provider, clock and resource bounds require
renewed acceptance only according to their actual qualification evidence,
never merely because source hashes were regenerated.

Completed results expose `manifest`, `native_witness`, `provider_manifest` and
`iter_page_bytes()` from the required durable store. Lost delivery replays those
exact completed bytes without reopening a native/provider cut. The final
manifest is written only after all pages and original evidence are durable.
ACK checking and financial settlement remain independent existing contracts.

The checked implementation source is `52d6c2767`. Its actual composed native
The historical 2026-11-11 validation used source `52d6c2767`. Its composed native
run and exact quantities are recorded in the [dated validation receipt](storage-capture-managed-assembly-validation-20261111.json).
The run recorded two scopes at one cut, one provider invocation and the same
actual S3 provider. Canonical-object quantities were 0 and 18 bytes. It recorded
Expand Down
12 changes: 10 additions & 2 deletions docs/development/storage-capture-original-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ private schema must be pinned by the qualified native profile.

`iter_store_references` reads actual catalog locator seeds without live/current
or success-only filters: raw objects; all five representation URI fields;
structure sidecars; supplied reference artifacts; projection trees; K page and
structure sidecars; supplied reference artifacts; K page and
curation paths; K planner/compiler transcripts; and every native forget
intent, including `preparing`. A forget seed carries its actual UUID with
`locator_kind=journal_intent`; the qualified journal adapter derives its
concrete key and proves stored presence. PostgreSQL alone cannot assert the
ObjectStore or LocalFS journal layout. Native content identities and locators use private fields with
suppressed repr/validation inputs. Trees, manifests, K origin/history and
suppressed repr/validation inputs. Manifests, K origin/history and
unmatched store resources still require the engine's qualified store profile
and complete provider evidence. A locator seed is neither a provider item nor
a publishable storage member. Missing lengths remain unknown; reference
Expand All @@ -88,6 +88,14 @@ receipt digest. Post-cut rows and ACK changes cannot alter this original view.
Both iterators use fixed keyset pages of at most 1,024 rows, with no later
pool or caller-supplied SQL.

`iter_corpus_documents` uses the same original view and page bound. It returns
each document's recorded cleanup folders, including deleted/unselected rows,
and its nullable served-reading inputs. The classifier recomputes the current
D155 publication revision before expanding reader-file references. Paths alone
do not prove publication; no snapshot registry is consulted. All selector joins
are pinned with AccessShare during acquisition. Both helpers require exact
schema head `p9_52_0073`.

The first native run exposed a real integration boundary: the guard's native
index exclusions hold AccessExclusive on `deployments_pkey`. Reading public
deployment/configuration rows under that guard tried to read the locked index
Expand Down
47 changes: 47 additions & 0 deletions plan/analysis/live_corpus_storage_capture_20261114.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# D155 live corpus capture classification

D152 capture still expanded retired immutable projection manifests after D155
replaced that writer with a mutable document tree. A folder's presence in
`documents.corpus_paths` proves only that publication might have written it:
the set is committed before IO and retained across failed moves and cleanup.
Treating every recorded prefix as published would count incomplete copies.

The existing served-reading selector supplies all DB inputs to
`desired_export_revision`. Read those inputs and every document's recorded paths
through the original bounded native capture view. Require the current marker
to match that revision and the recorded set to contain exactly the desired
folder. Expand its known reader files from the hash-bound immutable conversion
inventory. Do not read mutable corpus `document.json` as publication authority.
Missing required files refuse completion. Other files beneath a valid D155
suffix folder are staging, including unrecorded paths, deleted/forgotten
documents and interrupted publication. Unknown keys outside the writer grammar
refuse capture instead of inheriting an inclusion rule.

Limit the document page before joining served inputs and seek using the native
UUID index, so advancing a page does not rescan all earlier UUID text values.
The first page includes UUID zero; subsequent pages exclude their cursor row.

Retain D152's purpose/component vocabulary: separate native classes identify
corpus original copies, derivatives and navigation, all `projection_origin` in
`p3_origin`. Raw originals remain `canonical_raw` in `canonical_object`. Thus
equal payloads at different physical keys remain different resources and
corpus copies never inflate canonical-original quantities. Shared navigation
uses the current type/topic/radix grammar; an incomplete document's own index
is staging with the rest of that folder.

Alternatives rejected: snapshot-manifest support would preserve a second
classifier without a writer; prefix-only attribution would bill partial writes;
trusting a non-null marker without recomputing its input identity would accept
stale metadata or policy; introducing a publication table or counter duplicates
D155's existing inputs and marker. D155's accepted late-request repair race
remains: the marker proves a successful publication of these inputs, not an
atomic or byte-immutable tree. Provider evidence owns existence, version and
quantity at the requested cut; current listings supply private names only.

`projection_snapshots` is still read by `OperationalCatalog.inspect` for the
historical `/operations.latest_projections` field. Retain that relation and its
PostgreSQL allocation rule; remove it from the capture reader's extraction
locks and locator reads. No migration or API export change is needed. Pin both
native capture helpers to the actual `p9_52_0073` head, without an old-head
fallback. Generated regression profiles are synthetic inputs, never operator
clock, provider, image or cost qualification. No paid-work identity changes.
4 changes: 4 additions & 0 deletions plan/analysis/managed_storage_profile_20261111.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ non-null native repository URI. A zero K component still requires that closed
runtime source/configuration and the complete original native inventory;
loading `knowledge_repository=unconfigured` is no absence proof.

The snapshot classification in the next paragraph is historical and superseded
by [D155 live-tree classification](live_corpus_storage_capture_20261114.md).
The PostgreSQL snapshot relation remains only for the historical operations API.

P3 cannot be blanket-declared absent: managed `umc_runtime/setup.py:run_setup`
calls `SelfHostProfile.setup`, whose facts-layer reconciliation can call
`run_projection(p3)` (`profiles/selfhost.py`, around lines 1241–1244). The
Expand Down
15 changes: 15 additions & 0 deletions plan/designs/storage_capture_consumer_design.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,21 @@ excluded operator resources or suppress their cost. A mixed physical root
without an accepted exact mapping yields no chargeable component result.
The captured allocation/purpose remains evidence; it is not zero.

Under D155, corpus capture reads `documents.corpus_paths` and the served
reading's publication inputs in the original native view. A recorded folder is
only a cleanup target until its nullable marker matches the current export
revision and its recorded set is exactly the desired folder. Expand known
original/derivative files through the hash-bound immutable E0 inventory; never
use mutable corpus metadata as publication authority. Separate native classes
identify corpus original copies, derivatives and navigation (`projection_origin`,
`p3_origin`), while canonical raw originals remain `canonical_raw` in
`canonical_object`. Shared type/topic/radix `_index.md` and root `llms.txt` are
navigation. Other objects beneath D155 document folders, including stale,
updating, deleted/forgotten and unrecorded folders, are excluded `staging`.
Unknown keys outside that writer grammar refuse completion. The marker retains
D155's once-published meaning and accepted late-request repair race, rather
than asserting a whole-tree snapshot. [Classification rationale](../analysis/live_corpus_storage_capture_20261114.md).

Serving a durable P3 origin in place does not create another physical copy.
An additional staging/served tree is a distinct operator replica. Distinct
raw/artifact and P3 objects stay distinct resources even when their payloads
Expand Down
143 changes: 143 additions & 0 deletions scripts/generate_storage_capture_fixture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
"""Generate synthetic D152 regression pins; never deployed qualification.

Run with the engine environment and PYTHONPATH=src:. --check compares exact
bytes. Operator source/image/clock/cost acceptance remains separate. Historical
dated production/functional receipts are evidence and are never regenerated.
"""

from __future__ import annotations

import argparse
import base64
import hashlib
import json
from pathlib import Path

from alembic.config import Config
from alembic.script import ScriptDirectory

from rememberstack.profiles.storage_capture_profile import build_managed_storage_profile
from rememberstack.profiles.storage_capture_profile import current_class_rules
from rememberstack.profiles.storage_capture_profile import ManagedFilesystemBinding
from rememberstack.profiles.storage_capture_profile import ManagedStoreBindings
from rememberstack.spine import catalog_contract
from rememberstack.spine.storage_capture_catalog import NativeCatalogAcquisition
from rememberstack.spine.storage_capture_catalog import NativeCorpusPage
from rememberstack.spine.storage_capture_catalog import NativeReferencePage
from rememberstack.spine.storage_capture_catalog import NativeTerminalPage
from rememberstack.spine.storage_capture_guard import _EXTENSIONS
from rememberstack.spine.storage_capture_guard import _ROOTS
from rememberstack.spine.storage_capture_guard import NativeRelationGuardSample
from rememberstack.spine.storage_capture_view import NativeCaptureProfile

ROOT = Path(__file__).resolve().parents[1]
FIXTURE = ROOT / "src/tests/fixtures/storage_capture/live_corpus_profile.json"


def _digest(domain: str, document: object) -> str:
body = json.dumps(
document, sort_keys=True, ensure_ascii=True, separators=(",", ":")
).encode()
return hashlib.sha256(domain.encode() + b"\0" + body).hexdigest()


def capture() -> dict[str, object]:
"""Derive schema, source, classification, mapping and native test pins."""
source = {
str(path.relative_to(ROOT)): hashlib.sha256(path.read_bytes()).hexdigest()
for path in sorted((ROOT / "src/rememberstack").rglob("*.py"))
}
schema = {
"head": ScriptDirectory.from_config(
Config(str(ROOT / "alembic.ini"))
).get_current_head(),
"catalog": {
name: getattr(catalog_contract, name)
for name in sorted(vars(catalog_contract))
if name.startswith("EXPECTED_")
},
"guard_roots": _ROOTS,
"extensions": _EXTENSIONS,
"migrations": {
path.name: hashlib.sha256(path.read_bytes()).hexdigest()
for path in sorted(
(ROOT / "src/rememberstack/spine/migrations/versions").glob("*.py")
)
},
"records": {
model.__name__: model.model_json_schema()
for model in (
NativeRelationGuardSample,
NativeCatalogAcquisition,
NativeReferencePage,
NativeCorpusPage,
NativeTerminalPage,
)
},
}
schema_digest = _digest("rememberstack.test_schema.v1", schema)
native_inputs = {
"source_digest": _digest("rememberstack.test_engine_source.v1", source),
"schema_digest": schema_digest,
"schema_profile_digest": _digest(
"rememberstack.test_schema_profile.v1", schema
),
"clock_profile_digest": "5" * 64,
"clock_error_us": "1000",
"view_lifetime_ms": 30_000,
"release_margin_us": 500_000,
}
native = NativeCaptureProfile(
profile_digest=_digest("rememberstack.test_native_profile.v1", native_inputs),
**native_inputs, # type: ignore[arg-type]
)
bindings = ManagedStoreBindings(
deployment_id="0" * 31 + "1",
postgres_database_name="rememberstack",
provider_organisation_id="1" * 32,
provider_cell_id="synthetic-cell",
filesystems=tuple(
ManagedFilesystemBinding(
role=role,
filesystem_id=base64.b32encode(bytes([number]) * 16)
.decode()
.rstrip("=")
.lower(),
)
for number, role in enumerate(("artifacts", "corpus", "forget", "raw"))
),
)
profile = build_managed_storage_profile(
native=native,
bindings=bindings,
managed_runtime_source_digest="6" * 64,
provider_profile_digest="a" * 64,
provider_clock_profile_digest="b" * 64,
)
return {
"kind": "synthetic_live_corpus_regression_not_deployment_qualification",
"schema": schema,
"profile": profile.model_dump(mode="json"),
"request": profile.request(cut_at_unix_us="1800000000000000").model_dump(
mode="json"
),
"source_rules": current_class_rules(),
}


def render() -> str:
return json.dumps(capture(), indent=2, sort_keys=True, ensure_ascii=True) + "\n"


if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--check", action="store_true")
args = parser.parse_args()
body = render()
if args.check:
if FIXTURE.read_text() != body:
raise SystemExit(
"storage capture regression fixture is stale; run its generator"
)
else:
FIXTURE.write_text(body)
Loading
Loading