🧩 The Reason Log – Decision Chain Ledger
reasonlog stores Reggie’s chain-of-thought for every material decision.
It explains why an action was chosen, how risky it seemed, and what the agent expected to happen next.
Alongside internalmonologue (raw events) and cognitivealignment (after-the-fact verdicts) it forms a complete audit trail.
1. Purpose
| Objective | How it helps |
|---|---|
| Transparency | Gives humans and downstream models a timestamped record of the agent’s reasoning steps. |
| Risk-aware operations | Stores relevance and risk scores so high-impact decisions can be routed for human review first. |
| Outcome tracking | Saves the predicted outcome so the platform can later compare expectation versus reality. |
| Continuous learning | Inaccurate predictions feed the Cognitive-Alignment loop, tuning future risk thresholds and heuristics. |
2. Table Schema (PostgreSQL)
| Column | Type / Constraint | Notes |
|---|---|---|
id | uuid PK | Unique identifier for this reasoning chain. |
timestamp | timestamptz NOT NULL | When the step was recorded. |
decision_context | text NOT NULL | Short label (e.g. ROSTER_AUTO_REBALANCE). |
step_index | int NOT NULL | 0-based position in a multi-step chain. |
thought | text NOT NULL | Natural-language reasoning for this step. |
relevance | numeric(3,2) NOT NULL | 0.00 – 1.00 importance relative to the final action. |
risk | numeric(3,2) NOT NULL | 0.00 – 1.00 probability of a negative consequence. |
predicted_outcome | jsonb | Structured object describing the expected result. |
vector | vector(768) | Embedding of thought for semantic search. |
alignment_id | uuid | FK → cognitivealignment.id once reviewed. |
status | text DEFAULT 'PENDING' | Mirrors review state: PENDING, APPROVED, REJECTED. |
3. Workflow
- Reasoning – While planning an action Reggie appends one or more steps to
reasonlog. - Risk gate – If
risk ≥ monitoring_thresholdthe action pauses for human review (see Cognitive Alignment levels). - Execution – Upon approval the action executes; the final outcome is written to
internalmonologue. - Post-hoc analysis – A nightly job compares
predicted_outcomewith reality and writes accuracy stats to context buckets. - Linkage – Reviewer verdict updates
alignment_idandstatus, closing the loop.
4. Query & Recall Examples
-- Find recent high-risk decisions awaiting review
SELECT * FROM reasonlog
WHERE status = 'PENDING' AND risk > 0.6
ORDER BY timestamp DESC;
-- Retrieve reasoning similar to a new transport situation
SELECT id, decision_context, thought
FROM reasonlog
ORDER BY vector <-> embedding(:new_prompt) -- pgvector similarity
LIMIT 5;
The vector column enables precedent-based prompting, e.g.
“Show me past reasoning similar to reassigning vehicles after staff sick leave.”
5. Data Retention & Governance
- Retention: Full rows kept 180 days, then summarised and archived to cold storage.
- Privacy: Must not include raw PII; references use internal IDs only.
- Change control: Edits to this schema/document require Tech-Lead + Security sign-off.
- Monitoring metrics:
reasonlog_high_risk_rate,reasonlog_pending_count,reasonlog_avg_steps.