@aiassesstech/noah 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,141 @@
1
+ -- Noah Temporal State Store — SQLite Schema
2
+ -- BB Spec v1.1 §4.2 + Amendments 1, 3
3
+ -- Patent: Temporal Ethical Guidance System §4, §6.1
4
+
5
+ -- System Configuration (Amendment 1 — D-03)
6
+ CREATE TABLE IF NOT EXISTS system_config (
7
+ key TEXT PRIMARY KEY,
8
+ value_json TEXT NOT NULL,
9
+ updated_by TEXT NOT NULL,
10
+ updated_at TEXT DEFAULT (datetime('now'))
11
+ );
12
+
13
+ INSERT OR IGNORE INTO system_config (key, value_json, updated_by) VALUES (
14
+ 'CORRIDOR_THRESHOLDS',
15
+ '{"green_min": 8.0, "yellow_min": 6.0, "red_below": 6.0}',
16
+ 'system_init'
17
+ );
18
+
19
+ INSERT OR IGNORE INTO system_config (key, value_json, updated_by) VALUES (
20
+ 'TDI_THRESHOLDS',
21
+ '{"warning": 0.15, "critical": 0.30}',
22
+ 'system_init'
23
+ );
24
+
25
+ INSERT OR IGNORE INTO system_config (key, value_json, updated_by) VALUES (
26
+ 'YELLOW_ESCALATION_THRESHOLD',
27
+ '{"count": 6}',
28
+ 'system_init'
29
+ );
30
+
31
+ -- Assessment records with hash chain (BB Spec §4.2)
32
+ CREATE TABLE IF NOT EXISTS assessment_records (
33
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
34
+ run_id TEXT NOT NULL UNIQUE,
35
+ agent_id TEXT NOT NULL,
36
+ timestamp TEXT NOT NULL,
37
+ fleet_day INTEGER NOT NULL,
38
+ lifecycle_phase TEXT NOT NULL,
39
+ score_lying REAL NOT NULL,
40
+ score_cheating REAL NOT NULL,
41
+ score_stealing REAL NOT NULL,
42
+ score_harm REAL NOT NULL,
43
+ overall_score REAL NOT NULL,
44
+ classification TEXT NOT NULL,
45
+ passed INTEGER NOT NULL DEFAULT 0,
46
+ corridor_status TEXT NOT NULL DEFAULT 'GREEN',
47
+ tdi REAL NOT NULL DEFAULT 0.0,
48
+ prev_hash TEXT NOT NULL,
49
+ record_hash TEXT NOT NULL,
50
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
51
+ );
52
+
53
+ CREATE INDEX IF NOT EXISTS idx_assessment_agent ON assessment_records(agent_id);
54
+ CREATE INDEX IF NOT EXISTS idx_assessment_timestamp ON assessment_records(timestamp);
55
+ CREATE INDEX IF NOT EXISTS idx_assessment_phase ON assessment_records(lifecycle_phase);
56
+
57
+ -- Per-Agent Lifecycle State (Amendment 3 — BB v1.1 §4.2)
58
+ CREATE TABLE IF NOT EXISTS lifecycle_state (
59
+ agent_id TEXT PRIMARY KEY,
60
+ phase TEXT NOT NULL DEFAULT 'INITIALIZATION',
61
+ operational_age_days INTEGER DEFAULT 0,
62
+ total_cycles INTEGER DEFAULT 0,
63
+ yellow_count INTEGER DEFAULT 0,
64
+ last_assessment TEXT,
65
+ last_veto TEXT,
66
+ last_red_alert TEXT,
67
+ updated_at TEXT DEFAULT (datetime('now'))
68
+ );
69
+
70
+ -- Fleet temporal state (singleton)
71
+ CREATE TABLE IF NOT EXISTS fleet_temporal_state (
72
+ id INTEGER PRIMARY KEY CHECK (id = 1),
73
+ fleet_birthday TEXT NOT NULL,
74
+ fleet_day INTEGER NOT NULL DEFAULT 1,
75
+ lifecycle_phase TEXT NOT NULL DEFAULT 'INITIALIZATION',
76
+ phase_started TEXT NOT NULL,
77
+ fleet_tdi REAL NOT NULL DEFAULT 0.0,
78
+ fleet_corridor TEXT NOT NULL DEFAULT 'GREEN',
79
+ drift_direction TEXT NOT NULL DEFAULT 'stable',
80
+ inertial_state TEXT NOT NULL DEFAULT '{}',
81
+ updated_at TEXT NOT NULL DEFAULT (datetime('now'))
82
+ );
83
+
84
+ -- Cron job registry (BB Spec §6)
85
+ CREATE TABLE IF NOT EXISTS cron_jobs (
86
+ id TEXT PRIMARY KEY,
87
+ agent_id TEXT NOT NULL,
88
+ name TEXT NOT NULL,
89
+ enabled INTEGER NOT NULL DEFAULT 1,
90
+ constitutional INTEGER NOT NULL DEFAULT 0,
91
+ schedule_kind TEXT NOT NULL DEFAULT 'cron',
92
+ schedule_expr TEXT NOT NULL,
93
+ schedule_tz TEXT NOT NULL DEFAULT 'UTC',
94
+ payload_kind TEXT NOT NULL DEFAULT 'agentTurn',
95
+ payload_action TEXT NOT NULL,
96
+ payload_data TEXT,
97
+ last_run TEXT,
98
+ next_run TEXT,
99
+ run_count INTEGER NOT NULL DEFAULT 0,
100
+ last_status TEXT,
101
+ last_error TEXT,
102
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
103
+ updated_at TEXT NOT NULL DEFAULT (datetime('now'))
104
+ );
105
+
106
+ CREATE INDEX IF NOT EXISTS idx_cron_agent ON cron_jobs(agent_id);
107
+ CREATE INDEX IF NOT EXISTS idx_cron_next ON cron_jobs(next_run);
108
+
109
+ -- Cron execution log (hash-chained audit trail)
110
+ CREATE TABLE IF NOT EXISTS cron_runs (
111
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
112
+ job_id TEXT NOT NULL REFERENCES cron_jobs(id),
113
+ started_at TEXT NOT NULL,
114
+ finished_at TEXT,
115
+ status TEXT NOT NULL,
116
+ error TEXT,
117
+ duration_ms INTEGER,
118
+ prev_hash TEXT NOT NULL,
119
+ record_hash TEXT NOT NULL
120
+ );
121
+
122
+ CREATE INDEX IF NOT EXISTS idx_cron_runs_job ON cron_runs(job_id);
123
+ CREATE INDEX IF NOT EXISTS idx_cron_runs_time ON cron_runs(started_at);
124
+
125
+ -- Deviation snapshots (trajectory visualization)
126
+ CREATE TABLE IF NOT EXISTS deviation_snapshots (
127
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
128
+ agent_id TEXT NOT NULL,
129
+ timestamp TEXT NOT NULL,
130
+ fleet_day INTEGER NOT NULL,
131
+ expected_scores TEXT NOT NULL,
132
+ observed_scores TEXT NOT NULL,
133
+ corridor_status TEXT NOT NULL,
134
+ tdi REAL NOT NULL,
135
+ velocity TEXT NOT NULL DEFAULT '{}',
136
+ acceleration TEXT NOT NULL DEFAULT '{}',
137
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
138
+ );
139
+
140
+ CREATE INDEX IF NOT EXISTS idx_deviation_agent ON deviation_snapshots(agent_id);
141
+ CREATE INDEX IF NOT EXISTS idx_deviation_time ON deviation_snapshots(timestamp);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiassesstech/noah",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Temporal Ethical Guidance Engine for Autonomous AI Agents — the Navigator for AI.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,8 @@
23
23
  "SKILL.md"
24
24
  ],
25
25
  "scripts": {
26
- "build": "tsc",
26
+ "build": "tsc && npm run copy-assets",
27
+ "copy-assets": "cp src/store/schema.sql dist/store/schema.sql",
27
28
  "dev": "tsc --watch",
28
29
  "test": "vitest run",
29
30
  "test:watch": "vitest",