nkshirsa commited on
Commit
dd0b0be
Β·
verified Β·
1 Parent(s): 83050e2

Add ECC Harness: phd_research_os/ARCHITECTURE.md

Browse files
Files changed (1) hide show
  1. phd_research_os/ARCHITECTURE.md +80 -0
phd_research_os/ARCHITECTURE.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PhD Research OS β€” Architecture Map
2
+
3
+ > **WAKE-UP INSTRUCTION**: This file is the ground truth for all file locations,
4
+ > API configurations, and system topology. Read this FIRST before touching anything.
5
+
6
+ ## System Topology
7
+
8
+ ```
9
+ phd-research-os-brain/
10
+ β”œβ”€β”€ ARCHITECTURE.md ← YOU ARE HERE (project map)
11
+ β”œβ”€β”€ AGENTS.md ← Agent role registry & contracts
12
+ β”œβ”€β”€ MEMORY.md ← Persistent cross-session state
13
+ β”œβ”€β”€ plan.md ← Current task plan (mutable)
14
+ β”œβ”€β”€ HARNESS_EVOLUTION.md ← ECC rule amendments log
15
+ β”‚
16
+ β”œβ”€β”€ train.py ← SFT training script (Qwen2.5-3B + QLoRA)
17
+ β”œβ”€β”€ generate_dataset.py ← Synthetic dataset generator (1900 examples)
18
+ β”‚
19
+ β”œβ”€β”€ phd_research_os/ ← CORE PACKAGE
20
+ β”‚ β”œβ”€β”€ __init__.py ← v1.0.0
21
+ β”‚ β”œβ”€β”€ db.py ← SQLite data layer (Phase 0)
22
+ β”‚ β”‚ Tables: claims, sources, goals, conflicts,
23
+ β”‚ β”‚ decisions, overrides, experiments,
24
+ β”‚ β”‚ api_usage_log, calibration_log, embedding_cache
25
+ β”‚ β”‚ + companion_agents, agent_tasks, agent_audit_log
26
+ β”‚ β”œβ”€β”€ agents.py ← Original 6-role AI brain (ResearchOSBrain)
27
+ β”‚ β”œβ”€β”€ agent_os.py ← ECC HARNESS ORCHESTRATOR (companion AI factory)
28
+ β”‚ β”‚ CompanionAgent lifecycle: spawn β†’ preflight β†’
29
+ β”‚ β”‚ plan β†’ execute β†’ postflight β†’ retire
30
+ β”‚ β”œβ”€β”€ pipeline.py ← Paper ingestion (PDF β†’ claims)
31
+ β”‚ β”œβ”€β”€ obsidian_export.py ← Obsidian vault export (one-directional)
32
+ β”‚ β”œβ”€β”€ evaluation.py ← Golden dataset eval harness + regression gate
33
+ β”‚ β”œβ”€β”€ conflict_detector.py ← Pairwise contradiction detection
34
+ β”‚ └── backup.py ← SQLite backup & restore
35
+ β”‚
36
+ β”œβ”€β”€ tests/
37
+ β”‚ β”œβ”€β”€ test_db.py ← 22 unit tests (data layer)
38
+ β”‚ └── test_agent_os.py ← ECC harness integration tests
39
+ β”‚
40
+ └── output/
41
+ └── research_os/
42
+ └── db.py ← Symlink/alias β†’ phd_research_os/db.py
43
+ ```
44
+
45
+ ## API Configuration
46
+
47
+ | Provider | Env Variable | Default Model | Use Case |
48
+ |----------|-------------|---------------|----------|
49
+ | Anthropic | `ANTHROPIC_API_KEY` | claude-sonnet-4-20250514 | Primary brain + companion agents |
50
+ | OpenAI | `OPENAI_API_KEY` | gpt-4o-mini | Fallback |
51
+ | OpenRouter | `OPENROUTER_API_KEY` | (configurable) | Multi-model companion agents |
52
+ | HF Local | (model path) | nkshirsa/phd-research-os-brain | Fine-tuned local inference |
53
+
54
+ ## Database Schema (db.py)
55
+
56
+ ### Core Tables (Research OS)
57
+ - `claims` β€” Scientific claims with fixed-point confidence (Γ—1000)
58
+ - `sources` β€” Paper metadata (DOI, journal tier, study type)
59
+ - `goals` β€” Research goals with priority ordering
60
+ - `conflicts` β€” Claim contradiction pairs (hypothesis_confidence ALWAYS "low")
61
+ - `decisions` β€” Proposed research actions with info gain scores
62
+ - `overrides` β€” Expert confidence overrides (lock mechanism)
63
+ - `experiments` β€” Lab data objects (manual approval required)
64
+ - `api_usage_log` β€” Cost tracking per API call
65
+ - `calibration_log` β€” Brier score data collection
66
+ - `embedding_cache` β€” Semantic cache (text_hash β†’ embedding)
67
+
68
+ ### ECC Harness Tables (agent_os.py)
69
+ - `companion_agents` β€” Registry of spawned companion AIs
70
+ - `agent_tasks` β€” Task lifecycle tracking (preflight β†’ done)
71
+ - `agent_audit_log` β€” Every action, decision, and deviation logged
72
+
73
+ ## Key Invariants (NEVER violate)
74
+
75
+ 1. **Fixed-Point Math**: All probabilities stored as INTEGER Γ— 1000. No floats in DB.
76
+ 2. **Provenance**: All AI output is Level 5 (LLM Hypothesis). Human required for promotion.
77
+ 3. **Hypothesis Confidence**: Conflict hypotheses are ALWAYS "low". Never auto-promote.
78
+ 4. **Expert Override**: Once set, system cannot overwrite. Only human can change.
79
+ 5. **Schema Version**: Every record carries `schema_version` tag.
80
+ 6. **Companion Agent Isolation**: Companions cannot modify claims directly β€” they propose, humans approve.