The detector module looks like it was built to enable agent-driven learning creation, but no agent has been wired up to use it yet. The observer agent would be a natural candidate — it already detects patterns and contradictions, but currently can only express them as observations, not learnings.
Want me to wire up a create_learning tool for the observer agent?
User
/context
context
User
The Observer Agent acts as the detective, but the Learning Agent acts as the judge. For the Observer to suggest a learning, it has to move from Reporting (what happened) to Diagnostic (why the gap between intent and reality exists).
In the architecture, the "Suggestion" is a Learning Proposal Node that acts as a bridge between a failed reality and a new policy.
1. The "Discrepancy" Logic
The Observer's suggestion is triggered by a State Mismatch. It compares three points of data:
The Intent: What the agent claimed it would do.
The Observation: What the external system (Datadog/GitHub/Stripe) actually recorded.
The Policy: What the rules intended to prevent.
The Trigger: If Observation != Intent OR Observation == Incident, the Observer initiates the "Root Cause Trace."
2. The Root Cause Trace (How it finds the learning)
The Observer traverses the graph to find the Faulty Variable. It asks three structured questions:
Is it a Policy Failure? (e.g., "The Rego logic allowed a 500spend,200 for this agent.")
Assistant
Let me check what's already in the schema for suggestions and learnings.
Assistant
The existing learning table is already sufficient. It's essentially the learning_proposal spec you described, already built.
It also has fields your spec didn't cover but that are already wired: target_agents (which agents get the learning injected), source: human / agent / system, priority, pattern_confidence, and embedding for collision detection.
Why suggestion is the wrong table: Suggestions convert into work items (converted_to → task / feature / decision / project). Learnings become behavioral rules injected into agent prompts at runtime. They're fundamentally different outputs — a suggestion says "do this work", a learning says "behave this way going forward."
What's missing is the wiring, not the schema:
The Observer needs a suggest_learning tool that calls suggestLearning() from detector.ts (already exists, never called)
The Observer prompt needs the "Root Cause Trace" diagnostic logic you described — the three-question framework (policy failure? context failure? behavioral drift?)
The evidence edges need to be created when the Observer proposes a learning, linking back to the observations/traces that triggered it
The schema is ready. The Observer just needs the tool and the analyst prompt. Want me to wire that up?
User
Suggested Action:
Should we add a "Simulation Mode"? Where the Learning Proposal is tested against a "shadow" version of the incident to see if the new policy would have actually blocked it? This is a killer feature for your repo launch. Shall we draft that spec?
Should we have a "learning_proposal" table or is the existing "suggestion" table sufficient?
User
5. Why this is the "2026 Standard"
In 2024, "learning" meant retuning a model (expensive/slow). In your 2026 OS, learning is a Graph Mutation. It’s fast, it’s cheap, and it’s instantly effective. You aren't teaching the LLM to be "smarter"; you are making the Architecture around it more resilient.
The Verdict: The Observer doesn't just "guess" learnings. It identifies the graph edge that failed and proposes a new one to bridge the gap.
Would you like me to draft the "Analyst" system prompt for the Observer? This is the specific logic that tells it how to look at an Incident and generate these learning_proposal objects.
User
4. The Human-in-the-Loop Workflow
This is where the "System Learns" without going rogue.
Notification: You get a ping: "The Observer has a Learning Proposal for Incident #102."
Review: You see the proposal in your Business OS dashboard. You see the Trace (how it reached this conclusion).
Approval: You click "Apply Patch."
Rewire: The Brain automatically updates the Policy Node or the Agent's Context Buffer.
User
3. The "Learning Proposal" Node Spec
Instead of just "talking" to you, the Observer writes a structured proposal to SurrealDB for your approval.
sql
DEFINE TABLE learning_proposal SCHEMAFULL;
-- The "Evidence"
DEFINE FIELD incident_id ON learning_proposal TYPE record<incident>;
DEFINE FIELD evidence_nodes ON learning_proposal TYPE array; -- [observation:1, intent:A]
-- The "Fix"
DEFINE FIELD category ON learning_proposal TYPE string
ASSERT $value IN ['policy_patch', 'context_injection', 'behavioral_constraint'];
DEFINE FIELD proposed_change ON learning_proposal TYPE object;
/* Example: { table: "policy", action: "update", logic: "limit = 200" } */
-- The "Reasoning"
DEFINE FIELD rationale ON learning_proposal TYPE string;
-- Governance
DEFINE FIELD status ON learning_proposal TYPE string DEFAULT 'pending_review';
User
2. The Root Cause Trace (How it finds the learning)
The Observer traverses the graph to find the Faulty Variable. It asks three structured questions:
Is it a Policy Failure? (e.g., "The Rego logic allowed a 500spend,butitshouldhavebeen200 for this agent.")
Learning Suggestion: "Tighten Policy #402 to include role-based caps."
Is it a Context Failure? (e.g., "The agent didn't know the API was in maintenance mode.")
Learning Suggestion: "Inject 'System Status' telemetry into the pre-prompt for all API intents."
Is it a Behavioral Drift? (e.g., "The agent ignored the 'Safety First' KBI and kept retrying a broken endpoint.")
Learning Suggestion: "Reduce the 'Autonomy Score' for this agent until it passes a validation Dojo."
User
1. The "Discrepancy" Logic
The Observer's suggestion is triggered by a State Mismatch. It compares three points of data:
The Intent: What the agent claimed it would do.
The Observation: What the external system (Datadog/GitHub/Stripe) actually recorded.
The Policy: What the rules intended to prevent.
The Trigger: If Observation != Intent OR Observation == Incident, the Observer initiates the "Root Cause Trace."
User
/context
context
User
nw:discuss
/nw:discuss
User
NW-DISCUSS: Jobs-to-be-Done Analysis, UX Journey Design, and Requirements Gathering
Wave: DISCUSS (wave 2 of 6) | Agent: Luna (nw-product-owner) | Command: /nw:discuss
Overview
Execute DISCUSS wave through Luna's integrated workflow: JTBD analysis|UX journey discovery|emotional arc design|shared artifact tracking|requirements gathering|user story creation|acceptance criteria definition. Luna uncovers jobs users accomplish, maps to journeys and requirements, handles complete lifecycle from user motivations through DoR-validated stories ready for DESIGN. Establishes ATDD foundation.
For greenfield projects (no src/ code, no docs/feature/ history), Luna proposes Walking Skeleton as Feature 0.
Interactive Decision Points
Decision 1: Feature Type
Question: What type of feature is this?
Options:
User-facing -- UI/UX functionality visible to end users
docs/discovery/problem-validation.md | opportunity-tree.md | lean-canvas.md — From DISCOVER
Assistant
Let me answer the decision points for this feature before launching Luna:
Feature: Observer Agent Learning Proposals — wiring the Observer to diagnose root causes and propose learnings
Decision 1 (Feature Type): Cross-cutting — spans the Observer agent, learning system, graph layer, and feed/UI
Decision 2 (Walking Skeleton): No — the learning table, detector.ts, and Observer agent already exist. This is wiring, not greenfield.
Decision 3 (UX Research Depth): Comprehensive — the human-in-the-loop approval flow and the Observer's diagnostic reasoning need careful journey mapping
Decision 4 (Number of Jobs): Multiple jobs (2-4) — at minimum: (1) the system autonomously detecting why something went wrong, (2) the human reviewing/approving a proposed behavioral change, (3) the system applying the learning to future agent behavior
Let me check existing discovery artifacts and then launch Luna.
Assistant
There's already extensive JTBD and journey work for agent-learnings. Let me read the existing artifacts to understand what's already been designed before launching into a redundant discuss phase.
Assistant
The DISCUSS wave for agent-learnings is already complete. The existing artifacts cover exactly the scenario you described:
US-AL-002 already specifies three data sources for the Observer's learning suggestions:
Conversation-based — chat agent detects user corrections in real-time
Trace-based — Observer scans traces for repeated tool failures
Observation escalation — 3+ observations on same pattern → learning suggestion
The journey YAML maps the full flow: Pattern Detection → Suggestion Creation → Governance Feed → Human Review.
What's different from your "Root Cause Trace" vision: The existing spec focuses on pattern frequency (3 corrections = suggest learning) rather than the diagnostic reasoning you described (policy failure vs. context failure vs. behavioral drift). Your vision adds a causal classification layer — the Observer doesn't just count occurrences, it diagnoses why the gap exists and proposes a categorized fix.
Options:
Extend the existing DISCUSS artifacts — add the Root Cause Trace diagnostic framework (policy/context/behavioral classification) to US-AL-002 and the journey, then proceed
Skip to DESIGN/DELIVER — the schema and most infrastructure already exist; wire up the suggest_learning tool with the diagnostic prompt
Run a focused /nw:discuss --phase=jtbd on just the diagnostic reasoning as a sub-feature of Job 2
Which direction?
User
/context
context
Assistant· <synthetic>
No response requested.
User
proceed to /nw:design
User
NW-DESIGN: Architecture Design
Wave: DESIGN (wave 3 of 6) | Agents: Morgan (nw-solution-architect) | Command: *design-architecture
Overview
Execute DESIGN wave through discovery-driven architecture design. Morgan asks about business drivers and constraints first, then recommends architecture that fits. Analyzes existing codebase, evaluates open-source alternatives, produces C4 diagrams (Mermaid) as mandatory output.
docs/feature/{feature-name}/design/constraints.md — Technical and business constraints
Discovery Flow
Architecture decisions driven by quality attributes, not pattern shopping:
Step 1: Understand the Problem
Review JTBD artifacts from DISCUSS to understand which jobs the architecture must serve. Morgan asks: What are we building? For whom? Which quality attributes matter most? (scalability|maintainability|testability|time-to-market|fault tolerance|auditability)
Step 2: Understand Constraints
Morgan asks: Team size/experience? Timeline? Existing systems to integrate? Regulatory requirements? Operational maturity (CI/CD, monitoring)?
Step 3: Team Structure (Conway's Law)
Morgan asks: How many teams? Communication patterns? Does proposed architecture match org chart?
Step 3.5: Development Paradigm Selection
Morgan identifies primary language(s) from constraints, then applies:
Multi-paradigm (TypeScript|Kotlin|Python|Rust|Swift): present both, let user choose based on team experience and domain fit
After confirmation, ask user permission to write paradigm to project CLAUDE.md:
FP: This project follows the **functional programming** paradigm. Use @nw-functional-software-crafter for implementation.
OOP: This project follows the **object-oriented** paradigm. Use @nw-software-crafter for implementation.
Assistant
Let me gather the existing DISCUSS artifacts and codebase context before launching Morgan.
Assistant
Now let me read the remaining key files for the architecture context.
Assistant
Now let me check the existing ADRs and the learning types to understand the full picture.
Assistant
Good, I now have comprehensive understanding of the existing system. Let me check the existing requirements docs and the observer route to complete the picture, then produce the architecture design.
Assistant
Now I have a thorough understanding of the full system. Let me check existing ADRs relevant to learnings and then produce the architecture design.
Assistant
Now I have complete understanding of the system. Let me produce the architecture design. The key insight: the Observer already has a graph scan pipeline (runGraphScan) that detects contradictions and anomalies, and the learning infrastructure (suggestLearning in detector.ts) already has rate limiting and dismissed similarity gates. The missing piece is the diagnostic reasoning layer that bridges observation patterns to learning proposals.
Assistant
The existing architecture design already covers the base agent-learnings feature comprehensively (schema, CRUD, JIT injection, collision detection, governance feed). What's missing is the Observer's diagnostic reasoning — the "Root Cause Trace" that your earlier message described: the Observer moving from reporting (observation) to diagnosing (why the gap exists) to prescribing (learning proposal).
This is an extension of the existing architecture, not a replacement. Let me create the design doc for the observer-learning-proposals feature specifically.
Assistant
Now let me create the ADR and component boundaries docs.
Assistant
Now let me run the peer review.
Assistant
Good review. Conditionally approved with 3 high issues and 4 medium issues. Let me address the 3 high-severity requirements and the most impactful medium issue.
Assistant
Let me address all the review findings by updating the architecture design, ADR, and component boundaries.
Assistant
Now update the coverage checker to not create noise observations:
Assistant
Now address the event-driven deduplication (H3) and update step_04:
Assistant
Update step_04 acceptance criteria:
Assistant
Update step_02 to include the schema improvements:
Assistant
Now update the ADR to acknowledge the graceful absence tradeoff:
Assistant
Now update the component boundaries to reflect the schema changes and add the dedup contract:
Assistant
Now update the testing strategy to cover the new concerns:
Assistant
Now add the peer review section to the architecture design:
Assistant
Architecture design is complete. Here's the summary:
DESIGN wave complete for Observer Learning Proposals.
Root Cause Trace over frequency-only — Observer diagnoses why (policy failure / context failure / behavioral drift), not just that a pattern recurs
LLM determines learning type directly — schema includes proposed_learning_type so the model outputs constraint vs instruction based on full context, not a hardcoded category mapping
Learning Suggestion: "Tighten Policy #402 to include role-based caps."
Is it a Context Failure? (e.g., "The agent didn't know the API was in maintenance mode.")
Learning Suggestion: "Inject 'System Status' telemetry into the pre-prompt for all API intents."
Is it a Behavioral Drift? (e.g., "The agent ignored the 'Safety First' KBI and kept retrying a broken endpoint.")
Learning Suggestion: "Reduce the 'Autonomy Score' for this agent until it passes a validation Dojo."
3. The "Learning Proposal" Node Spec
Instead of just "talking" to you, the Observer writes a structured proposal to SurrealDB for your approval.
sql
DEFINE TABLE learning_proposal SCHEMAFULL;
-- The "Evidence"
DEFINE FIELD incident_id ON learning_proposal TYPE record<incident>;
DEFINE FIELD evidence_nodes ON learning_proposal TYPE array; -- [observation:1, intent:A]
-- The "Fix"
DEFINE FIELD category ON learning_proposal TYPE string
ASSERT $value IN ['policy_patch', 'context_injection', 'behavioral_constraint'];
DEFINE FIELD proposed_change ON learning_proposal TYPE object;
/* Example: { table: "policy", action: "update", logic: "limit = 200" } */
-- The "Reasoning"
DEFINE FIELD rationale ON learning_proposal TYPE string;
-- Governance
DEFINE FIELD status ON learning_proposal TYPE string DEFAULT 'pending_review';
4. The Human-in-the-Loop Workflow
This is where the "System Learns" without going rogue.
Notification: You get a ping: "The Observer has a Learning Proposal for Incident #102."
Review: You see the proposal in your Business OS dashboard. You see the Trace (how it reached this conclusion).
Approval: You click "Apply Patch."
Rewire: The Brain automatically updates the Policy Node or the Agent's Context Buffer.
5. Why this is the "2026 Standard"
In 2024, "learning" meant retuning a model (expensive/slow). In your 2026 OS, learning is a Graph Mutation. It’s fast, it’s cheap, and it’s instantly effective. You aren't teaching the LLM to be "smarter"; you are making the Architecture around it more resilient.
The Verdict: The Observer doesn't just "guess" learnings. It identifies the graph edge that failed and proposes a new one to bridge the gap.
Would you like me to draft the "Analyst" system prompt for the Observer? This is the specific logic that tells it how to look at an Incident and generate these learning_proposal objects.
Suggested Action:
Should we add a "Simulation Mode"? Where the Learning Proposal is tested against a "shadow" version of the incident to see if the new policy would have actually blocked it? This is a killer feature for your repo launch. Shall we draft that spec?
Should we have a "learning_proposal" table or is the existing "suggestion" table sufficient?
Agent Invocation
@nw-product-owner
Execute *jtbd-analysis for {feature-name}, then *journey informed by JTBD artifacts, then *gather-requirements informed by both.
Context files: see Context Files Required and Previous Artifacts above.
Configuration:
format: visual | yaml | gherkin | all (default: all)
research_depth: {Decision 3} | interactive: high | output_format: markdown
Grounds all subsequent artifacts in real user motivations.
Job Discovery: Ask user what users are trying to accomplish. Capture in job story format: "When [situation], I want to [motivation], so I can [outcome]."
Job Dimensions: For each job — functional (practical task)|emotional (desired feeling)|social (desired perception)
Four Forces Analysis: For each primary job:
Push (current frustration): "What frustrated users enough to request this?"
Pull (desired future): "What could they do that they cannot now?"
Anxiety (adoption concerns): "What concerns about adopting this?"
Habit (current behavior): "What behavior must change?"
If interview transcripts|support tickets|analytics exist, extract forces from those instead of relying solely on user description.
Opportunity Scoring (multiple jobs): Rank by importance vs. satisfaction gap. High importance + low satisfaction = strongest opportunities. Produce scored table.
JTBD-to-Story Bridge: Each job story feeds into user stories and acceptance criteria in Phase 3. Every user story must trace to at least one job.
Luna runs deep discovery (mental model|emotional arc|shared artifacts|error paths) informed by JTBD, produces visual journey + YAML schema + Gherkin scenarios. Each journey maps to one or more identified jobs.
Artifact
Path
Visual Journey
docs/ux/{epic}/journey-{name}-visual.md
Journey Schema
docs/ux/{epic}/journey-{name}.yaml
Gherkin Scenarios
docs/ux/{epic}/journey-{name}.feature
Artifact Registry
docs/ux/{epic}/shared-artifacts-registry.md
Phase 3 -- Requirements and User Stories:
Luna crafts LeanUX stories informed by JTBD + journey artifacts. Every story traces to at least one job story. Validates against DoR, invokes peer review, prepares handoff.
Artifact
Path
Requirements
docs/requirements/requirements.md
User Stories
docs/requirements/user-stories.md
Acceptance Criteria
docs/requirements/acceptance-criteria.md
DoR Checklist
docs/requirements/dor-checklist.md
Success Criteria
JTBD analysis complete: all jobs in job story format
Job dimensions identified: functional|emotional|social per job
Four Forces mapped per job (push|pull|anxiety|habit)
Opportunity scores produced (when multiple jobs)
UX journey map with emotional arcs and shared artifacts
Every journey maps to at least one job
Discovery complete: user mental model understood, no vague steps
Happy path defined: all steps start-to-goal with expected outputs
docs/ux/{epic}/
jtbd-job-stories.md
jtbd-four-forces.md
jtbd-opportunity-scores.md (when multiple jobs)
journey-{name}-visual.md
journey-{name}.yaml
journey-{name}.feature
shared-artifacts-registry.md
docs/requirements/
requirements.md
user-stories.md (each story traces to a job)
acceptance-criteria.md
dor-checklist.md
Examples
Example 1: User-facing feature with comprehensive UX research
code
/nw:discuss first-time-setup
Orchestrator asks Decision 1-4. User selects "User-facing", "No skeleton", "Comprehensive", "Multiple jobs". Luna starts with JTBD analysis: discovers jobs like "When I first open the app, I want to feel productive immediately, so I can justify the purchase." Maps four forces for each job. Scores opportunities. Then runs journey discovery informed by JTBD, produces visual journey + YAML + Gherkin. Finally crafts stories where each traces to a job, validates DoR, and prepares handoff.
Example 2: JTBD-only invocation
code
/nw:discuss --phase=jtbd onboarding-flow
Runs only Luna's JTBD analysis phase (job discovery + dimensions + four forces + opportunity scoring). Produces JTBD artifacts without proceeding to journey design or requirements. Useful for early discovery when you need to understand user motivations before committing to UX design.
Example 3: Journey-only invocation
code
/nw:discuss --phase=journey release-nwave
Runs only Luna's journey design phases (discovery + visualization + coherence validation). Produces journey artifacts without proceeding to requirements crafting. Useful when JTBD is already done and journey design needs standalone iteration.
Runs only Luna's requirements phases (gathering + crafting + DoR validation). Assumes JTBD and journey artifacts already exist or are not needed (e.g., backend feature).
Default if user declines/unsure: OOP. User can override later.
Step 4: Recommend Architecture Based on Drivers
Recommend based on quality attribute priorities|constraints|paradigm from Steps 1-3.5. Default: modular monolith with dependency inversion (ports-and-adapters). Overrides require evidence.
If functional paradigm selected, Morgan adapts architectural strategy:
Types-first design: define algebraic data types and domain models before components
Composition pipelines: data flows through transformation chains, not method dispatch
Pure core / effect shell: domain logic is pure, IO lives at boundaries (adapters are functions)
Effect boundaries replace port interfaces: function signatures serve as ports
Immutable state: state changes produce new values, no mutation in the domain
These are strategic guidance items for the architecture document — no code snippets.
When activated: apply complexity-science-based stress analysis — stressors|attractors|residues|incidence matrix|resilience modifications. See stress-analysis skill.
When not activated: skip entirely, do not mention.
Step 6: Produce Deliverables
Architecture document with component boundaries|tech stack|integration patterns
C4 System Context diagram (Mermaid) -- MANDATORY
C4 Container diagram (Mermaid) -- MANDATORY
C4 Component diagrams (Mermaid) -- only for complex subsystems
ADRs for significant decisions
Rigor Profile Integration
Before dispatching the architect agent, read rigor config from .nwave/des-config.json (key: rigor). If absent, use standard defaults.
agent_model: Pass as model parameter to Task tool. If "inherit", omit model (inherits from session).
reviewer_model: If design review is performed, use this model for the reviewer agent. If "skip", skip design review.
review_enabled: If false, skip post-design review step.
Agent Invocation
@nw-solution-architect
Execute *design-architecture for {feature-name}.
Context files: see Context Files Required above.
Configuration:
model: rigor.agent_model (omit if "inherit")
interactive: moderate
output_format: markdown
diagram_format: mermaid (C4)
stress_analysis: {true if --residuality flag, false otherwise}
Success Criteria
Business drivers and constraints gathered before architecture selection
Existing system analyzed before design (codebase search performed)
Integration points with existing components documented
Reuse vs. new component decisions justified
Architecture supports all business requirements
Technology stack selected with clear rationale
Development paradigm selected and (optionally) written to project CLAUDE.md
Component boundaries defined with dependency-inversion compliance
C4 System Context + Container diagrams produced (Mermaid)
ADRs written with alternatives considered
Handoff accepted by nw-platform-architect (DEVOP wave)
Next Wave
Handoff To: nw-platform-architect (DEVOP wave)
Deliverables: See Morgan's handoff package specification in agent file
Expected Outputs
code
docs/feature/{feature-name}/design/
architecture-design.md (includes C4 diagrams in Mermaid)
technology-stack.md
component-boundaries.md
data-models.md
docs/adrs/
ADR-NNN-*.md
CLAUDE.md (project root) (optional: ## Development Paradigm section)