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:
@@ -99,3 +99,59 @@ export function unmapAction(change: MappingChange): Promise<void> {
|
||||
});
|
||||
return apiDelete(`/api/retrieval/moments/mappings?${q.toString()}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Proposals that a rule belongs on a moment (milestone 458 step 7) — from a
|
||||
* pass that read the rule, or from the rule being opened just after the
|
||||
* moment fired. `GET /api/retrieval/moments/proposals`, the payload the
|
||||
* `rule_moment_proposals` MCP tool returns.
|
||||
*/
|
||||
export type ProposalSource = "pass" | "signal" | "edit";
|
||||
|
||||
export interface MomentProposal {
|
||||
moment: string;
|
||||
source: ProposalSource;
|
||||
why: string;
|
||||
evidence: { situations: number; projects: number; co_surfaced: number };
|
||||
created_at: string | null;
|
||||
}
|
||||
|
||||
export interface RuleProposals {
|
||||
id: number;
|
||||
title: string;
|
||||
kind: string;
|
||||
statement: string;
|
||||
when_to_apply: string;
|
||||
home: "global" | "project";
|
||||
/** What the rule is mounted on now. */
|
||||
mounted: string[];
|
||||
proposals: MomentProposal[];
|
||||
}
|
||||
|
||||
export interface ProposalsPayload {
|
||||
rules: RuleProposals[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export type Verdict = "confirm" | "reject";
|
||||
|
||||
export interface MomentJudgment {
|
||||
rule_id: number;
|
||||
moment: string;
|
||||
verdict: Verdict;
|
||||
note?: string;
|
||||
}
|
||||
|
||||
export interface JudgeResult {
|
||||
judged: { rule_id: number; moment: string; state: string }[];
|
||||
refused: { rule_id: number; moment?: string; error: string }[];
|
||||
}
|
||||
|
||||
export function getProposals(ruleId?: number): Promise<ProposalsPayload> {
|
||||
return apiGet(`/api/retrieval/moments/proposals${ruleId ? `?rule_id=${ruleId}` : ""}`);
|
||||
}
|
||||
|
||||
/** A confirm MOUNTS the rule on the moment; a reject stops it being proposed again. */
|
||||
export function judgeProposals(judgments: MomentJudgment[]): Promise<JudgeResult> {
|
||||
return apiPost("/api/retrieval/moments/proposals/judge", { judgments });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user