feat(slice4): POST .../meta single-entry edit endpoint + GET RFC meta/can_edit_meta (§22.4a PUC-1)

Direct-commit to the sidecar (D7), contributor+ gated (INV-4), schema-validated
at the write boundary, lazy-migrates a legacy entry, re-ingests. GET RFC now
returns the per-entry meta mapping and a can_edit_meta capability.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ben Stull
2026-06-07 19:00:40 -07:00
parent aee9b582e5
commit d687a65470
3 changed files with 245 additions and 0 deletions
+12
View File
@@ -29,6 +29,7 @@ from . import (
api_invitations,
api_join_requests,
api_memberships,
api_metadata,
api_notifications,
api_prs,
auth,
@@ -130,6 +131,8 @@ def make_router(
router.include_router(api_prs.make_router(config, gitea, bot, providers))
# Slice 5: §13 graduation + §13.1 claim.
router.include_router(api_graduation.make_router(config, gitea, bot))
# §22.4a SLICE-4/5: entry metadata edit + Owner-gated collection migrate.
router.include_router(api_metadata.make_router(config, gitea, bot))
# Slice 6: §15 notifications surface (inbox, watches, prefs,
# quiet hours, per-user mute, email unsubscribe, bounce webhook).
router.include_router(api_notifications.make_router(config))
@@ -721,6 +724,9 @@ def make_router(
(slug,),
).fetchone()
payload["proposed_use_case"] = uc["use_case"] if uc else None
# §22.4a SLICE-4: contributor+ on the entry's collection may edit metadata.
payload["can_edit_meta"] = bool(
auth.can_contribute_in_collection(viewer, auth.collection_of_rfc(slug)))
return payload
# ---------------------------------------------------------------
@@ -839,6 +845,9 @@ def make_router(
(slug, collection_id),
).fetchone()
payload["proposed_use_case"] = uc["use_case"] if uc else None
# §22.4a SLICE-4: contributor+ on the collection may edit metadata (INV-4).
payload["can_edit_meta"] = bool(
auth.can_contribute_in_collection(viewer, collection_id))
return payload
@router.get("/api/projects/{project_id}/rfcs")
@@ -1387,6 +1396,9 @@ def _serialize_rfc(row) -> dict[str, Any]:
"tags": json.loads(row["tags_json"] or "[]"),
"body": row["body"] or "",
"metadata_malformed": bool(row["metadata_malformed"]),
# §22.4a SLICE-4: the full per-entry metadata mapping (known + custom
# fields) so the detail panel can render schema-driven controls.
"meta": json.loads(row["meta_json"] or "{}"),
}