feat(slice3): persist entry metadata to cached_rfcs.meta_json at ingest (§22.4a)

This commit is contained in:
Ben Stull
2026-06-07 17:33:47 -07:00
parent 3636fa5afd
commit 644bf35d89
+8 -2
View File
@@ -170,6 +170,10 @@ def _upsert_cached_rfc(
# §6.7: funder_login mirrors the optional `funder:` frontmatter
# field. NULL means absent — operator credentials are used.
funder_login = entry.funder or None
# §22.4a SLICE-3: persist the full per-entry metadata mapping (known keys +
# extra, never the body) so facet/filter can read any declared field. Stored
# via metadata_dict so the sidecar's forward-compat keys (INV-7) ride along.
meta_json = json.dumps(metadata_mod.metadata_dict(entry))
db.conn().execute(
"""
INSERT INTO cached_rfcs
@@ -177,8 +181,8 @@ def _upsert_cached_rfc(
graduated_at, graduated_by, owners_json, arbiters_json, tags_json,
models_json, funder_login, body, body_sha,
unreviewed, reviewed_at, reviewed_by, collection_id,
metadata_malformed, last_entry_commit_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, datetime('now'), datetime('now'))
metadata_malformed, meta_json, last_entry_commit_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, datetime('now'), datetime('now'))
ON CONFLICT(collection_id, slug) DO UPDATE SET
title = excluded.title,
state = excluded.state,
@@ -199,6 +203,7 @@ def _upsert_cached_rfc(
reviewed_at = excluded.reviewed_at,
reviewed_by = excluded.reviewed_by,
metadata_malformed = excluded.metadata_malformed,
meta_json = excluded.meta_json,
last_entry_commit_at = datetime('now'),
updated_at = datetime('now')
""",
@@ -224,6 +229,7 @@ def _upsert_cached_rfc(
entry.reviewed_by,
collection_id,
1 if metadata_malformed else 0,
meta_json,
),
)