feat(7728): a rule declares its enforcement and salience
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / Python lint (push) Successful in 2s
CI & Build / TypeScript typecheck (push) Failing after 21s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / integration (push) Successful in 2m2s
CI & Build / Build & push image (push) Skipped
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / Python lint (push) Successful in 2s
CI & Build / TypeScript typecheck (push) Failing after 21s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / integration (push) Successful in 2m2s
CI & Build / Build & push image (push) Skipped
A rule now carries what it does when it arrives, declared by its author rather than guessed from a score: enforce (the act is checked), hold (the reply or act waits for one read) or inform (a line beside the work, the default). And a salience, high, normal or low, for ranking among rules of the same enforcement at a crowded moment. A preference is always inform. Migration 0128 adds both with CHECKs. Every door carries them: the service, the MCP create and update tools, REST, backup and restore, and the rule editor, which also marks holding and enforced rules in the list. Unknown values are refused rather than mapped. Nothing reads them yet beyond the record; the ordering function and the lifecycle come next in this step, and step 5 decides who holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,6 +54,15 @@ export interface RulebookTopic {
|
||||
*/
|
||||
export type RuleKind = "rule" | "preference";
|
||||
|
||||
/**
|
||||
* What a rule does when it arrives, declared by its author. `inform` puts a
|
||||
* line beside the work; `hold` makes the reply or act it governs wait for one
|
||||
* read; `enforce` checks the act itself. A preference is always `inform`.
|
||||
*/
|
||||
export type RuleEnforcement = "enforce" | "hold" | "inform";
|
||||
/** How a rule ranks among rules of the same enforcement at a crowded moment. */
|
||||
export type RuleSalience = "high" | "normal" | "low";
|
||||
|
||||
/** A new record opened from somewhere that already knows what it is for —
|
||||
* "Adjust this" on a reply shape opens a preference mounted on that shape's
|
||||
* moment. The editor applies it once, when creating. */
|
||||
@@ -70,6 +79,8 @@ export interface Rule {
|
||||
title: string;
|
||||
statement: string;
|
||||
kind: RuleKind;
|
||||
enforcement: RuleEnforcement;
|
||||
salience: RuleSalience;
|
||||
/** WHEN this rule fires — the trigger, not the instruction. */
|
||||
when_to_apply: string;
|
||||
why: string;
|
||||
@@ -113,6 +124,10 @@ export interface RuleHeader {
|
||||
topic_id: number | null;
|
||||
/** Unconditional on the wire (services.rulebooks.rule_brief). */
|
||||
kind: RuleKind;
|
||||
/** Unconditional on the wire, like `kind`. */
|
||||
enforcement: RuleEnforcement;
|
||||
/** Present only when raised or lowered from `normal`. */
|
||||
salience?: RuleSalience;
|
||||
/** A date (YYYY-MM-DD), not a timestamp. */
|
||||
updated_at: string | null;
|
||||
when_to_apply?: string;
|
||||
@@ -217,6 +232,8 @@ export interface RuleWrite {
|
||||
/** Writable from the editor: a preference is not a lesser rule, it is a
|
||||
* different force, and the person writing it is the one who knows which. */
|
||||
kind: RuleKind;
|
||||
enforcement: RuleEnforcement;
|
||||
salience: RuleSalience;
|
||||
when_to_apply: string;
|
||||
why: string;
|
||||
how_to_apply: string;
|
||||
|
||||
@@ -6,7 +6,10 @@ import { useMomentsStore } from "@/stores/moments";
|
||||
import RuleHistoryPanel from "@/components/rules/RuleHistoryPanel.vue";
|
||||
import RuleHomePicker from "@/components/rules/RuleHomePicker.vue";
|
||||
import { apiErrorMessage } from "@/api/client";
|
||||
import { listRulebooks, listTopics, type Rule, type RuleKind, type RulePreset } from "@/api/rulebooks";
|
||||
import {
|
||||
listRulebooks, listTopics,
|
||||
type Rule, type RuleEnforcement, type RuleKind, type RulePreset, type RuleSalience,
|
||||
} from "@/api/rulebooks";
|
||||
|
||||
const props = defineProps<{
|
||||
ruleId: number | null;
|
||||
@@ -26,6 +29,14 @@ const whenToApply = ref("");
|
||||
// followed too faithfully, where a rule mislabelled as a preference is one a
|
||||
// session may quietly rewrite.
|
||||
const kind = ref<RuleKind>("rule");
|
||||
// The server's defaults: a line beside the work, at normal rank.
|
||||
const enforcement = ref<RuleEnforcement>("inform");
|
||||
const salience = ref<RuleSalience>("normal");
|
||||
// A preference carries no force but `inform`, and the server refuses any
|
||||
// other, so switching kind settles it here rather than as a failed save.
|
||||
watch(kind, (k) => {
|
||||
if (k === "preference") enforcement.value = "inform";
|
||||
});
|
||||
const systemIds = ref<number[]>([]);
|
||||
// The moments this rule is mounted on. Catalog moments are
|
||||
// ticked; a named procedure's moment (`skill.<name>`) is typed, since its
|
||||
@@ -123,6 +134,8 @@ async function load() {
|
||||
statement.value = r.statement;
|
||||
whenToApply.value = r.when_to_apply || "";
|
||||
kind.value = r.kind;
|
||||
enforcement.value = r.enforcement ?? "inform";
|
||||
salience.value = r.salience ?? "normal";
|
||||
systemIds.value = (r.systems ?? []).map((sys) => sys.id);
|
||||
ruleMoments.value = [...(r.moments ?? [])];
|
||||
why.value = r.why || "";
|
||||
@@ -135,6 +148,8 @@ async function load() {
|
||||
statement.value = "";
|
||||
whenToApply.value = props.preset?.whenToApply ?? "";
|
||||
kind.value = props.preset?.kind ?? "rule";
|
||||
enforcement.value = "inform";
|
||||
salience.value = "normal";
|
||||
systemIds.value = [];
|
||||
ruleMoments.value = [...(props.preset?.moments ?? [])];
|
||||
why.value = "";
|
||||
@@ -181,6 +196,8 @@ async function save() {
|
||||
statement: statement.value,
|
||||
when_to_apply: whenToApply.value,
|
||||
kind: kind.value,
|
||||
enforcement: enforcement.value,
|
||||
salience: salience.value,
|
||||
// Always sent, so clearing the last area actually clears it — the server
|
||||
// reads a list as "these ARE the areas now".
|
||||
system_ids: systemIds.value,
|
||||
@@ -271,6 +288,38 @@ watch(() => props.ruleId, load);
|
||||
preference.
|
||||
</p>
|
||||
</fieldset>
|
||||
<fieldset class="kind arrival">
|
||||
<legend>When it arrives</legend>
|
||||
<template v-if="kind === 'rule'">
|
||||
<label class="kind-opt">
|
||||
<input v-model="enforcement" type="radio" value="inform" />
|
||||
<span><strong>Inform</strong> — a line beside the work. Most rules.</span>
|
||||
</label>
|
||||
<label class="kind-opt">
|
||||
<input v-model="enforcement" type="radio" value="hold" />
|
||||
<span>
|
||||
<strong>Hold</strong> — the reply or act it governs waits for one
|
||||
read of it. For a rule whose miss costs a rewrite.
|
||||
</span>
|
||||
</label>
|
||||
<label class="kind-opt">
|
||||
<input v-model="enforcement" type="radio" value="enforce" />
|
||||
<span>
|
||||
<strong>Enforce</strong> — the act itself is checked. For a hard
|
||||
boundary.
|
||||
</span>
|
||||
</label>
|
||||
</template>
|
||||
<p v-else class="field-note">A preference arrives as a line beside the work.</p>
|
||||
<label class="salience">
|
||||
Rank among the rest
|
||||
<select v-model="salience" class="fs-input">
|
||||
<option value="high">High — shown first when a moment is crowded</option>
|
||||
<option value="normal">Normal</option>
|
||||
<option value="low">Low — the first to give way</option>
|
||||
</select>
|
||||
</label>
|
||||
</fieldset>
|
||||
<p v-if="kind === 'preference'" class="kind-drift">
|
||||
Sessions rewrite preferences without asking, which is what makes them
|
||||
stay current. Every rewrite is kept, and
|
||||
|
||||
@@ -27,6 +27,15 @@ const emit = defineEmits<{
|
||||
class="rule-chip rule-chip-preference"
|
||||
title="How you want work done. It does not bind, and Grimoire updates it as the work teaches it."
|
||||
>preference</span>
|
||||
<!-- Marked only when the rule stops the work: a line beside the work
|
||||
is the default, and marking it on every row would mark nothing. -->
|
||||
<span
|
||||
v-if="r.enforcement === 'hold' || r.enforcement === 'enforce'"
|
||||
class="rule-chip"
|
||||
:title="r.enforcement === 'hold'
|
||||
? 'The reply or act it governs waits for one read of it'
|
||||
: 'The act it governs is checked against it'"
|
||||
>{{ r.enforcement === "hold" ? "holds" : "enforced" }}</span>
|
||||
<!-- Marked only when something is WRONG: every rule arrives by
|
||||
retrieval now, so "conditional" stopped distinguishing anything.
|
||||
A missing trigger does — it means nothing can retrieve this. -->
|
||||
|
||||
Reference in New Issue
Block a user