feat(moments): mount the corpus by proposal - a pass and an open-after-moment signal, both stopping at the operator (milestone 458 step 7, #4925)
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 19s
CI & Build / integration (push) Failing after 43s
CI & Build / Python tests (push) Failing after 46s
CI & Build / TypeScript typecheck (push) Successful in 55s
CI & Build / Build & push image (push) Skipped
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 19s
CI & Build / integration (push) Failing after 43s
CI & Build / Python tests (push) Failing after 46s
CI & Build / TypeScript typecheck (push) Successful in 55s
CI & Build / Build & push image (push) Skipped
A rule written before moments existed is mounted on nothing. Step 7 records, per (rule, moment), whether it belongs there and who said so: - rule_moment_judgments (migration 0118, backup v23): suggested / confirmed / rejected, from a pass, the signal, or an edit. Moment "" is "no moment fits". - The pass: rules_to_mount lists unjudged rules; propose_rule_moments records suggestions that mount nothing; rule_moment_proposals and judge_rule_moments put them to the operator. A confirm mounts, a reject is kept so the pair is never proposed again. Same service behind REST and a "Waiting on you" panel in Settings > Moments. - Edits are judgments: set_rule_moments, the one mount write path, confirms what was added and rejects what was removed in the same transaction. - The signal: scribe_moment.sh keeps a per-session acts ledger; when a rule is opened, scribe_record_opened.sh sends the last three minutes of it to /api/plugin/rule-opened. The acts resolve through the install's mappings; work.run and work.change are not evidence. Counted per distinct session with lesson_rules' evidence model, and once due the open returns one line asking the reader to offer the mount. - scribe_session_end.sh removes the session's scribe-moment files. Plugin 2026.10.05.2003. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1111,7 +1111,8 @@ async def set_rule_systems(
|
||||
|
||||
|
||||
async def set_rule_moments(
|
||||
rule_id: int, user_id: int, moments: list[str],
|
||||
rule_id: int, user_id: int, moments: list[str], *,
|
||||
note: str = "", judged=(), verdict: str | None = None,
|
||||
) -> list[str] | None:
|
||||
"""Replace which MOMENTS a rule arrives at (milestone 458). None if not owned.
|
||||
|
||||
@@ -1119,15 +1120,24 @@ async def set_rule_moments(
|
||||
Every name is checked against the catalog first and the whole write is
|
||||
refused on the first unknown one — a typo stored as a mount would read
|
||||
back as attached and never fire, the silent miss moments exist to end.
|
||||
|
||||
THE ONE WRITE PATH for mounts, so it is also where a change is recorded as
|
||||
a judgment (step 7): what was added is confirmed, what was removed is
|
||||
rejected, in the same transaction as the mounts. `note`, `judged` and
|
||||
`verdict` come from `rule_moment_judgments.judge`, which says why.
|
||||
"""
|
||||
from scribe.models.rulebook import rule_moments as rule_moments_t
|
||||
from scribe.services.moments import require_moments
|
||||
from scribe.services.rule_moment_judgments import record_mount_change
|
||||
|
||||
wanted = require_moments(moments) or []
|
||||
async with async_session() as session:
|
||||
rule = await _fetch_owned_rule(session, rule_id, user_id)
|
||||
if rule is None:
|
||||
return None
|
||||
before = (await session.execute(
|
||||
select(rule_moments_t.c.moment).where(rule_moments_t.c.rule_id == rule_id)
|
||||
)).scalars().all()
|
||||
await session.execute(
|
||||
sql_delete(rule_moments_t).where(rule_moments_t.c.rule_id == rule_id)
|
||||
)
|
||||
@@ -1135,6 +1145,9 @@ async def set_rule_moments(
|
||||
await session.execute(
|
||||
insert(rule_moments_t).values(rule_id=rule_id, moment=moment)
|
||||
)
|
||||
await record_mount_change(
|
||||
session, rule_id, before, wanted, note=note, judged=judged, verdict=verdict,
|
||||
)
|
||||
await session.commit()
|
||||
return wanted
|
||||
|
||||
|
||||
Reference in New Issue
Block a user