Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
28afc9c
Retire the hosted Supabase mirror and query_sources
MaxGhenis Oct 12, 2026
975d27b
Correct the retirement history and tighten its guards
MaxGhenis Oct 12, 2026
98cca22
Resolve relative imports in the Supabase importer guard
MaxGhenis Oct 12, 2026
9017d36
Say plainly what the other sweep matches were
MaxGhenis Oct 12, 2026
8811fc5
Merge main into retire/supabase-mirror
MaxGhenis Nov 14, 2026
158cf40
Delete the Supabase client and the supabase dependency
MaxGhenis Nov 14, 2026
eb9df0a
Keep the lock's revision line at 5
MaxGhenis Nov 14, 2026
43ad958
Guard chronicle.__all__ and literal dynamic imports of the client
MaxGhenis Nov 14, 2026
58dea21
Narrow the retirement record's claim about the rename plan
MaxGhenis Nov 14, 2026
4f0041c
Name ledger.db, not a hosted database, as the README's provenance store
MaxGhenis Nov 14, 2026
cef0441
Stop the legacy-ETL record assuming a hosted mirror exists
MaxGhenis Nov 14, 2026
bb7096e
Widen the retired-mirror guards past the supabase package itself
MaxGhenis Nov 14, 2026
b2067e2
Date the changelog's hosted-project and consumer-search claims
MaxGhenis Nov 14, 2026
e42325d
Wrap one long line in the retirement record
MaxGhenis Nov 14, 2026
fef8165
Skip __import__ levels deeper than the package in the import guard
MaxGhenis Nov 15, 2026
32f899d
Merge main at 2f2f672b into retire/supabase-mirror
MaxGhenis Nov 15, 2026
ed397f4
Count only import-function calls in the import guard
MaxGhenis Nov 15, 2026
c1307be
Stop the storage doc promising validation status in ledger.db
MaxGhenis Nov 15, 2026
ec4a9fe
Pin the import guard's alias scan to a fixpoint
MaxGhenis Nov 15, 2026
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
41 changes: 15 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ contract that aligns it to another period (see
The storage split is documented in
[`docs/storage-architecture.md`](docs/storage-architecture.md): `ledger-raw`
stores immutable source bytes, `ledger-derived` stores reproducible build
artifacts, and Supabase/Postgres hosts the queryable relational Chronicle registry
mirrored from accepted builds.
artifacts, and each build's SQLite `ledger.db` is the queryable relational
artifact. There is no hosted relational mirror
([`docs/supabase-mirror-retirement.md`](docs/supabase-mirror-retirement.md)).

## Repository Model

Expand Down Expand Up @@ -112,7 +113,6 @@ chronicle/
│ ├── jurisdictions/ # Temporary in-repo jurisdiction source prototypes
├── db/ # Source-artifact store and packaged source files
│ ├── schema.py # SQLModel: SourceArtifact, SourceTable, SourceRow
│ ├── supabase_client.py # Supabase client helpers
│ └── data/ # Publisher files that source packages read
├── data/ # Cached data files
└── docs/ # Architecture and source documentation
Expand Down Expand Up @@ -191,8 +191,9 @@ This writes queryable Chronicle-owned tables such as `source_rows`,
`source_columns`, `source_row_values`, `source_cells`, `aggregate_facts`,
`aggregate_constraints`, `concept_alignments`, `fact_source_cells`, and
`fact_source_rows`. The DB is a deterministic build artifact from source
manifests, parsers, and checked-in specs; hosted Postgres/Supabase should mirror
this schema rather than become the unreproducible origin of source-backed facts.
manifests, parsers, and checked-in specs; a hosted copy, if one is ever
reintroduced, should mirror this schema rather than become the unreproducible
origin of source-backed facts.

On the same Python and SQLite build, identical inputs write a byte-identical
`ledger.db`, so a rebuilt suite's `ledger.db`, `datapackage.json` and
Expand Down Expand Up @@ -414,8 +415,8 @@ uv run chronicle scaffold-package --source-id irs_soi --package-id soi-table-1-2

Raw source artifacts should be content-addressed and checksum-locked before a
package spec depends on them. Tiny fixtures can stay in Git, but production raw
files should live in private Cloudflare R2 buckets, with `manifest.yaml` and the
hosted database carrying the queryable provenance.
files should live in private Cloudflare R2 buckets, with `manifest.yaml` and
each build's `ledger.db` carrying the queryable provenance.

The buckets live on the PolicyEngine Cloudflare account, which `wrangler.toml`
pins via `account_id`, so a plain `wrangler login` as any account member is the
Expand Down Expand Up @@ -498,7 +499,7 @@ include `--upload-r2`; semantic target work still requires a package to pass
publisher-source lookup clues; they should not become canonical Chronicle source
artifacts or target provenance.

R2 owns the immutable bytes. Chronicle manifests and Supabase/Postgres mirrors own
R2 owns the immutable bytes. Chronicle manifests and the `ledger.db` artifact own
metadata such as source URL, checksum, size, vintage, extraction date, and R2
key. Source-package parsers still read deterministic local/package resources,
so builds remain reproducible without making hosted storage the source of
Expand All @@ -511,8 +512,8 @@ uv run chronicle build-suite soi-table-1-4 --year 2023 --out /tmp/chronicle-suit
uv run chronicle build-suite packages/irs_soi/table_1_4 --year 2023 --out /tmp/chronicle-suite-1-4 --replace
```

To prepare the deterministic SQLite artifact for a hosted Supabase/Postgres
mirror, export each relational table to JSONL plus a manifest:
To load the deterministic SQLite artifact into another store, export each
relational table to JSONL plus a checksummed manifest:

```bash
uv run chronicle export-db-tables --db /tmp/chronicle-suite/ledger.db --out /tmp/chronicle-mirror --replace
Expand All @@ -529,22 +530,10 @@ uv run chronicle publish-derived \
--build-artifacts-out /tmp/chronicle-build-artifacts.jsonl
```

The Supabase schema for this mirror lives at
`supabase/migrations/20260504_chronicle_bronze.sql`. Raw government spreadsheets are
mirrored as artifact metadata plus one row per parsed cell, not one tidy table
per sheet. Chronicle does not host raw survey microdata tables.

After the migration is applied and the `chronicle` schema is exposed through the
Supabase Data API, accepted mirror exports can be upserted with:

```bash
uv run chronicle load-supabase-mirror \
--dir /tmp/chronicle-mirror \
--build-artifacts /tmp/chronicle-build-artifacts.jsonl
```

Use `--dry-run` first to validate JSONL row counts and file coverage without
writing to Supabase.
Raw government spreadsheets are stored as artifact metadata plus one row per
parsed cell, not one tidy table per sheet. Chronicle does not host raw survey
microdata tables. There is no hosted load step: the Supabase mirror loader was
retired (see `docs/supabase-mirror-retirement.md`).

Chronicle facts keep source concepts and canonical concepts separately. For example,
the SOI Table 1.1 adjusted gross income column is preserved as
Expand Down
28 changes: 28 additions & 0 deletions changelog.d/supabase-mirror-retired.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Retire the hosted Supabase mirror path and the Supabase client:
- the `chronicle load-supabase-mirror` command, with `load_supabase_mirror`,
`SupabaseMirrorLoadReport` and `SupabaseTableLoad` in `chronicle.mirror` and
`load_supabase_mirror_files` in `chronicle.harness`
- `query_sources` (`db.supabase_client`, `chronicle.sources`,
`chronicle.sources.client`, `policyengine_chronicle.sources`)
- the `POLICYENGINE_LEDGER_SCHEMA` setting and `db.supabase_client.LEDGER_SCHEMA`
- the `db.supabase_client` module (`SupabaseConfig`, `get_supabase_client`) and
`chronicle.client`, which re-exported it
- the `supabase` dependency and the packages only it required

Since the 2026-06-30 Ledger rename the loader and `query_sources` defaulted to
a `ledger` schema. Read-only checks on 2026-10-12 found no such schema in the
configured Supabase project, so every call with the default schema failed with
`PGRST106 Invalid schema: ledger`. They also found that nothing had read the
copy an earlier version of the loader wrote under `arch`. The client's other
callers, the legacy target-input helpers, were retired first (chronicle#353),
so no shipped module imports a Supabase client. `chronicle export-db-tables`
is unchanged and still writes every `ledger.db` table to JSONL with a
checksummed manifest.

`pypdf` is now required with its `crypto` extra. pypdf needs `cryptography` to
read one AES-encrypted publisher PDF, and `cryptography` used to arrive only
through `supabase`.

Migration: searches on 2026-10-12 found no repository outside Chronicle that
imports these names. Read `ledger.db` from `ledger-derived` or build the
consumer-fact export instead. See `docs/supabase-mirror-retirement.md`.
1 change: 0 additions & 1 deletion chronicle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

__all__ = [
"bundle",
"client",
"concepts",
"consumer_contract",
"core",
Expand Down
1 change: 0 additions & 1 deletion chronicle/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def main() -> None:
["export-db-tables"],
["fetch-artifact"],
["inventory-artifacts"],
["load-supabase-mirror"],
["plan-pe-sources"],
["publish-derived"],
["publish-raw"],
Expand Down
5 changes: 0 additions & 5 deletions chronicle/client.py

This file was deleted.

2 changes: 1 addition & 1 deletion chronicle/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The database is a Chronicle-owned query surface for source-backed aggregate facts.
It is deterministic output from source artifacts, selectors, and aggregate facts;
hosted systems such as Supabase can mirror this schema later. With the same
a hosted store can mirror this schema later. With the same
Python and SQLite build, identical inputs give byte-identical files:
``ledger_builds.created_at`` comes from ``SOURCE_DATE_EPOCH``, never the wall
clock.
Expand Down
72 changes: 1 addition & 71 deletions chronicle/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@
)
from chronicle.core import AggregateFact, ValidationReport, validate_facts
from chronicle.database import ChronicleDbBuildReport, build_chronicle_db
from chronicle.mirror import (
ChronicleMirrorExportReport,
SupabaseMirrorLoadReport,
export_chronicle_db_tables,
load_supabase_mirror,
)
from chronicle.mirror import ChronicleMirrorExportReport, export_chronicle_db_tables
from chronicle.pe_source_plan import (
PeSourcePlanReport,
build_pe_source_plan,
Expand Down Expand Up @@ -465,29 +460,6 @@ def export_chronicle_db_table_files(
return export_chronicle_db_tables(db_path, output_dir, replace=replace)


def load_supabase_mirror_files(
input_dir: str | Path,
*,
schema: str = "ledger",
batch_size: int = 500,
dry_run: bool = False,
build_artifacts_path: str | Path | None = None,
) -> SupabaseMirrorLoadReport:
"""Load exported Chronicle JSONL mirror files into Supabase/Postgres."""
table_paths = (
{"build_artifacts": Path(build_artifacts_path)}
if build_artifacts_path is not None
else None
)
return load_supabase_mirror(
input_dir,
schema=schema,
batch_size=batch_size,
dry_run=dry_run,
table_paths=table_paths,
)


def plan_pe_source_files(
manifest_path: str | Path,
*,
Expand Down Expand Up @@ -1142,38 +1114,6 @@ def main(argv: list[str] | None = None) -> int:
help="Replace an existing nonempty output directory",
)

mirror_load_parser = subparsers.add_parser(
"load-supabase-mirror",
help="Load exported Chronicle JSONL mirror files into Supabase/Postgres",
)
mirror_load_parser.add_argument(
"--dir",
type=Path,
required=True,
help="Directory containing exported per-table JSONL files.",
)
mirror_load_parser.add_argument(
"--schema",
default="ledger",
help="Supabase/Postgres schema to load into.",
)
mirror_load_parser.add_argument(
"--batch-size",
type=int,
default=500,
help="Rows per Supabase upsert batch.",
)
mirror_load_parser.add_argument(
"--dry-run",
action="store_true",
help="Count rows and validate files without writing to Supabase.",
)
mirror_load_parser.add_argument(
"--build-artifacts",
type=Path,
help="Optional build_artifacts JSONL path to use instead of the file in --dir.",
)

pe_plan_parser = subparsers.add_parser(
"plan-pe-sources",
help="Build an agent batch plan from a PE source manifest CSV",
Expand Down Expand Up @@ -1463,16 +1403,6 @@ def main(argv: list[str] | None = None) -> int:
)
print(json.dumps(report.to_dict(), indent=2, sort_keys=True))
return 0
if args.command == "load-supabase-mirror":
report = load_supabase_mirror_files(
args.dir,
schema=args.schema,
batch_size=args.batch_size,
dry_run=args.dry_run,
build_artifacts_path=args.build_artifacts,
)
print(json.dumps(report.to_dict(), indent=2, sort_keys=True))
return 0 if report.valid else 1
if args.command == "plan-pe-sources":
report = plan_pe_source_files(
args.manifest,
Expand Down
Loading
Loading