Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

feat: add Intent, Decision node kinds and update StructuredContext

riley0227decb4890f554
diff --git a/memory-layer/src/main/scala/ix/memory/context/ContextService.scala b/memory-layer/src/main/scala/ix/memory/context/ContextService.scala
index e600fb59..ffb2675f 100644
--- a/memory-layer/src/main/scala/ix/memory/context/ContextService.scala
+++ b/memory-layer/src/main/scala/ix/memory/context/ContextService.scala
@@ -51,13 +51,16 @@ class ContextService(
} yield StructuredContext(
claims = ranked.toList,
conflicts = conflicts.toList,
+ decisions = List.empty,
+ intents = List.empty,
nodes = (seeds ++ expanded.nodes).distinctBy(_.id).toList,
edges = expanded.edges.toList,
metadata = ContextMetadata(
query = question,
seedEntities = seeds.map(_.id).toList,
hopsExpanded = 1,
- asOfRev = rev
+ asOfRev = rev,
+ depth = None
)
)
}
diff --git a/memory-layer/src/main/scala/ix/memory/db/ArangoSchema.scala b/memory-layer/src/main/scala/ix/memory/db/ArangoSchema.scala
index f836edc3..d0c325ea 100644
--- a/memory-layer/src/main/scala/ix/memory/db/ArangoSchema.scala
+++ b/memory-layer/src/main/scala/ix/memory/db/ArangoSchema.scala
@@ -22,46 +22,58 @@ object ArangoSchema {
// Indexes — nodes
val nodes = db.collection("nodes")
nodes.ensurePersistentIndex(
- java.util.Arrays.asList("tenant", "kind"),
+ java.util.Arrays.asList("kind"),
new PersistentIndexOptions()
)
nodes.ensurePersistentIndex(
- java.util.Arrays.asList("tenant", "name"),
+ java.util.Arrays.asList("name"),
new PersistentIndexOptions().sparse(true)
)
+ nodes.ensurePersistentIndex(
+ java.util.Arrays.asList("logical_id"),
+ new PersistentIndexOptions()
+ )
// Indexes — edges
val edges = db.collection("edges")
edges.ensurePersistentIndex(
- java.util.Arrays.asList("tenant", "src"),
+ java.util.Arrays.asList("src"),
new PersistentIndexOptions()
)
edges.ensurePersistentIndex(
- java.util.Arrays.asList("tenant", "dst"),
+ java.util.Arrays.asList("dst"),
new PersistentIndexOptions()
)
edges.ensurePersistentIndex(
- java.util.Arrays.asList("tenant", "predicate"),
+ java.util.Arrays.asList("predicate"),
new PersistentIndexOptions()
)
// Indexes — claims
val claims = db.collection("claims")
claims.ensurePersistentIndex(
- java.util.Arrays.asList("tenant", "entity_id"),
+ java.util.Arrays.asList("entity_id"),
new PersistentIndexOptions()
)
claims.ensurePersistentIndex(
- java.util.Arrays.asList("tenant", "status"),
+ java.util.Arrays.asList("status"),
new PersistentIndexOptions()
)
+ claims.ensurePersistentIndex(
+ java.util.Arrays.asList("statement"),
+ new PersistentIndexOptions().sparse(true)
+ )
// Indexes — patches
val patches = db.collection("patches")
patches.ensurePersistentIndex(
- java.util.Arrays.asList("tenant", "patch_id"),
+ java.util.Arrays.asList("patch_id"),
new PersistentIndexOptions().unique(true)
)
+ patches.ensurePersistentIndex(
+ java.util.Arrays.asList("data.source.uri", "data.source.extractor"),
+ new PersistentIndexOptions()
+ )
// Indexes — idempotency_keys
val idem = db.collection("idempotency_keys")
diff --git a/memory-layer/src/main/scala/ix/memory/model/Node.scala b/memory-layer/src/main/scala/ix/memory/model/Node.scala
index b47f0b95..d3ad52e7 100644
--- a/memory-layer/src/main/scala/ix/memory/model/Node.scala
+++ b/memory-layer/src/main/scala/ix/memory/model/Node.scala
@@ -16,6 +16,8 @@ object NodeKind {
case object ConfigEntry extends NodeKind
case object Service extends NodeKind
case object Endpoint extends NodeKind
+ case object Intent extends NodeKind
+ case object Decision extends NodeKind
private val nameMap: Map[String, NodeKind] = Map(
"module" -> Module,
@@ -26,7 +28,9 @@ object NodeKind {
"config" -> Config,
"config_entry" -> ConfigEntry,
"service" -> Service,
- "endpoint" -> Endpoint
+ "endpoint" -> Endpoint,
+ "intent" -> Intent,
+ "decision" -> Decision
)
implicit val encoder: Encoder[NodeKind] = Encoder[String].contramap {
@@ -39,6 +43,8 @@ object NodeKind {
case ConfigEntry => "config_entry"
case Service => "service"
case Endpoint => "endpoint"
+ case Intent => "intent"
+ case Decision => "decision"
}
implicit val decoder: Decoder[NodeKind] = Decoder[String].emap { s =>
diff --git a/memory-layer/src/main/scala/ix/memory/model/StructuredContext.scala b/memory-layer/src/main/scala/ix/memory/model/StructuredContext.scala
index 725b5bd6..be8b5ebf 100644
--- a/memory-layer/src/main/scala/ix/memory/model/StructuredContext.scala
+++ b/memory-layer/src/main/scala/ix/memory/model/StructuredContext.scala
@@ -26,11 +26,38 @@ object ConflictReport {
implicit val decoder: Decoder[ConflictReport] = deriveDecoder[ConflictReport]
}
+final case class DecisionReport(
+ title: String,
+ rationale: String,
+ entityId: Option[NodeId],
+ intentId: Option[NodeId],
+ rev: Rev
+)
+
+object DecisionReport {
+ implicit val encoder: Encoder[DecisionReport] = deriveEncoder[DecisionReport]
+ implicit val decoder: Decoder[DecisionReport] = deriveDecoder[DecisionReport]
+}
+
+final case class IntentReport(
+ id: NodeId,
+ statement: String,
+ status: String,
+ confidence: Double,
+ parentIntent: Option[String]
+)
+
+object IntentReport {
+ implicit val encoder: Encoder[IntentReport] = deriveEncoder[IntentReport]
+ implicit val decoder: Decoder[IntentReport] = deriveDecoder[IntentReport]
+}
+
final case class ContextMetadata(
query: String,
seedEntities: List[NodeId],
hopsExpanded: Int,
- asOfRev: Rev
+ asOfRev: Rev,
+ depth: Option[String]
)
object ContextMetadata {
@@ -41,6 +68,8 @@ object ContextMetadata {
final case class StructuredContext(
claims: List[ScoredClaim],
conflicts: List[ConflictReport],
+ decisions: List[DecisionReport],
+ intents: List[IntentReport],
nodes: List[GraphNode],
edges: List[GraphEdge],
metadata: ContextMetadata
diff --git a/memory-layer/src/test/scala/ix/memory/model/ModelSpec.scala b/memory-layer/src/test/scala/ix/memory/model/ModelSpec.scala
index 9cd0e7a5..fa411c8c 100644
--- a/memory-layer/src/test/scala/ix/memory/model/ModelSpec.scala
+++ b/memory-layer/src/test/scala/ix/memory/model/ModelSpec.scala
@@ -77,7 +77,9 @@ class ModelSpec extends AnyFlatSpec with Matchers {
NodeKind.Config,
NodeKind.ConfigEntry,
NodeKind.Service,
- NodeKind.Endpoint
+ NodeKind.Endpoint,
+ NodeKind.Intent,
+ NodeKind.Decision
)
variants.foreach { nk =>
@@ -87,6 +89,11 @@ class ModelSpec extends AnyFlatSpec with Matchers {
}
}
+ it should "include Intent and Decision" in {
+ NodeKind.decoder.decodeJson(Json.fromString("intent")) shouldBe Right(NodeKind.Intent)
+ NodeKind.decoder.decodeJson(Json.fromString("decision")) shouldBe Right(NodeKind.Decision)
+ }
+
// ── ClaimStatus ─────────────────────────────────────────────────────
"ClaimStatus" should "encode and decode all variants" in {