Cut review over to the sitting PDP and load seven memos.
FLEX-WP-0028 admitted a dedicated package. Runtime ConfigMap and NetworkPolicy now pin flex-auth-informed-decision-sitting. Memos are in the live store for the existing named recipient. No human bind. Assistant: grok Assistant-Session: 01a09dc1-b21e-77e1-919e-fcad2f82b267
This commit is contained in:
parent
ca563504c4
commit
d4b77a8c0e
6 changed files with 115 additions and 15 deletions
|
|
@ -56,13 +56,14 @@ def attach(principal: str, receipt: dict, root: Path = ROOT) -> dict:
|
|||
for row in index["ordinal"]:
|
||||
expected.append((name, row["memo_id"], row["memo"], row["packet"]))
|
||||
requests = receipt.get("requests") or []
|
||||
if len(requests) != len(expected):
|
||||
raise ValueError("receipt must cover every sitting memo once")
|
||||
by_id = {row.get("memo_id"): row for row in requests}
|
||||
if set(by_id) != {memo_id for _, memo_id, _, _ in expected}:
|
||||
raise ValueError("receipt memo set must match the sitting")
|
||||
sitting_ids = {memo_id for _, memo_id, _, _ in expected}
|
||||
if not by_id or set(by_id) - sitting_ids:
|
||||
raise ValueError("receipt memo set must be a non-empty subset of the sitting")
|
||||
prepared = []
|
||||
for name, memo_id, memo_name, packet_name in expected:
|
||||
if memo_id not in by_id:
|
||||
continue
|
||||
approval = _approval(by_id[memo_id], memo_id)
|
||||
memo = memo_from(json.loads((root / name / memo_name).read_text()))
|
||||
if memo.approval_id is not None or memo.binding.principal.id != "pending-human-session":
|
||||
|
|
|
|||
51
tools/load_sitting_memos.py
Normal file
51
tools/load_sitting_memos.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
"""Load bound sitting memos into a review store. Does not present or bind."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from informed_decision.records import memo_from as _memo_from
|
||||
from informed_decision.store import Store
|
||||
|
||||
|
||||
def principal_from_store(store: Store) -> str:
|
||||
with store._connection() as db:
|
||||
rows = list(db.execute("SELECT body FROM presentations"))
|
||||
subs = {json.loads(body)["principal_sub"] for (body,) in rows}
|
||||
if len(subs) != 1:
|
||||
raise ValueError("single live recipient required")
|
||||
value = next(iter(subs))
|
||||
if not value or value == "pending-human-session":
|
||||
raise ValueError("live key-cape subject required")
|
||||
return value
|
||||
|
||||
|
||||
def load(store: Store, bound: Path) -> dict:
|
||||
index = json.loads((bound / "index.json").read_text())
|
||||
if index.get("agent_disposition_forbidden") is not True:
|
||||
raise ValueError("bound sitting index required")
|
||||
loaded = []
|
||||
for row in index["memos"]:
|
||||
memo = _memo_from(json.loads((bound / row["memo"]).read_text()))
|
||||
packet = (bound / row["packet"]).read_bytes()
|
||||
digest = store.put_document(packet)
|
||||
if digest != memo.packet[0].hash:
|
||||
raise ValueError(f"packet digest mismatch for {memo.id}")
|
||||
store.save_memo(memo)
|
||||
loaded.append(memo.id)
|
||||
return {"status": "loaded", "count": len(loaded), "memo_ids": loaded}
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--db", type=Path, required=True)
|
||||
parser.add_argument("--bound", type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
store = Store(args.db)
|
||||
print(json.dumps(load(store, args.bound), indent=2))
|
||||
print("No presentations or dispositions created.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue