Jurisdiction-pack anatomy
What a jurisdiction pack is, how the loader validates it, and what one pack actually tells the model — read in pack order from registry to prompt text to loading code.
dochaus/plugin/legal/stage-context.ts29 lines · loadStageJurisdictions L23–28
Outline 6 symbols
- JurisdictionContextMode type export
- DraftingPreferencesMode type export
- CONTEXT_FREE_AGENTS const
- jurisdictionContextMode function export
- draftingPreferencesMode function export
- loadStageJurisdictions function export
1import { loadJurisdiction, readMatterJurisdictionCodes, type JurisdictionPack } from "../../lib/jurisdiction"
2
3export type JurisdictionContextMode = "declared" | "none"
4export type DraftingPreferencesMode = "full" | "explanation" | "none"
5
6// The draft orchestrator and router route work, and the narrator restates a
7// drafting run's progress, rather than make jurisdiction-sensitive judgments, so
8// they receive no jurisdiction packs. The narrator receives only preferences
9// for human-facing explanations; substantive stages receive preferences in full.
10const CONTEXT_FREE_AGENTS = new Set(["draft", "router", "narrator"])
11
12export function jurisdictionContextMode(agent: string | undefined): JurisdictionContextMode {
13 if (agent && CONTEXT_FREE_AGENTS.has(agent)) return "none"
14 return "declared"
15}
16
17export function draftingPreferencesMode(agent: string | undefined): DraftingPreferencesMode {
18 if (agent === "narrator") return "explanation"
19 if (agent && CONTEXT_FREE_AGENTS.has(agent)) return "none"
20 return "full"
21}
22
23export async function loadStageJurisdictions(directory: string, mode: JurisdictionContextMode): Promise<JurisdictionPack[]> {
24 if (mode === "none") return []
25 return (await Promise.all(readMatterJurisdictionCodes(directory).map(loadJurisdiction))).filter(
26 (pack): pack is JurisdictionPack => Boolean(pack),
27 )
28}
29