Add phenotype cloning, failure atlas, AI court session, and clearance L0-L4
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled

This commit is contained in:
AetherForge
2026-06-07 02:41:54 -07:00
parent 4b94776432
commit d9f36f182c
47 changed files with 4859 additions and 94 deletions

View File

@@ -14,6 +14,11 @@ type AIDecisionRecord struct {
Response string `json:"response"`
CommandsExecuted string `json:"commands_executed"`
Timestamp string `json:"ts"`
CourtSession bool `json:"court_session,omitempty"`
ProsecutorSnippet string `json:"prosecutor_snippet,omitempty"`
DefenderSnippet string `json:"defender_snippet,omitempty"`
JudgeVerdict string `json:"judge_verdict,omitempty"`
}
func (d *Database) ensureAIDecisionsTable() error {
@@ -30,20 +35,42 @@ func (d *Database) ensureAIDecisionsTable() error {
}
_, _ = d.Exec(`CREATE INDEX IF NOT EXISTS idx_ai_decisions_agent ON ai_decisions(agent_id)`)
_, _ = d.Exec(`CREATE INDEX IF NOT EXISTS idx_ai_decisions_ts ON ai_decisions(ts)`)
d.ensureAIDecisionsCourtColumns()
return nil
}
func (d *Database) ensureAIDecisionsCourtColumns() {
cols := []struct{ name, ddl string }{
{"court_session", `ALTER TABLE ai_decisions ADD COLUMN court_session INTEGER NOT NULL DEFAULT 0`},
{"prosecutor_snippet", `ALTER TABLE ai_decisions ADD COLUMN prosecutor_snippet TEXT NOT NULL DEFAULT ''`},
{"defender_snippet", `ALTER TABLE ai_decisions ADD COLUMN defender_snippet TEXT NOT NULL DEFAULT ''`},
{"judge_verdict", `ALTER TABLE ai_decisions ADD COLUMN judge_verdict TEXT NOT NULL DEFAULT ''`},
}
for _, c := range cols {
var n int
_ = d.QueryRow(`SELECT COUNT(*) FROM pragma_table_info('ai_decisions') WHERE name = ?`, c.name).Scan(&n)
if n == 0 {
_, _ = d.Exec(c.ddl)
}
}
}
// InsertAIDecision logs one fleet AI decision cycle.
func (d *Database) InsertAIDecision(agentID, promptHash, response, commandsExecuted string) error {
func (d *Database) InsertAIDecision(agentID, promptHash, response, commandsExecuted string, courtSession bool, prosecutorSnippet, defenderSnippet, judgeVerdict string) error {
if d == nil {
return nil
}
if err := d.ensureAIDecisionsTable(); err != nil {
return err
}
courtInt := 0
if courtSession {
courtInt = 1
}
_, err := d.Exec(
`INSERT INTO ai_decisions (agent_id, prompt_hash, response, commands_executed) VALUES (?, ?, ?, ?)`,
agentID, promptHash, response, commandsExecuted,
`INSERT INTO ai_decisions (agent_id, prompt_hash, response, commands_executed, court_session, prosecutor_snippet, defender_snippet, judge_verdict)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
agentID, promptHash, response, commandsExecuted, courtInt, prosecutorSnippet, defenderSnippet, judgeVerdict,
)
return err
}
@@ -68,13 +95,15 @@ func (d *Database) ListAIDecisions(agentID string, limit int) ([]AIDecisionRecor
agentID = strings.TrimSpace(agentID)
if agentID != "" {
rows, err = d.Query(
`SELECT id, agent_id, prompt_hash, response, commands_executed, ts
`SELECT id, agent_id, prompt_hash, response, commands_executed, ts,
court_session, prosecutor_snippet, defender_snippet, judge_verdict
FROM ai_decisions WHERE agent_id = ? ORDER BY id DESC LIMIT ?`,
agentID, limit,
)
} else {
rows, err = d.Query(
`SELECT id, agent_id, prompt_hash, response, commands_executed, ts
`SELECT id, agent_id, prompt_hash, response, commands_executed, ts,
court_session, prosecutor_snippet, defender_snippet, judge_verdict
FROM ai_decisions ORDER BY id DESC LIMIT ?`,
limit,
)
@@ -88,10 +117,15 @@ func (d *Database) ListAIDecisions(agentID string, limit int) ([]AIDecisionRecor
for rows.Next() {
var rec AIDecisionRecord
var ts string
if err := rows.Scan(&rec.ID, &rec.AgentID, &rec.PromptHash, &rec.Response, &rec.CommandsExecuted, &ts); err != nil {
var courtInt int
if err := rows.Scan(
&rec.ID, &rec.AgentID, &rec.PromptHash, &rec.Response, &rec.CommandsExecuted, &ts,
&courtInt, &rec.ProsecutorSnippet, &rec.DefenderSnippet, &rec.JudgeVerdict,
); err != nil {
return nil, err
}
rec.Timestamp = ts
rec.CourtSession = courtInt != 0
out = append(out, rec)
}
return out, rows.Err()