feat(7836): lessons and rules are no longer paired by arriving together
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Failing after 1m40s
CI & Build / integration (push) Successful in 2m7s
CI & Build / Build & push image (push) Skipped
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Failing after 1m40s
CI & Build / integration (push) Successful in 2m7s
CI & Build / Build & push image (push) Skipped
The co-arrival recorder counted a lesson and a rule shown in one response as evidence that the lesson is an instance of the rule, and asked the reader to judge the pair once three situations had gathered. Two records that resemble the same prompts arrive together whether or not one is an instance of the other, and the outcome bore that out (2,317 pairs suggested, 23 confirmed). It no longer runs: - neither the prompt door nor the write path records co-arrivals or carries a proposal line; - a rule read lists the lessons judged against it, confirmed first, and a lesson read the rules it was judged against: suggested rows stay in the table and no read shows them; - the lesson page and the rule editor drop the suggested section. The situation-counting helpers stay; rule moment judgments use them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,8 +11,8 @@ import type { RuleKind } from "@/api/rulebooks";
|
||||
* another one fits. */
|
||||
export type RuleJudgment = "linked" | "no_rule" | "unjudged";
|
||||
|
||||
/** A link's state (`models/lesson_rule_link.py` LINK_STATES). */
|
||||
export type LinkState = "suggested" | "confirmed" | "rejected";
|
||||
/** A judged link's state; the reads list only these two. */
|
||||
export type LinkState = "confirmed" | "rejected";
|
||||
|
||||
/** One link from a lesson to a rule, in the reader's view: only rules the
|
||||
* reader owns are listed (`rules_for_lessons`). */
|
||||
@@ -20,14 +20,11 @@ export interface LessonRuleLink {
|
||||
id: number;
|
||||
title: string;
|
||||
kind: RuleKind;
|
||||
/** `suggested` carries nothing in retrieval until it is judged; only
|
||||
* `confirmed` changes what surfaces; `rejected` is kept so the pair is
|
||||
* never proposed again. */
|
||||
/** `confirmed` changes what surfaces; `rejected` is kept so the reason
|
||||
* stays readable. */
|
||||
state: LinkState;
|
||||
/** Why it was confirmed or rejected. */
|
||||
note: string;
|
||||
/** What a suggestion rests on — sent on suggested links only. */
|
||||
evidence?: { situations: number; projects: number; co_surfaced: number };
|
||||
}
|
||||
|
||||
/** A lesson: a transferable insight, retrievable by the SITUATION it applies
|
||||
@@ -79,7 +76,7 @@ export interface Lesson {
|
||||
updated_at: string | null;
|
||||
systems?: { id: number; name: string }[];
|
||||
usage?: RecordUsage;
|
||||
/** The rules this lesson points at, confirmed first, then suggested, then
|
||||
/** The rules this lesson was judged against, confirmed first, then
|
||||
* rejected. Absent (with `rule_judgment`) when the links could not be read
|
||||
* — which is "not attached", never "no rule". */
|
||||
rules?: LessonRuleLink[];
|
||||
|
||||
@@ -120,9 +120,9 @@ export interface Rule {
|
||||
/** Present only when the rule has triggers. */
|
||||
triggers?: RuleTrigger[];
|
||||
relations?: RuleRelation[];
|
||||
/** The lessons that point at this rule — the concrete
|
||||
* situations judged instances of it, plus any suggested and awaiting a
|
||||
* judgment. Readable lessons only; omitted when there are none. */
|
||||
/** The lessons judged against this rule — confirmed instances of it
|
||||
* first, then those judged not to be. Readable lessons only; omitted when
|
||||
* there are none. */
|
||||
lessons?: { id: number; title: string; state: LinkState; note: string }[];
|
||||
}
|
||||
|
||||
|
||||
@@ -570,13 +570,13 @@ watch(() => props.ruleId, load);
|
||||
<ul>
|
||||
<li v-for="l in lessons" :key="l.id" class="relation">
|
||||
<router-link :to="`/lessons/${l.id}`" class="relation-target">{{ l.title }}</router-link>
|
||||
<span v-if="l.state === 'suggested'" class="rule-chip">suggested</span>
|
||||
<span v-if="l.state === 'rejected'" class="rule-chip">not an instance</span>
|
||||
<span v-if="l.note" class="relation-note">{{ l.note }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="field-note">
|
||||
The situations that keep proving this rule. A confirmed lesson brings the rule along
|
||||
when it surfaces; a suggested one waits for a judgment on the lesson's page.
|
||||
when it surfaces, and arrives with the rule when you open it.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
@@ -603,7 +603,7 @@ watch(() => props.ruleId, load);
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- `.rule-chip` for the "suggested" marker on a lesson — the chip the rule
|
||||
<!-- `.rule-chip` for the "not an instance" marker on a lesson — the chip the rule
|
||||
panes already use, loaded here because the slide-over can open with no
|
||||
pane that loads it (a link straight to ?rule=N).
|
||||
Block 0, as in every pane that loads it: a shared src must sit at
|
||||
|
||||
@@ -30,7 +30,6 @@ import { apiErrorMessage } from "@/api/client";
|
||||
import {
|
||||
deleteLesson,
|
||||
getLesson,
|
||||
judgeLessonLink,
|
||||
type Lesson,
|
||||
type LessonRuleLink,
|
||||
} from "@/api/lessons";
|
||||
@@ -41,7 +40,6 @@ import { DEAD_WEIGHT_ADVICE } from "@/utils/deadWeight";
|
||||
import { useToastStore } from "@/stores/toast";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
import { vRecordRefs } from "@/directives/recordRefs";
|
||||
import { canWriteRecord } from "@/utils/permission";
|
||||
import { recordHref } from "@/utils/recordHref";
|
||||
|
||||
const route = useRoute();
|
||||
@@ -62,16 +60,11 @@ const insightHtml = computed(() =>
|
||||
);
|
||||
|
||||
|
||||
const canWrite = computed(() => canWriteRecord(lesson.value?.permission));
|
||||
|
||||
/** The links by state — each state reads differently. Confirmed links are
|
||||
* the answer; suggested ones are evidence waiting on a judgment; rejected
|
||||
* ones are kept so the pair is never proposed again, and shown so the reason
|
||||
* stays readable. */
|
||||
* the answer; rejected ones are kept so the reason stays readable. */
|
||||
const linksIn = (state: LessonRuleLink["state"]) =>
|
||||
computed(() => (lesson.value?.rules ?? []).filter((r) => r.state === state));
|
||||
const confirmedRules = linksIn("confirmed");
|
||||
const suggestedRules = linksIn("suggested");
|
||||
const rejectedRules = linksIn("rejected");
|
||||
|
||||
/** A rule opens in the rules view's editor, which takes the rule alone. */
|
||||
@@ -79,36 +72,6 @@ function ruleHref(ruleId: number) {
|
||||
return { path: "/rules", query: { rule: String(ruleId) } };
|
||||
}
|
||||
|
||||
/** What a suggestion rests on, in the units it was proposed by: distinct
|
||||
* situations, not raw arrivals — one situation repeated proves nothing. */
|
||||
function evidenceLine(ev: NonNullable<LessonRuleLink["evidence"]>): string {
|
||||
const situations = `${ev.situations} distinct situation${ev.situations === 1 ? "" : "s"}`;
|
||||
const projects = ev.projects > 1 ? `, across ${ev.projects} projects` : "";
|
||||
return `Arrived together in ${situations}${projects}.`;
|
||||
}
|
||||
|
||||
const judging = ref<number | null>(null);
|
||||
|
||||
/** Judge a suggested link from here. Re-reads the lesson rather than editing
|
||||
* the list in place: confirming also clears a "no rule fits" answer, and the
|
||||
* judgment line has to come back from the server to be right. */
|
||||
async function judge(rule: LessonRuleLink, verdict: "confirm" | "reject") {
|
||||
judging.value = rule.id;
|
||||
try {
|
||||
await judgeLessonLink(lessonId.value, rule.id, verdict);
|
||||
lesson.value = await getLesson(lessonId.value);
|
||||
toast.show(
|
||||
verdict === "confirm"
|
||||
? "Linked — the rule can now surface through this lesson"
|
||||
: "Not an instance — this pair will not be suggested again",
|
||||
);
|
||||
} catch (e) {
|
||||
toast.show(apiErrorMessage(e, "Failed to record the judgment"), "error");
|
||||
} finally {
|
||||
judging.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
error.value = null;
|
||||
@@ -223,39 +186,6 @@ onMounted(load);
|
||||
nobody has said none fits.
|
||||
</p>
|
||||
|
||||
<template v-if="suggestedRules.length">
|
||||
<h3 class="ld-sub-label">Suggested</h3>
|
||||
<ul class="ld-sources">
|
||||
<li v-for="r in suggestedRules" :key="r.id">
|
||||
<router-link :to="ruleHref(r.id)" class="ld-link">
|
||||
{{ r.title }}
|
||||
</router-link>
|
||||
<span v-if="r.kind === 'preference'" class="rule-chip rule-chip-preference">
|
||||
preference
|
||||
</span>
|
||||
<p v-if="r.evidence" class="ld-link-note">{{ evidenceLine(r.evidence) }}</p>
|
||||
<div v-if="canWrite" class="ld-judge">
|
||||
<button
|
||||
type="button"
|
||||
class="ld-ghost ld-small"
|
||||
:disabled="judging === r.id"
|
||||
@click="judge(r, 'confirm')"
|
||||
>
|
||||
Confirm
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="ld-ghost ld-small"
|
||||
:disabled="judging === r.id"
|
||||
@click="judge(r, 'reject')"
|
||||
>
|
||||
Not an instance
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<template v-if="rejectedRules.length">
|
||||
<h3 class="ld-sub-label">Judged not an instance</h3>
|
||||
<ul class="ld-sources ld-rejected">
|
||||
@@ -410,8 +340,6 @@ onMounted(load);
|
||||
color: var(--fs-text-tertiary);
|
||||
}
|
||||
.ld-rejected .ld-link { color: var(--fs-text-secondary); }
|
||||
.ld-judge { display: flex; gap: var(--fs-space-2); margin-top: var(--fs-space-1); }
|
||||
.ld-small { padding: 0.15rem 0.6rem; font-size: var(--fs-size-label); }
|
||||
.ld-ghost:disabled { opacity: var(--fs-disabled-opacity); cursor: default; }
|
||||
|
||||
.ld-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 1.25rem; }
|
||||
|
||||
Reference in New Issue
Block a user