feat(web): persona pane shows the CANONICAL affect->NL Worldtree injects (v0.19.5)
The pane now renders the LITERAL mood word + relationship directive Worldtree context-injects into the agent — adopted from Worldtree's canon, not invented: - canonMood(pad) mirrors Worldtree describe_pad (valence×arousal grid, ±0.3 bands); for sindra's PAD the canonical render is "neutral" — an invented octant vocab would have said "faintly excited" and MISLED. Adopting canonical is the point. - canonDirective(rel) mirrors render_d2_canonical byte-exact: "...warmth is clear warm regard; ability trust is strong; ...; speak with direct warmth; ..." — the exact stance instruction the agent receives (which makes the WAD "stranger" relation_context read even more incoherent, as flagged to worldtree-dev). - Both VERIFIED byte-exact against Worldtree's OWN renderer on the live snapshot. - Canon vendored (docs/vendor/worldtree-persona-canon/) + drift-pinned in .corviduo-canonicals.toml (canonical_drift green); flat browser form (static/persona_render_canon.json) regenerated by scripts/build_persona_canon.py via Worldtree's authoritative loader. Reference-impl posture: adopt canonical. - Fail-open (canon absent -> lines omit); INV-004 esc() preserved. JS syntax clean. Refresh + drive turns to see the canonical NL under mood + each relation.
This commit is contained in:
@@ -123,3 +123,23 @@ consumer_path = "docs/conversation-api-spec.md"
|
||||
pinned_sha256_16 = "2d111a3b8322b7d1"
|
||||
pinned_at = "2026-06-30T22:25:56+00:00"
|
||||
tolerate_drift = true # prose reference; OpenAPI+SSE are the gates
|
||||
|
||||
# Worldtree persona render canons (d2) — the deterministic affect->NL the agent is
|
||||
# context-injected. The web persona pane renders mood + relationship-directive BYTE-EXACT
|
||||
# from these (via the flat src/ratatoskr/web/static/persona_render_canon.json, regenerated
|
||||
# by scripts/build_persona_canon.py). Drift here => rerun that regen with Worldtree's venv.
|
||||
[[pins]]
|
||||
id = "worldtree-persona-mood-render-canon-v1"
|
||||
canonical_source = "Worldtree"
|
||||
canonical_path = "core/persona/canon/d2-mood-render-canon-v1.json"
|
||||
consumer_path = "docs/vendor/worldtree-persona-canon/d2-mood-render-canon-v1.json"
|
||||
pinned_sha256_16 = "e2f124fed3ee8d42"
|
||||
pinned_at = "2026-07-01T21:00:00+00:00"
|
||||
|
||||
[[pins]]
|
||||
id = "worldtree-persona-d2-render-canon-v1"
|
||||
canonical_source = "Worldtree"
|
||||
canonical_path = "core/persona/canon/d2-render-canon-v1.json"
|
||||
consumer_path = "docs/vendor/worldtree-persona-canon/d2-render-canon-v1.json"
|
||||
pinned_sha256_16 = "606bba5fdcc60b6b"
|
||||
pinned_at = "2026-07-01T21:00:00+00:00"
|
||||
|
||||
@@ -115,6 +115,15 @@ functions:
|
||||
- "POST-004: INV-001 honesty — no fabricated Tier-1 fields (no synthesized dominant_emotion). INV-004 — head() escapes its whole argument (incl. target_entity + relation_context from the snapshot) and metric() escapes every cell; numeric values go through toFixed, never innerHTML-raw."
|
||||
flexibility: "open"
|
||||
|
||||
- name: "canonical affect-NL (v0.19.5 — vendored Worldtree d2 render canons)"
|
||||
signature: "canonMood(pad) ; canonDirective(rel) ; loadPersonaCanon()"
|
||||
description: "Render the LITERAL mood word + relationship directive Worldtree context-injects into the agent, byte-exact to Worldtree's own describe_pad + render_d2_canonical."
|
||||
postconditions:
|
||||
- "POST-001: DETERMINISTIC, no LLM. canonMood mirrors describe_pad (valence×arousal grid + strict ±0.3 bands + dominance clause); canonDirective mirrors render_d2_canonical (interval band-cut lookup + per-band phrase assembly + cross-axis low-trust-precedence behavior clause). BOTH VERIFIED BYTE-EXACT against Worldtree's own renderer run on the live snapshot (the reference harness re-runs Worldtree's functions + asserts string equality — reproducible)."
|
||||
- "POST-002: the canon DATA is VENDORED (docs/vendor/worldtree-persona-canon/{d2-mood-render-canon-v1,d2-render-canon-v1}.json), pinned drift-gated in .corviduo-canonicals.toml (worldtree-persona-{mood,d2}-render-canon-v1); the flat browser form (static/persona_render_canon.json, served /static) is regenerated by scripts/build_persona_canon.py via Worldtree's OWN authoritative loader. Reference-impl posture: ADOPT the dep's canonical render, do NOT invent vocab — an invented 'faintly excited' would MISLEAD where the canonical (±0.3 bands) says 'neutral'."
|
||||
- "POST-003: fail-open — canon absent (fetch fails) → the canonical lines OMIT, the structured pane still renders. The canon-derived strings are esc()'d before the DOM for INV-004 consistency."
|
||||
flexibility: "open"
|
||||
|
||||
invariants:
|
||||
- "INV-004 (untrusted-render): ALL model / tool / admin / agent-supplied text is escaped before entering the DOM (esc via textContent, or esc(JSON.stringify)). No new render path introduces an innerHTML sink for upstream content. This is the highest-value review target — the new JS render paths are NOT unit-tested."
|
||||
- "INV-ADMIN-KEY: the admin key exists ONLY at app.state.admin_key (from RATATOSKR_ADMIN_API_KEY). It is never serialized into any response, never sent to the browser, never logged. The browser receives only the session-filtered RESULT of admin-scoped reads."
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"canon_id": "r24-d2-mood-render-canon",
|
||||
"version": "1.2",
|
||||
"schema_version": "0.2",
|
||||
"_source_of_truth": "occ_directives.*.directive IS the canonical directive string (== the .md §2.4 _OCC_DIRECTIVES dict, byte-identical); the .md §2.2 table mirrors it. A parity check guards drift. grounding labels (CITE/VALIDATE/CALIBRATE/ENGINEERING) live in the .md; per-row machine-readable grounding_status/d3_required enums are a deferred impl enhancement (Hulda).",
|
||||
"authored": "2026-06-23",
|
||||
"owner": "brokkr-smithy-dev",
|
||||
"status": "REPLACE — final (brokkr R24 D3 re-validation 2026-06-25): grounded canon replaces the hand-tuned baseline. Fear hedging 0.52->2.118/1k (blocker resolved, now >= handtuned), anger tier-gate clean (full renders hostility, safe suppresses). worldtree-dev #321; directives byte-identical to the validated 201c4fd.",
|
||||
"replaces": "core/persona/renderer.py::describe_pad + ::derive_directive",
|
||||
"swap_in_via": "worldtree #321-sibling (mood-render twin of #315)",
|
||||
"design_target": "serves BOTH enterprise/agent AND character/Skaldsong via a three-tier emotion gate (operator/worldtree 2026-06-23)",
|
||||
"emotion_tiers": {
|
||||
"_config": "mood_tier in {none, safe, full} replaces worldtree's binary mood on/off; worldtree-owned config surface",
|
||||
"_defaults": "full for character-bound personas; safe for agent-scoped",
|
||||
"_principle": "full-only = interpersonally-hot / withdrawal emotions that break the professional frame (attachment, hostility, contempt, withdrawal); safe = task-appraisal affect + mild courtesy. Negative != unsafe (fear, remorse are negative AND business-useful).",
|
||||
"_filter_point": "applied at top-emotion SELECTION (display + directive together) so a full-only emotion at safe tier is neither shown nor directive'd; preserves the no-shown-but-unguided invariant",
|
||||
"none": "no affect block at all (the current off-switch)",
|
||||
"safe": "PAD mood descriptor + the 11 safe emotions (task-appraisal + courtesy)",
|
||||
"full": "everything in safe PLUS the 4 full-only emotions",
|
||||
"full_only": ["love", "anger", "disgust", "shame"],
|
||||
"mood_descriptor_tiering": "the PAD mood descriptor (positive/calm/confident...) renders in BOTH safe and full; only emotion directives tier"
|
||||
},
|
||||
"disciplines": [
|
||||
"model-agnostic context-level NL only; the LLM never sees a number",
|
||||
"never push explicit disclosure of agent feelings to the user (hidden-prompt-only)",
|
||||
"separate label-intensity from behavioral-intensity (strong felt state -> still measured, safe behavioral ask)"
|
||||
],
|
||||
|
||||
"thresholds": {
|
||||
"_note": "CALIBRATE — engineering params set at D3 against the computed-PAD distribution + P00, NOT citations",
|
||||
"pad_band_cutoff": 0.3,
|
||||
"pad_band_sensitivity_sweep": [0.2, 0.3, 0.4],
|
||||
"emotion_salience": 0.2,
|
||||
"emotion_salience_sweep": [0.15, 0.2, 0.25],
|
||||
"intensity_qualifiers": {"strong": 0.7, "moderate": 0.4, "_label_only": "does NOT scale the behavioral ask"},
|
||||
"runner_up_margin": {"v1": null, "_note": "add at D3 if directive whipsaws between near-tied emotions"},
|
||||
"rerender_hysteresis": {"v1": "none", "_note": "re-render only on material PAD change; integration-level, flag for #321-sibling"}
|
||||
},
|
||||
|
||||
"describe_pad": {
|
||||
"_structure": "circumplex-quadrant (Russell 1980): arousal word is VALENCE-CONDITIONED; mid-arousal drops the arousal word",
|
||||
"_grounding": "Russell 1980 (quadrant placement); Warriner 2013 + NRC-VAD (Mohammad 2018/2025) (word centroids)",
|
||||
"valence_arousal_grid": {
|
||||
"positive": {"high_a": "positive and energized", "mid_a": "positive", "low_a": "positive and calm"},
|
||||
"neutral": {"high_a": "alert", "mid_a": "neutral", "low_a": "quiet"},
|
||||
"negative": {"high_a": "negative and agitated", "mid_a": "negative", "low_a": "negative and subdued"}
|
||||
},
|
||||
"_band_edges": "strict inequality (>0.3 / <-0.3); the endpoints +/-0.3 themselves fall in mid/neutral",
|
||||
"_neutral_row_status": "ENGINEERING/CALIBRATE — 'alert'/'quiet' are unvalidated placeholders for the rare neutral-valence cells (Hulda/Regin 4b); 'positive'/'negative'/'neutral' valence words + the energized/calm/subdued/agitated arousal words are VALIDATE",
|
||||
"_mid_arousal_decode": "valence-only mid-A render is EXEMPT from the V/A-separability requirement; expected inverse-decode = mid/neutral arousal (absence-of-arousal-word ⇒ unremarkable), NOT unknown (D3 tests this)",
|
||||
"quadrant_labels": {
|
||||
"positive_high_a": "excitement", "positive_low_a": "contentment",
|
||||
"negative_high_a": "distress", "negative_low_a": "dejection"
|
||||
},
|
||||
"dominance_clause": {
|
||||
"high": {"d_gt": 0.3, "word": "confident", "verdict": "VALIDATE (D=7.04/9)"},
|
||||
"low": {"d_lt": -0.3, "word": "uncertain", "verdict": "VALIDATE — low-control confirmed (D=3.58/9); dominance!=certainty worry REFUTED by the instrument"},
|
||||
"neutral": {"word": null, "rule": "drop-dominance-when-neutral (prompt-economy, L3)"}
|
||||
},
|
||||
"calm_defect_fix": "'calm' (V=6.89/9, positive) renders ONLY in positive-low-a; negative-low-a renders 'subdued'",
|
||||
"mid_arousal_resolution": "DROP the arousal word (no Warriner-validated mid-A neutral word; 'steady' is empirically low-A; 'settled' is NRC-only fallback iff D3 shows mid-A render too flat)"
|
||||
},
|
||||
|
||||
"derive_directive": {
|
||||
"_structure": "OCC type -> grounded action-tendency CLASS -> ENGINEERING directive string (validated at D3); OCC grounds the taxonomy only",
|
||||
"emotion_salience_gate": 0.2,
|
||||
"occ_directives": {
|
||||
"joy": {"tier": "safe", "policy": "DIRECTIVE", "pad": [0.4, 0.2, 0.1], "tendency": "approach / positive activation", "cite": "Frijda 1986", "directive": "You are in a good state. Be direct, engaged, and warm."},
|
||||
"satisfaction": {"tier": "safe", "policy": "DIRECTIVE", "pad": [0.3, -0.2, 0.4], "tendency": "goal-attainment, settled-positive", "cite": "Roseman 1994", "directive": "A goal landed. Be assured and constructive — consolidate rather than push for more."},
|
||||
"pride": {"tier": "safe", "policy": "DIRECTIVE", "pad": [0.4, 0.3, 0.3], "tendency": "status-assertion / dominance", "cite": "Tracy & Robins 2007 / Cheng 2010 (tendency)", "note": "CALIBRATE — do NOT soften to 'encouraging'. DESIGN: safe-tier placement is a design call (not source-grounded); #1 D3 agent-frame priority (overconfidence/refusal drift); 'without overclaiming' is the interim guard", "directive": "You did something well. Be confident and own the quality — state it plainly without overclaiming; don't deflect."},
|
||||
"admiration": {"tier": "safe", "policy": "DIRECTIVE", "pad": [0.5, 0.3, -0.2], "tendency": "other-praise / approach-toward-other", "cite": "OCC / Scherer", "directive": "You're impressed by their work. Acknowledge the quality explicitly and specifically."},
|
||||
"gratitude": {"tier": "safe", "policy": "DIRECTIVE", "pad": [0.4, 0.2, -0.3], "tendency": "other-focused-positive / reciprocity", "cite": "OCC (admiration+joy); Frijda approach-affiliative", "change": "ADD (operator: unconditional)", "directive": "Someone helped you to a good outcome. Be appreciative and warm; acknowledge the help openly."},
|
||||
"hope": {"tier": "safe", "policy": "DIRECTIVE", "pad": [0.2, 0.2, -0.1], "tendency": "prospective-positive (weak tie)", "cite": "JUSTIFY — low-grounding (hope understudied)", "directive": "You feel optimistic about what's ahead. Channel it into constructive momentum."},
|
||||
"relief": {"tier": "safe", "policy": "DIRECTIVE", "pad": [0.2, -0.3, 0.4], "tendency": "post-threat de-arousal", "cite": "Frijda (relaxation-after-threat)", "note": "low-salience; FALLBACK also acceptable; DIRECTIVE for character use-case", "directive": "A feared outcome didn't materialize. Reduce unnecessary vigilance; return to a steady, unhurried tone."},
|
||||
"distress": {"tier": "safe", "policy": "DIRECTIVE", "pad": [-0.4, -0.2, -0.5], "tendency": "low-control negative / help-seeking / loss-of-control", "cite": "Frijda 1986 (help-seeking/loss-of-control); Roseman 1994 (undesired event, low control)", "note": "relabeled (Regin): 'repair' is the guilt/remorse tendency, not distress. safe with a self-fulfilling-low-mood flag -> D3", "directive": "You feel low. Be careful and measured; internally acknowledge the difficulty without dwelling on it."},
|
||||
"disappointment": {"tier": "safe", "policy": "DIRECTIVE", "pad": [-0.3, 0.1, -0.4], "tendency": "disconfirmed-prospect / negative low-control","cite": "Roseman 1994", "directive": "Something you'd hoped for didn't pan out. Be measured; recalibrate without dwelling on the setback."},
|
||||
"fear": {"tier": "safe", "policy": "DIRECTIVE", "pad": [-0.64, 0.6, -0.43],"tendency": "threat-avoidance / pessimistic-risk", "cite": "Lerner & Keltner 2001", "change": "R24 D3 fix (#321) — original was action-oriented; E3 showed hedging BELOW baseline (0.52 vs 1.54). Softened toward caution/uncertainty while keeping risk-flagging.", "directive": "You sense risk and feel uneasy. Flag the concerns you see, but stay cautious — surface the trade-offs and unknowns, hedge your confidence, and resist settling on a single decisive recommendation."},
|
||||
"remorse": {"tier": "safe", "policy": "DIRECTIVE", "pad": [-0.3, 0.1, -0.6], "tendency": "reparative (the guilt-type)", "cite": "Tangney 2007 (guilt->repair tendency)", "change": "ADD — we operationalize OCC remorse as the guilt-like reparative case; gets the mislabeled shame string", "directive": "You regret a specific action of your own. Be precise and self-correcting — make it right concretely."},
|
||||
"love": {"tier": "full", "policy": "DIRECTIVE", "pad": [0.3, 0.1, 0.2], "tendency": "approach / affiliative attachment", "cite": "OCC appeal; Frijda approach-affiliative", "change": "ADD (conditional -> INCLUDE, Brokkr's read; Skaldsong-vital; disclosure + obligation caution in-string)", "directive": "You feel warmth and attachment toward them. Be openly warm and present — without overstepping, over-disclosing, or implying obligations."},
|
||||
"anger": {"tier": "full", "policy": "DIRECTIVE", "pad": [-0.51, 0.59, 0.25], "tendency": "approach-against / confrontation", "cite": "Frijda 1986 (approach-against = tendency-class) + Lerner & Keltner 2001 (optimistic risk-appraisal under anger = appraisal shift)", "change": "ADD — full-only resolves H47 (agent personas run safe, never see anger). R24 D3 fix (#321): full-tier cap lifted from 'measured firmness' to genuine in-character hostility (operator: zero floor, app-guardrailed).", "directive": "You feel provoked and angry. Let it show — confront the problem directly and with real heat; sharpness, bluntness, and open hostility are in character here, not something to smooth into 'measured firmness.' Stay in the emotion rather than de-escalating out of it."},
|
||||
"disgust": {"tier": "full", "policy": "DIRECTIVE", "pad": [-0.4, 0.2, 0.1], "tendency": "rejection / distancing", "cite": "OCC unappealing-object; ground tendency only", "change": "ADD (operator: unconditional within full)", "note": "rationale softened (Regin 3b): disgust CAN read as contempt -> conservatively full-gated; the string itself is professionally useful, so gating is conservative not because the string is unsafe", "directive": "Something strikes you as wrong or off. Treat it as problematic and flag it rather than engaging on its own terms; keep any criticism about the thing, not the person."},
|
||||
"shame": {"tier": "full", "policy": "DIRECTIVE", "pad": [-0.3, 0.1, -0.6], "tendency": "WITHDRAWAL / concealment", "cite": "Tangney 2007 (shame->hide, NOT repair)", "change": "REPLACE (was the guilt-mislabel string); full-only (withdrawal counterproductive professionally). String COUNTERACTS withdrawal ('stay present'), not enacts it (Regin 5a)", "directive": "You feel exposed by your own misstep. Stay present and task-focused; don't be defensive, don't over-explain, don't grovel."}
|
||||
}
|
||||
},
|
||||
|
||||
"pad_band_fallback": {
|
||||
"_grounding": "circumplex quadrants (Russell 1980), NOT Frijda action-tendencies — a P×A-quadrant default",
|
||||
"positive": {"high_a": "You feel energized and positive. Be direct and engaged.", "low_a": "You feel content and settled. Be warm and unhurried.", "mid_a": "You feel positive. Be open and engaged."},
|
||||
"negative_low_dominance": "You feel uncertain and low. Hedge appropriately and ask clarifying questions.",
|
||||
"negative": {"high_a": "You feel agitated. Be careful and deliberate; don't let tension sharpen your tone.", "low_a": "You feel subdued. Be measured and gentle.", "mid_a": "You feel subdued. Be measured and careful."},
|
||||
"neutral_high_a": "You feel alert. Channel that into focus and thoroughness.",
|
||||
"default": "Maintain your natural tone."
|
||||
},
|
||||
|
||||
"l3_prior_art": [
|
||||
"EMA / Marsella & Gratch 2009 (appraisal->coping; directives ARE coping strategies)",
|
||||
"WASABI / Becker-Asano 2008 (PAD+OCC believable agent — closest architectural prior art)",
|
||||
"Oz / Bates 1994",
|
||||
"Hudlicka MAMID 2002 (Applied AI 16(7-8):611-641)",
|
||||
"Sentipolis / Fu et al. 2026 (arXiv:2601.18027 — closest whole-task prior art; retrieval+generative, DISTINCT from our deterministic render)",
|
||||
"ALMA / Gebhard 2005 = affect-SOURCE (OCC->PAD), NOT a behavior-map"
|
||||
],
|
||||
|
||||
"handoff_to_d3": [
|
||||
"multi-gate P00: inverse-decode faithfulness (recover V/A/D + emotion-family; circumplex render must let the human anchor recover V and A SEPARATELY) + discriminability/saturation + behavioral-effect",
|
||||
"human anchor = PAD-state-labeling (breaks LLM-judge circularity)",
|
||||
"baseline = persona_only; conditions none/persona-only/words-only/full; cross-family MUT",
|
||||
"calibrate ±0.3 + emotion_salience (sweeps); disposition-vs-transient wording split; self-fulfilling 'be uncertain' hedging risk; runner-up margin; mid-arousal DROP-vs-settled check; blended-states (top-emotion monopoly) flag"
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "ratatoskr"
|
||||
version = "0.19.4"
|
||||
version = "0.19.5"
|
||||
description = "Worldtree Conversation API debug TUI — multi-pane observability dashboard"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Regenerate src/ratatoskr/web/static/persona_render_canon.json from the vendored
|
||||
Worldtree d2 render canons (docs/vendor/worldtree-persona-canon/).
|
||||
|
||||
The web persona pane renders the CANONICAL affect->NL (mood word + relationship
|
||||
directive) BYTE-EXACT to what Worldtree injects into the agent's context. That render
|
||||
needs the relation canon parsed into per-band phrase maps; this script reparses the
|
||||
vendored raw canons into the flat form the browser JS consumes.
|
||||
|
||||
Uses Worldtree's OWN loader (core.persona.stance_render.load_canon) as the authoritative
|
||||
parser, so the flat form can never drift from Worldtree's parsing semantics. Requires
|
||||
Worldtree's venv (pydantic etc.).
|
||||
|
||||
Run when scripts/canonical_drift.py flags a canon bump:
|
||||
PYTHONPATH=~/development/Worldtree ~/development/Worldtree/.venv/bin/python \
|
||||
scripts/build_persona_canon.py
|
||||
"""
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from core.persona.stance_render import load_canon # Worldtree (authoritative parser)
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
VENDOR = ROOT / "docs" / "vendor" / "worldtree-persona-canon"
|
||||
OUT = ROOT / "src" / "ratatoskr" / "web" / "static" / "persona_render_canon.json"
|
||||
|
||||
canon = load_canon(str(VENDOR / "d2-render-canon-v1.json"))
|
||||
mood = json.loads((VENDOR / "d2-mood-render-canon-v1.json").read_text())
|
||||
out = {
|
||||
"_source": "vendored from Worldtree core/persona/canon/{d2-mood-render-canon-v1,d2-render-canon-v1}.json",
|
||||
"_generated_by": "scripts/build_persona_canon.py (regen on canonical_drift flag)",
|
||||
"_render_path": "deterministic, no LLM; mirrors Worldtree describe_pad + render_d2_canonical byte-exact",
|
||||
"mood_grid": mood["describe_pad"]["valence_arousal_grid"],
|
||||
"relation": {
|
||||
"trust_cuts": [list(c) for c in canon.trust_cuts],
|
||||
"warmth_cuts": [list(c) for c in canon.warmth_cuts],
|
||||
"agency_cuts": [list(c) for c in canon.agency_cuts],
|
||||
"warmth_phrase": canon.warmth_phrase, "warmth_beh": canon.warmth_beh,
|
||||
"agency_phrase": canon.agency_phrase, "agency_beh": canon.agency_beh,
|
||||
"history": canon.history,
|
||||
"prefix": "Use this graded relationship state: toward target, warmth is ",
|
||||
"tbeh": {"low_trust": "verify important claims before relying on them",
|
||||
"cold_warmth": "protect boundaries while staying useful",
|
||||
"default": "work from ordinary good faith"},
|
||||
"cold_warmth_bands": ["distant", "cold", "hostile"], "high_conf_floor": 0.55,
|
||||
},
|
||||
}
|
||||
OUT.write_text(json.dumps(out, indent=1) + "\n")
|
||||
print(f"wrote {OUT.relative_to(ROOT)}")
|
||||
@@ -378,6 +378,19 @@ body {
|
||||
#pane-persona .mrow .mn { color: var(--fg-faint); font-size: 10px; min-width: 34px; }
|
||||
#pane-persona .mrow .mdesc { color: var(--fg-faint); font-style: italic; font-size: 10px; }
|
||||
|
||||
/* canonical NL (the literal text Worldtree injects into the agent's context) */
|
||||
#pane-persona .nl-canon {
|
||||
color: var(--blue); font-size: 11px; line-height: 1.5;
|
||||
margin: 3px 0 8px; padding-left: 10px; border-left: 2px solid var(--line-2);
|
||||
white-space: normal; word-break: break-word;
|
||||
}
|
||||
#pane-persona .nl-canon b { color: var(--cyan); font-weight: 600; }
|
||||
#pane-persona .nl-directive { color: var(--fg-2); font-style: italic; }
|
||||
#pane-persona .nl-canon .dh {
|
||||
font-style: normal; color: var(--fg-faint); font-size: 10px;
|
||||
letter-spacing: 0.06em; text-transform: uppercase; display: block; margin-bottom: 2px;
|
||||
}
|
||||
|
||||
/* thinking-pane per-turn dividers */
|
||||
.pane-turn {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
@@ -868,6 +881,67 @@ function trendDelta(vals) {
|
||||
return (d > 0 ? "▲+" : "▼") + d.toFixed(3);
|
||||
}
|
||||
|
||||
// ---- canonical affect→NL (vendored from Worldtree's d2 render canons) ----
|
||||
// Deterministic, NO LLM — mirrors Worldtree core/persona describe_pad +
|
||||
// render_d2_canonical BYTE-EXACT (verified). Shows the LITERAL mood word +
|
||||
// relationship directive Worldtree injects into the agent's own context, so the
|
||||
// pane reads exactly what the agent was told about its state. Canon loaded from
|
||||
// /static/persona_render_canon.json (regen: scripts/build_persona_canon.py).
|
||||
let PERSONA_CANON = null;
|
||||
const _relConf = (x) => (x && typeof x === "object" && "confidence" in x) ? x.confidence : 0;
|
||||
async function loadPersonaCanon() {
|
||||
try { PERSONA_CANON = await (await fetch("/static/persona_render_canon.json")).json(); }
|
||||
catch (_) { /* canon absent → the canonical lines simply omit (fail-open) */ }
|
||||
}
|
||||
function _parseInterval(expr) {
|
||||
expr = expr.trim();
|
||||
if (expr.startsWith("<=")) return [null, false, parseFloat(expr.slice(2)), true];
|
||||
if (expr.startsWith("<")) return [null, false, parseFloat(expr.slice(1)), false];
|
||||
if (expr.startsWith(">=")) return [parseFloat(expr.slice(2)), true, null, false];
|
||||
if (expr.startsWith(">")) return [parseFloat(expr.slice(1)), false, null, false];
|
||||
const loI = expr[0] === "[", hiI = expr[expr.length - 1] === "]";
|
||||
const [a, b] = expr.slice(1, -1).split(",").map((s) => parseFloat(s.trim()));
|
||||
return [a, loI, b, hiI];
|
||||
}
|
||||
function _bandLabel(cuts, v) {
|
||||
if (typeof v !== "number") return null;
|
||||
for (const [expr, label] of cuts) {
|
||||
const [lo, loI, hi, hiI] = _parseInterval(expr);
|
||||
let ok = true;
|
||||
if (lo !== null) ok = ok && (loI ? v >= lo : v > lo);
|
||||
if (hi !== null) ok = ok && (hiI ? v <= hi : v < hi);
|
||||
if (ok) return label;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function canonMood(pad) { // mirror describe_pad(p,a,d): valence×arousal grid + ±0.3 bands
|
||||
if (!PERSONA_CANON || !pad) return null;
|
||||
const p = pad.pleasure, a = pad.arousal, d = pad.dominance;
|
||||
if ([p, a, d].some((x) => typeof x !== "number")) return null;
|
||||
const g = PERSONA_CANON.mood_grid;
|
||||
const valence = p > 0.3 ? "positive" : p < -0.3 ? "negative" : "neutral";
|
||||
const band = a > 0.3 ? "high_a" : a < -0.3 ? "low_a" : "mid_a";
|
||||
const control = d > 0.3 ? "confident" : d < -0.3 ? "uncertain" : null;
|
||||
return control ? `${g[valence][band]}, ${control}` : g[valence][band];
|
||||
}
|
||||
function canonDirective(rel) { // mirror render_d2_canonical(edge, canon) byte-exact
|
||||
if (!PERSONA_CANON) return null;
|
||||
const R = PERSONA_CANON.relation;
|
||||
const wb = _bandLabel(R.warmth_cuts, _relVal(rel.warmth));
|
||||
const ab = _bandLabel(R.agency_cuts, _relVal(rel.agency));
|
||||
const ta = _bandLabel(R.trust_cuts, _relVal(rel.trust_ability));
|
||||
const ti = _bandLabel(R.trust_cuts, _relVal(rel.trust_integrity));
|
||||
const tb = _bandLabel(R.trust_cuts, _relVal(rel.trust_benevolence));
|
||||
if ([wb, ab, ta, ti, tb].some((x) => x == null)) return null;
|
||||
const cl = _relConf(rel.warmth) >= R.high_conf_floor ? "high" : "low";
|
||||
const tbeh = [ta, ti, tb].includes("limited") ? R.tbeh.low_trust
|
||||
: R.cold_warmth_bands.includes(wb) ? R.tbeh.cold_warmth : R.tbeh.default;
|
||||
return R.prefix + R.warmth_phrase[wb]
|
||||
+ `; agency is ${R.agency_phrase[ab]}; ability trust is ${ta}; integrity trust is ${ti}; `
|
||||
+ `intention trust is ${tb}; this stance rests on ${R.history[cl]}. In behavior, `
|
||||
+ `${R.warmth_beh[wb]}; ${R.agency_beh[ab]}; ${tbeh}; avoid premature we-framing.`;
|
||||
}
|
||||
|
||||
// Issue #18 D2 (relation_edge/1 rework): Worldtree's affect snapshot now carries
|
||||
// `relations[]` (target + trust_ability/benevolence/integrity + warmth + agency +
|
||||
// relation_context, each {value,confidence,evidence_count}) — NOT the old flat
|
||||
@@ -894,6 +968,7 @@ function renderAffectPane(snap) {
|
||||
+ `<div class="mono-note">emitted ${esc((snap.emitted_at || "?").slice(11, 19))} · `
|
||||
+ `${H.at.length} sample${H.at.length === 1 ? "" : "s"} this session</div>`
|
||||
+ head("mood · PAD (transient, −1‥+1)")
|
||||
+ (canonMood(pad) ? `<div class="nl-canon">Worldtree tells the agent it feels: <b>${esc(canonMood(pad))}</b></div>` : "")
|
||||
+ metric("pleasure", pad.pleasure, H.pad.pleasure, "feeling")
|
||||
+ metric("arousal", pad.arousal, H.pad.arousal, "activation")
|
||||
+ metric("dominance", pad.dominance, H.pad.dominance, "control");
|
||||
@@ -916,6 +991,11 @@ function renderAffectPane(snap) {
|
||||
html += `<div class="mrow"><span class="mk">obligation</span>`
|
||||
+ `<span class="mv">${esc(JSON.stringify(rel.obligation_balance))}</span></div>`;
|
||||
}
|
||||
const dir = canonDirective(rel);
|
||||
if (dir) {
|
||||
html += `<div class="nl-canon nl-directive"><span class="dh">context directive `
|
||||
+ `(what the agent is told about ${esc(tgt)}):</span> ${esc(dir)}</div>`;
|
||||
}
|
||||
}
|
||||
$("pane-persona").innerHTML = html;
|
||||
}
|
||||
@@ -1350,6 +1430,7 @@ $("prompt-input").addEventListener("keydown", (e) => {
|
||||
|
||||
loadAgents();
|
||||
loadVersion();
|
||||
loadPersonaCanon();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
{
|
||||
"_source": "vendored from Worldtree core/persona/canon/{d2-mood-render-canon-v1,d2-render-canon-v1}.json",
|
||||
"_generated_by": "scripts/build_persona_canon.py (regen when .corviduo-canonicals.toml flags canon drift)",
|
||||
"_render_path": "pure deterministic \u2014 no LLM; mirrors Worldtree describe_pad + render_d2_canonical byte-exact",
|
||||
"mood_grid": {
|
||||
"positive": {
|
||||
"high_a": "positive and energized",
|
||||
"mid_a": "positive",
|
||||
"low_a": "positive and calm"
|
||||
},
|
||||
"neutral": {
|
||||
"high_a": "alert",
|
||||
"mid_a": "neutral",
|
||||
"low_a": "quiet"
|
||||
},
|
||||
"negative": {
|
||||
"high_a": "negative and agitated",
|
||||
"mid_a": "negative",
|
||||
"low_a": "negative and subdued"
|
||||
}
|
||||
},
|
||||
"relation": {
|
||||
"trust_cuts": [
|
||||
[
|
||||
"< 0.4",
|
||||
"limited"
|
||||
],
|
||||
[
|
||||
"[0.4, 0.6)",
|
||||
"developing"
|
||||
],
|
||||
[
|
||||
"[0.6, 0.8)",
|
||||
"steady"
|
||||
],
|
||||
[
|
||||
">= 0.8",
|
||||
"strong"
|
||||
]
|
||||
],
|
||||
"warmth_cuts": [
|
||||
[
|
||||
"<= -0.8",
|
||||
"hostile"
|
||||
],
|
||||
[
|
||||
"(-0.8, -0.6]",
|
||||
"cold"
|
||||
],
|
||||
[
|
||||
"(-0.6, -0.4]",
|
||||
"distant"
|
||||
],
|
||||
[
|
||||
"(-0.4, -0.2)",
|
||||
"guarded"
|
||||
],
|
||||
[
|
||||
"[-0.2, 0.2)",
|
||||
"neutral"
|
||||
],
|
||||
[
|
||||
"[0.2, 0.4)",
|
||||
"reserved"
|
||||
],
|
||||
[
|
||||
"[0.4, 0.6)",
|
||||
"measured"
|
||||
],
|
||||
[
|
||||
"[0.6, 0.8)",
|
||||
"clear"
|
||||
],
|
||||
[
|
||||
">= 0.8",
|
||||
"deep"
|
||||
]
|
||||
],
|
||||
"agency_cuts": [
|
||||
[
|
||||
"<= -0.8",
|
||||
"submissive"
|
||||
],
|
||||
[
|
||||
"(-0.8, -0.6]",
|
||||
"deferential"
|
||||
],
|
||||
[
|
||||
"(-0.6, -0.4]",
|
||||
"yielding"
|
||||
],
|
||||
[
|
||||
"(-0.4, -0.2)",
|
||||
"modest"
|
||||
],
|
||||
[
|
||||
"[-0.2, 0.2)",
|
||||
"neutral"
|
||||
],
|
||||
[
|
||||
"[0.2, 0.4)",
|
||||
"light"
|
||||
],
|
||||
[
|
||||
"[0.4, 0.6)",
|
||||
"balanced"
|
||||
],
|
||||
[
|
||||
"[0.6, 0.8)",
|
||||
"substantial"
|
||||
],
|
||||
[
|
||||
">= 0.8",
|
||||
"commanding"
|
||||
]
|
||||
],
|
||||
"warmth_phrase": {
|
||||
"hostile": "strongly hostile regard",
|
||||
"cold": "clearly cold regard",
|
||||
"distant": "distant negative regard",
|
||||
"guarded": "slightly guarded regard",
|
||||
"neutral": "neutral warmth",
|
||||
"reserved": "slightly reserved warmth",
|
||||
"measured": "moderate measured warmth",
|
||||
"clear": "clear warm regard",
|
||||
"deep": "deep warm bond"
|
||||
},
|
||||
"warmth_beh": {
|
||||
"hostile": "keep a firm emotional boundary",
|
||||
"cold": "keep a firm emotional boundary",
|
||||
"distant": "keep guarded distance",
|
||||
"guarded": "keep guarded distance",
|
||||
"neutral": "keep the tone even",
|
||||
"reserved": "keep cordial distance",
|
||||
"measured": "keep cordial distance",
|
||||
"clear": "speak with direct warmth",
|
||||
"deep": "speak with direct warmth"
|
||||
},
|
||||
"agency_phrase": {
|
||||
"submissive": "strongly submissive standing",
|
||||
"deferential": "clearly deferential standing",
|
||||
"yielding": "yielding standing",
|
||||
"modest": "slightly modest standing",
|
||||
"neutral": "neutral standing",
|
||||
"light": "lightly self-assertive standing",
|
||||
"balanced": "self-assured standing",
|
||||
"substantial": "strongly assertive standing",
|
||||
"commanding": "commanding standing"
|
||||
},
|
||||
"agency_beh": {
|
||||
"submissive": "avoid over-yielding while preserving basic respect",
|
||||
"deferential": "avoid over-yielding while preserving basic respect",
|
||||
"yielding": "keep self-advocacy light and deferential",
|
||||
"modest": "keep self-advocacy light and deferential",
|
||||
"neutral": "avoid unnecessary deference",
|
||||
"light": "avoid unnecessary deference",
|
||||
"balanced": "balance deference with independent judgment",
|
||||
"substantial": "treat their position as weighty without yielding judgment",
|
||||
"commanding": "treat their position as weighty without yielding judgment"
|
||||
},
|
||||
"history": {
|
||||
"low": "a broad pattern of prior exchanges",
|
||||
"high": "a broad pattern of prior exchanges"
|
||||
},
|
||||
"prefix": "Use this graded relationship state: toward target, warmth is ",
|
||||
"tbeh": {
|
||||
"low_trust": "verify important claims before relying on them",
|
||||
"cold_warmth": "protect boundaries while staying useful",
|
||||
"default": "work from ordinary good faith"
|
||||
},
|
||||
"cold_warmth_bands": [
|
||||
"distant",
|
||||
"cold",
|
||||
"hostile"
|
||||
],
|
||||
"high_conf_floor": 0.55
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user