mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-17 03:59:28 +00:00
feat(corpus-seeded-mechanisms): the mechanisms lever admits or retracts exporter records
Task 4.1 (Req 5.1, 5.2, 5.5). - validator: MechanismEdit (admit | retract by record id) under the `mechanisms` lever; validate_mechanism accepts only records from the exporter candidate set with origin corpus, a closed guard and source kinds, and identifier-only shape text; free-form shapes are rejected. - apply_mechanism_edits appends the record (admit) or a retracted tombstone (retract) so the log stays append-only; StoreSnapshot.restore reverts byte for byte. MechanismStore.load folds tombstones away. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01T7XD7x5KonMdmGRkp63EQG
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
f11cf183de
commit
73e856a06b
@@ -37,6 +37,7 @@ class Mechanism:
|
||||
pairs: tuple[str, ...] = ()
|
||||
shape: dict[str, object] | None = None # Shape.to_dict(); None on sandbox rows (not searchable)
|
||||
guard: str = "none"
|
||||
retracted: bool = False # tombstone row appended by the improve lever; load() folds the record away
|
||||
|
||||
|
||||
class MechanismStore:
|
||||
@@ -53,7 +54,10 @@ class MechanismStore:
|
||||
continue
|
||||
payload = json.loads(line)
|
||||
record = _mechanism_from_payload(payload)
|
||||
by_id[record.id] = record
|
||||
if record.retracted:
|
||||
by_id.pop(record.id, None)
|
||||
else:
|
||||
by_id[record.id] = record
|
||||
return tuple(by_id.values())
|
||||
|
||||
def append(self, mechanism: Mechanism) -> None:
|
||||
@@ -340,8 +344,9 @@ def _mechanism_from_payload(payload: dict[str, object]) -> Mechanism:
|
||||
origin=str(payload.get("origin", "sandbox")),
|
||||
review_tier=str(payload.get("review_tier", "")),
|
||||
pairs=tuple(str(item) for item in pairs),
|
||||
shape=Shape.from_dict(shape).to_dict() if isinstance(shape, dict) else None,
|
||||
shape=dict(shape) if isinstance(shape, dict) else None, # validated where it is used (search_tree, the lever)
|
||||
guard=str(payload.get("guard", "none")),
|
||||
retracted=bool(payload.get("retracted", False)),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user