Research-Stack/5-Applications/scripts/ene.js
Brandon Schneider 0cf775c80e collapse: prover orchestration layers, FAMM verilator harness, swarm topological prober, spec sheets, virtual FPGA system tests, merge conflict resolution
- Prover-Integrated Orchestration Layers (L0-L3): Goedel-Prover-V2 watchdog, BFS-Prover-V2 swarm consensus, bf4prover topology adaptation
- FAMM Verilator benchmark: uniform vs preshaped delay comparison (4.4x speedup)
- Swarm topological device prober: 11 agents probing traces, caps, delays, errors, vias, PDN
- Spec sheet puller: 10 components with key params and topological relevance
- Virtual FPGA system tests: 6/6 passed, 134K ops/s throughput
- Fixed merge conflicts in AI-Newton test_experiment.ipynb
2026-05-06 23:42:01 -05:00

81 lines
2.6 KiB
JavaScript

import Database from "./sqlite.js";
import { join } from "path";
import { createHash } from "crypto";
const dbPath = join(process.cwd(), "data", "substrate_index.db");
export function pkgIngest({ title, body, kind, tags, sessionId, notionId, metric, witness, sigma }) {
const db = new Database(dbPath);
try {
const pkgName = `aiscroll/${title.toLowerCase().replace(/[^a-z0-9]/g, "_")}`;
const version = new Date().toISOString().replace(/[:.]/g, "-");
const timestamp = new Date().toISOString();
// Create a simple SHA256 of the body for provenance
const sha256 = createHash("sha256").update(body).digest("hex");
// Enhance description with Sigma metatyping if available
let description = body.substring(0, 500);
if (sigma) {
description = `[SIGMA: ${sigma.sigma_codon || 'UNK'}] ${sigma.classify || 'data'}\n` +
`OBSERVE: ${sigma.observe || ''}\n` +
`PROVE: ${sigma.prove || ''}\n---\n` +
description;
}
const stmt = db.prepare(`
INSERT INTO packages (
pkg, version, tier, domain, archetype,
description, tags, source, session_id, notion_id,
sha256, indexed_utc, model_status,
foam_score, verification_basis,
idea_weights, extension_points, concept_vector, analog_map, concept_anchor,
audit_rationale
) VALUES (
?, ?, ?, ?, ?,
?, ?, ?, ?, ?,
?, ?, ?,
?, ?,
?, ?, ?, ?, ?,
?
)
`);
const result = stmt.run(
pkgName,
version,
"RESEARCH",
"neural_manifold",
kind || "chat_session",
description,
JSON.stringify(tags || []),
"YourAIScroll",
sessionId || null,
notionId || null,
sha256,
timestamp,
"INGESTED",
metric ? parseFloat(metric.cost) / 65536.0 : 0.0, // Convert Q16.16 to float for foam_score
witness ? witness.trace_hash : "unverified",
JSON.stringify({}), // idea_weights
JSON.stringify([]), // extension_points
JSON.stringify(sigma ? sigma.tags : []), // Use sigma tags for concept_vector as placeholder
JSON.stringify(sigma || {}), // analog_map as placeholder for sigma object
JSON.stringify({ domain: "research", concept: title, resolution: "SEED" }), // concept_anchor
sigma ? JSON.stringify(sigma) : null // audit_rationale
);
return {
ok: true,
pkg: pkgName,
version: version,
rowid: result.lastInsertRowid
};
} catch (error) {
console.error("ENE Ingest Error:", error);
throw error;
} finally {
db.close();
}
}