Skip to content

armgit / Ix

Public Imported from GitHub
0

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

Remove TenantId from all model classes and fix all references

riley022707029bf6ab6b
diff --git a/memory-layer/src/main/scala/ix/memory/api/ConflictRoutes.scala b/memory-layer/src/main/scala/ix/memory/api/ConflictRoutes.scala
index d69294f7..76899595 100644
--- a/memory-layer/src/main/scala/ix/memory/api/ConflictRoutes.scala
+++ b/memory-layer/src/main/scala/ix/memory/api/ConflictRoutes.scala
@@ -10,7 +10,7 @@ import org.http4s.circe.CirceEntityCodec._
import org.http4s.dsl.io._
import ix.memory.conflict.ConflictService
-import ix.memory.model.{ClaimId, ConflictId, ConflictStatus, TenantId}
+import ix.memory.model.{ClaimId, ConflictId, ConflictStatus}
case class ResolveRequest(winnerClaimId: String)
@@ -23,29 +23,21 @@ class ConflictRoutes(conflictService: ConflictService) {
val routes: HttpRoutes[IO] = HttpRoutes.of[IO] {
- // GET /v1/conflicts?tenant=<uuid>&status=<optional>
+ // GET /v1/conflicts?status=<optional>
case req @ GET -> Root / "v1" / "conflicts" =>
+ val status = req.params.get("status").flatMap(parseStatus)
(for {
- tenantStr <- IO.fromOption(req.params.get("tenant"))(
- new IllegalArgumentException("Missing required query parameter: tenant")
- )
- tenantId <- IO.fromTry(scala.util.Try(UUID.fromString(tenantStr))).map(TenantId(_))
- status = req.params.get("status").flatMap(parseStatus)
- conflicts <- conflictService.listConflicts(tenantId, status)
+ conflicts <- conflictService.listConflicts(status)
resp <- Ok(conflicts)
} yield resp).handleErrorWith(ErrorHandler.handle(_))
- // POST /v1/conflicts/:id/resolve?tenant=<uuid>
+ // POST /v1/conflicts/:id/resolve
case req @ POST -> Root / "v1" / "conflicts" / UUIDVar(id) / "resolve" =>
(for {
- tenantStr <- IO.fromOption(req.params.get("tenant"))(
- new IllegalArgumentException("Missing required query parameter: tenant")
- )
- tenantId <- IO.fromTry(scala.util.Try(UUID.fromString(tenantStr))).map(TenantId(_))
body <- req.as[ResolveRequest]
winnerClaimId <- IO.fromTry(scala.util.Try(UUID.fromString(body.winnerClaimId))).map(ClaimId(_))
conflictId = ConflictId(id)
- _ <- conflictService.resolve(tenantId, conflictId, winnerClaimId)
+ _ <- conflictService.resolve(conflictId, winnerClaimId)
resp <- Ok(io.circe.Json.obj("status" -> io.circe.Json.fromString("resolved")))
} yield resp).handleErrorWith(ErrorHandler.handle(_))
}
diff --git a/memory-layer/src/main/scala/ix/memory/api/ContextRoutes.scala b/memory-layer/src/main/scala/ix/memory/api/ContextRoutes.scala
index 428f9288..1ebacb45 100644
--- a/memory-layer/src/main/scala/ix/memory/api/ContextRoutes.scala
+++ b/memory-layer/src/main/scala/ix/memory/api/ContextRoutes.scala
@@ -1,7 +1,5 @@
package ix.memory.api
-import java.util.UUID
-
import cats.effect.IO
import io.circe.{Decoder, Encoder}
import io.circe.generic.semiauto.{deriveDecoder, deriveEncoder}
@@ -10,9 +8,9 @@ import org.http4s.circe.CirceEntityCodec._
import org.http4s.dsl.io._
import ix.memory.context.ContextService
-import ix.memory.model.{Rev, TenantId}
+import ix.memory.model.Rev
-case class ContextRequest(query: String, tenant: String, asOfRev: Option[Long])
+case class ContextRequest(query: String, asOfRev: Option[Long])
object ContextRequest {
implicit val decoder: Decoder[ContextRequest] = deriveDecoder[ContextRequest]
@@ -25,9 +23,8 @@ class ContextRoutes(contextService: ContextService) {
case req @ POST -> Root / "v1" / "context" =>
(for {
body <- req.as[ContextRequest]
- tenantId <- IO.fromTry(scala.util.Try(UUID.fromString(body.tenant))).map(TenantId(_))
asOfRev = body.asOfRev.map(Rev(_))
- result <- contextService.query(tenantId, body.query, asOfRev)
+ result <- contextService.query(body.query, asOfRev)
resp <- Ok(result)
} yield resp).handleErrorWith(ErrorHandler.handle(_))
}
diff --git a/memory-layer/src/main/scala/ix/memory/api/DiffRoutes.scala b/memory-layer/src/main/scala/ix/memory/api/DiffRoutes.scala
index db6c1f32..05a7a107 100644
--- a/memory-layer/src/main/scala/ix/memory/api/DiffRoutes.scala
+++ b/memory-layer/src/main/scala/ix/memory/api/DiffRoutes.scala
@@ -12,7 +12,7 @@ import org.http4s.dsl.io._
import ix.memory.db.GraphQueryApi
import ix.memory.model._
-case class DiffRequest(tenant: String, fromRev: Long, toRev: Long, entityId: Option[String])
+case class DiffRequest(fromRev: Long, toRev: Long, entityId: Option[String])
object DiffRequest {
implicit val decoder: Decoder[DiffRequest] = deriveDecoder[DiffRequest]
@@ -42,7 +42,6 @@ class DiffRoutes(queryApi: GraphQueryApi) {
case req @ POST -> Root / "v1" / "diff" =>
(for {
body <- req.as[DiffRequest]
- tenantId <- IO.fromTry(scala.util.Try(UUID.fromString(body.tenant))).map(TenantId(_))
_ <- IO.raiseWhen(body.fromRev >= body.toRev)(
new IllegalArgumentException("fromRev must be less than toRev")
)
@@ -51,7 +50,7 @@ class DiffRoutes(queryApi: GraphQueryApi) {
// Diff a single entity
for {
eid <- IO.fromTry(scala.util.Try(UUID.fromString(eidStr))).map(NodeId(_))
- result <- diffEntity(tenantId, eid, Rev(body.fromRev), Rev(body.toRev))
+ result <- diffEntity(eid, Rev(body.fromRev), Rev(body.toRev))
} yield result.toVector
case None =>
IO.raiseError(new UnsupportedOperationException(
@@ -63,11 +62,11 @@ class DiffRoutes(queryApi: GraphQueryApi) {
}
private def diffEntity(
- tenant: TenantId, nodeId: NodeId, fromRev: Rev, toRev: Rev
+ nodeId: NodeId, fromRev: Rev, toRev: Rev
): IO[Option[DiffEntry]] =
for {
- atFrom <- queryApi.getNode(tenant, nodeId, asOfRev = Some(fromRev))
- atTo <- queryApi.getNode(tenant, nodeId, asOfRev = Some(toRev))
+ atFrom <- queryApi.getNode(nodeId, asOfRev = Some(fromRev))
+ atTo <- queryApi.getNode(nodeId, asOfRev = Some(toRev))
} yield {
(atFrom, atTo) match {
case (None, None) => None
diff --git a/memory-layer/src/main/scala/ix/memory/api/EntityRoutes.scala b/memory-layer/src/main/scala/ix/memory/api/EntityRoutes.scala
index 51c20ead..20023d1b 100644
--- a/memory-layer/src/main/scala/ix/memory/api/EntityRoutes.scala
+++ b/memory-layer/src/main/scala/ix/memory/api/EntityRoutes.scala
@@ -35,44 +35,36 @@ class EntityRoutes(queryApi: GraphQueryApi) {
val routes: HttpRoutes[IO] = HttpRoutes.of[IO] {
- // GET /v1/entity/:id?tenant=<uuid>
- case req @ GET -> Root / "v1" / "entity" / UUIDVar(id) =>
+ // GET /v1/entity/:id
+ case GET -> Root / "v1" / "entity" / UUIDVar(id) =>
+ val nodeId = NodeId(id)
(for {
- tenantStr <- IO.fromOption(req.params.get("tenant"))(
- new IllegalArgumentException("Missing required query parameter: tenant")
- )
- tenantId <- IO.fromTry(scala.util.Try(UUID.fromString(tenantStr))).map(TenantId(_))
- nodeId = NodeId(id)
- nodeOpt <- queryApi.getNode(tenantId, nodeId)
+ nodeOpt <- queryApi.getNode(nodeId)
node <- IO.fromOption(nodeOpt)(
new NoSuchElementException(s"Entity not found: $id")
)
- claims <- queryApi.getClaims(tenantId, nodeId)
- expanded <- queryApi.expand(tenantId, nodeId, Direction.Both)
+ claims <- queryApi.getClaims(nodeId)
+ expanded <- queryApi.expand(nodeId, Direction.Both)
resp <- Ok(EntityResponse(node, claims, expanded.edges))
} yield resp).handleErrorWith(ErrorHandler.handle(_))
- // POST /v1/provenance/:id?tenant=<uuid>
- case req @ POST -> Root / "v1" / "provenance" / UUIDVar(id) =>
+ // POST /v1/provenance/:id
+ case POST -> Root / "v1" / "provenance" / UUIDVar(id) =>
+ val nodeId = NodeId(id)
(for {
- tenantStr <- IO.fromOption(req.params.get("tenant"))(
- new IllegalArgumentException("Missing required query parameter: tenant")
- )
- tenantId <- IO.fromTry(scala.util.Try(UUID.fromString(tenantStr))).map(TenantId(_))
- nodeId = NodeId(id)
// Verify entity exists
- nodeOpt <- queryApi.getNode(tenantId, nodeId)
+ nodeOpt <- queryApi.getNode(nodeId)
_ <- IO.fromOption(nodeOpt)(
new NoSuchElementException(s"Entity not found: $id")
)
// Query patches that touched this entity
- chain <- queryProvenanceChain(tenantId, nodeId)
+ chain <- queryProvenanceChain(nodeId)
resp <- Ok(ProvenanceResponse(nodeId, chain))
} yield resp).handleErrorWith(ErrorHandler.handle(_))
}
- private def queryProvenanceChain(tenant: TenantId, nodeId: NodeId): IO[Vector[ProvenanceEntry]] =
- queryApi.getPatchesForEntity(tenant, nodeId).map { jsons =>
+ private def queryProvenanceChain(nodeId: NodeId): IO[Vector[ProvenanceEntry]] =
+ queryApi.getPatchesForEntity(nodeId).map { jsons =>
jsons.flatMap { json =>
val c = json.hcursor
val dataC = c.downField("data")
diff --git a/memory-layer/src/main/scala/ix/memory/api/IngestionRoutes.scala b/memory-layer/src/main/scala/ix/memory/api/IngestionRoutes.scala
index bbec9ee6..13abea0a 100644
--- a/memory-layer/src/main/scala/ix/memory/api/IngestionRoutes.scala
+++ b/memory-layer/src/main/scala/ix/memory/api/IngestionRoutes.scala
@@ -1,7 +1,6 @@
package ix.memory.api
import java.nio.file.Paths
-import java.util.UUID
import cats.effect.IO
import io.circe.{Decoder, Encoder}
@@ -11,9 +10,8 @@ import org.http4s.circe.CirceEntityCodec._
import org.http4s.dsl.io._
import ix.memory.ingestion.IngestionService
-import ix.memory.model.TenantId
-case class IngestRequest(path: String, tenant: String, language: Option[String], recursive: Option[Boolean])
+case class IngestRequest(path: String, language: Option[String], recursive: Option[Boolean])
object IngestRequest {
implicit val decoder: Decoder[IngestRequest] = deriveDecoder[IngestRequest]
@@ -33,12 +31,11 @@ class IngestionRoutes(ingestionService: IngestionService) {
case req @ POST -> Root / "v1" / "ingest" =>
(for {
body <- req.as[IngestRequest]
- tenantId <- IO.fromTry(scala.util.Try(UUID.fromString(body.tenant))).map(TenantId(_))
_ <- IO.raiseWhen(body.path.contains(".."))(
new IllegalArgumentException("Path traversal not allowed")
)
path = Paths.get(body.path)
- result <- ingestionService.ingestPath(tenantId, path, body.language, body.recursive.getOrElse(false))
+ result <- ingestionService.ingestPath(path, body.language, body.recursive.getOrElse(false))
resp <- Ok(IngestResponse(
filesProcessed = result.filesProcessed,
patchesApplied = result.patchesApplied,
diff --git a/memory-layer/src/main/scala/ix/memory/conflict/ConflictService.scala b/memory-layer/src/main/scala/ix/memory/conflict/ConflictService.scala
index 0e24408c..bce05638 100644
--- a/memory-layer/src/main/scala/ix/memory/conflict/ConflictService.scala
+++ b/memory-layer/src/main/scala/ix/memory/conflict/ConflictService.scala
@@ -8,16 +8,16 @@ import ix.memory.context.ConflictDetector
class ConflictService(client: ArangoClient, queryApi: GraphQueryApi, writeApi: GraphWriteApi) {
- def detectAndStore(tenant: TenantId, claims: Vector[ScoredClaim],
+ def detectAndStore(claims: Vector[ScoredClaim],
detector: ConflictDetector): IO[Vector[ConflictReport]] = {
val reports = detector.detect(claims)
// Store conflict sets in DB for each report
reports.traverse { report =>
- storeConflictSet(tenant, report).map(_ => report)
+ storeConflictSet(report).map(_ => report)
}
}
- private def storeConflictSet(tenant: TenantId, report: ConflictReport): IO[Unit] = {
+ private def storeConflictSet(report: ConflictReport): IO[Unit] = {
client.execute(
"""INSERT {
| _key: @key,
@@ -26,7 +26,6 @@ class ConflictService(client: ArangoClient, queryApi: GraphQueryApi, writeApi: G
| status: "open",
| candidate_claims: @candidates,
| winner_claim_id: null,
- | tenant: @tenant,
| created_rev: 0
|} INTO conflict_sets OPTIONS { overwriteMode: "ignore" }""".stripMargin,
Map(
@@ -35,14 +34,13 @@ class ConflictService(client: ArangoClient, queryApi: GraphQueryApi, writeApi: G
"reason" -> report.reason.asInstanceOf[AnyRef],
"candidates" -> java.util.Arrays.asList(
report.claimA.value.toString, report.claimB.value.toString
- ).asInstanceOf[AnyRef],
- "tenant" -> tenant.value.toString.asInstanceOf[AnyRef]
+ ).asInstanceOf[AnyRef]
)
)
}
- def listConflicts(tenant: TenantId, status: Option[ConflictStatus] = None): IO[Vector[ConflictSet]] = {
- val statusFilter = status.map(_ => " AND cs.status == @status").getOrElse("")
+ def listConflicts(status: Option[ConflictStatus] = None): IO[Vector[ConflictSet]] = {
+ val statusFilter = status.map(_ => " FILTER cs.status == @status").getOrElse("")
val statusVar: Map[String, AnyRef] = status.map { s =>
val str = s match {
case ConflictStatus.Open => "open"
@@ -54,20 +52,19 @@ class ConflictService(client: ArangoClient, queryApi: GraphQueryApi, writeApi: G
client.query(
s"""FOR cs IN conflict_sets
- | FILTER cs.tenant == @tenant$statusFilter
+ | $statusFilter
| RETURN cs""".stripMargin,
- Map("tenant" -> tenant.value.toString.asInstanceOf[AnyRef]) ++ statusVar
+ statusVar
).map(_.flatMap(parseConflictSet).toVector)
}
- def resolve(tenant: TenantId, conflictId: ConflictId, winnerClaimId: ClaimId): IO[Unit] = {
+ def resolve(conflictId: ConflictId, winnerClaimId: ClaimId): IO[Unit] = {
client.execute(
"""FOR cs IN conflict_sets
- | FILTER cs._key == @key AND cs.tenant == @tenant
+ | FILTER cs._key == @key
| UPDATE cs WITH { status: "resolved", winner_claim_id: @winner } IN conflict_sets""".stripMargin,
Map(
"key" -> conflictId.value.toString.asInstanceOf[AnyRef],
- "tenant" -> tenant.value.toString.asInstanceOf[AnyRef],
"winner" -> winnerClaimId.value.toString.asInstanceOf[AnyRef]
)
)
diff --git a/memory-layer/src/main/scala/ix/memory/context/ClaimCollector.scala b/memory-layer/src/main/scala/ix/memory/context/ClaimCollector.scala
index f4757dde..cc2f696d 100644
--- a/memory-layer/src/main/scala/ix/memory/context/ClaimCollector.scala
+++ b/memory-layer/src/main/scala/ix/memory/context/ClaimCollector.scala
@@ -8,8 +8,8 @@ import ix.memory.model._
class ClaimCollector(queryApi: GraphQueryApi) {
- def collect(tenant: TenantId, nodeIds: Vector[NodeId]): IO[Vector[Claim]] =
+ def collect(nodeIds: Vector[NodeId]): IO[Vector[Claim]] =
nodeIds
- .parTraverse(id => queryApi.getClaims(tenant, id))
+ .parTraverse(id => queryApi.getClaims(id))
.map(_.flatten.distinctBy(_.id))
}
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 2ec66722..e600fb59 100644
--- a/memory-layer/src/main/scala/ix/memory/context/ContextService.scala
+++ b/memory-layer/src/main/scala/ix/memory/context/ContextService.scala
@@ -14,24 +14,24 @@ class ContextService(
conflictDetector: ConflictDetector
) {
- def query(tenant: TenantId, question: String,
+ def query(question: String,
asOfRev: Option[Rev] = None): IO[StructuredContext] =
for {
// 1. Extract entity keywords from the natural language query
terms <- IO.pure(EntityExtractor.extract(question))
// 2. Seed: search the graph for nodes matching extracted terms
- seeds <- seeder.seed(tenant, terms, asOfRev)
+ seeds <- seeder.seed(terms, asOfRev)
// 3. Expand: traverse the graph 1 hop from each seed
- expanded <- expander.expand(tenant, seeds.map(_.id), hops = 1, asOfRev = asOfRev)
+ expanded <- expander.expand(seeds.map(_.id), hops = 1, asOfRev = asOfRev)
// 4. Collect claims for all discovered nodes
allNodeIds = (seeds.map(_.id) ++ expanded.nodes.map(_.id)).distinct
- claims <- claimCollector.collect(tenant, allNodeIds)
+ claims <- claimCollector.collect(allNodeIds)
// 5. Score each claim
- rev <- asOfRev.fold(queryApi.getLatestRev(tenant))(IO.pure)
+ rev <- asOfRev.fold(queryApi.getLatestRev)(IO.pure)
scored = claims.map { c =>
confidenceScorer.score(c, ScoringContext(
latestRev = rev,
diff --git a/memory-layer/src/main/scala/ix/memory/context/GraphExpander.scala b/memory-layer/src/main/scala/ix/memory/context/GraphExpander.scala
index 86832ea4..8c712aff 100644
--- a/memory-layer/src/main/scala/ix/memory/context/GraphExpander.scala
+++ b/memory-layer/src/main/scala/ix/memory/context/GraphExpander.scala
@@ -8,12 +8,12 @@ import ix.memory.model._
class GraphExpander(queryApi: GraphQueryApi) {
- def expand(tenant: TenantId, seeds: Vector[NodeId], hops: Int = 1,
+ def expand(seeds: Vector[NodeId], hops: Int = 1,
predicates: Option[Set[String]] = None,
asOfRev: Option[Rev] = None): IO[ExpandResult] =
seeds
.parTraverse { nodeId =>
- queryApi.expand(tenant, nodeId, Direction.Both, predicates, hops, asOfRev)
+ queryApi.expand(nodeId, Direction.Both, predicates, hops, asOfRev)
}
.map { results =>
val allNodes = results.flatMap(_.nodes).distinctBy(_.id)
diff --git a/memory-layer/src/main/scala/ix/memory/context/GraphSeeder.scala b/memory-layer/src/main/scala/ix/memory/context/GraphSeeder.scala
index 2fa62387..13c1307c 100644
--- a/memory-layer/src/main/scala/ix/memory/context/GraphSeeder.scala
+++ b/memory-layer/src/main/scala/ix/memory/context/GraphSeeder.scala
@@ -8,9 +8,9 @@ import ix.memory.model._
class GraphSeeder(queryApi: GraphQueryApi) {
- def seed(tenant: TenantId, terms: Vector[String],
+ def seed(terms: Vector[String],
asOfRev: Option[Rev] = None): IO[Vector[GraphNode]] =
terms
- .parTraverse(term => queryApi.searchNodes(tenant, term))
+ .parTraverse(term => queryApi.searchNodes(term))
.map(_.flatten.distinctBy(_.id))
}
diff --git a/memory-layer/src/main/scala/ix/memory/db/ArangoGraphQueryApi.scala b/memory-layer/src/main/scala/ix/memory/db/ArangoGraphQueryApi.scala
index 212caeb3..bc7837f1 100644
--- a/memory-layer/src/main/scala/ix/memory/db/ArangoGraphQueryApi.scala
+++ b/memory-layer/src/main/scala/ix/memory/db/ArangoGraphQueryApi.scala
@@ -16,56 +16,49 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
// ── Public API ──────────────────────────────────────────────────────
- override def getNode(tenant: TenantId, id: NodeId, asOfRev: Option[Rev] = None): IO[Option[GraphNode]] =
+ override def getNode(id: NodeId, asOfRev: Option[Rev] = None): IO[Option[GraphNode]] =
for {
- rev <- asOfRev.fold(getLatestRev(tenant))(IO.pure)
+ rev <- asOfRev.fold(getLatestRev)(IO.pure)
result <- client.queryOne(
"""FOR n IN nodes
| FILTER n._key == @id
- | AND n.tenant == @tenant
| AND n.created_rev <= @rev
| AND (n.deleted_rev == null OR @rev < n.deleted_rev)
| RETURN n""".stripMargin,
Map(
"id" -> id.value.toString.asInstanceOf[AnyRef],
- "tenant" -> tenant.value.toString.asInstanceOf[AnyRef],
"rev" -> Long.box(rev.value).asInstanceOf[AnyRef]
)
)
} yield result.flatMap(parseNode)
- override def findNodesByKind(tenant: TenantId, kind: NodeKind, limit: Int = 100): IO[Vector[GraphNode]] =
+ override def findNodesByKind(kind: NodeKind, limit: Int = 100): IO[Vector[GraphNode]] =
client.query(
"""FOR n IN nodes
- | FILTER n.tenant == @tenant
- | AND n.kind == @kind
+ | FILTER n.kind == @kind
| AND n.deleted_rev == null
| LIMIT @limit
| RETURN n""".stripMargin,
Map(
- "tenant" -> tenant.value.toString.asInstanceOf[AnyRef],
"kind" -> nodeKindToString(kind).asInstanceOf[AnyRef],
"limit" -> Int.box(limit).asInstanceOf[AnyRef]
)
).map(_.flatMap(parseNode).toVector)
- override def searchNodes(tenant: TenantId, text: String, limit: Int = 20): IO[Vector[GraphNode]] =
+ override def searchNodes(text: String, limit: Int = 20): IO[Vector[GraphNode]] =
client.query(
"""FOR n IN nodes
- | FILTER n.tenant == @tenant
- | AND CONTAINS(LOWER(n.name), LOWER(@text))
+ | FILTER CONTAINS(LOWER(n.name), LOWER(@text))
| AND n.deleted_rev == null
| LIMIT @limit
| RETURN n""".stripMargin,
Map(
- "tenant" -> tenant.value.toString.asInstanceOf[AnyRef],
"text" -> text.asInstanceOf[AnyRef],
"limit" -> Int.box(limit).asInstanceOf[AnyRef]
)
).map(_.flatMap(parseNode).toVector)
override def expand(
- tenant: TenantId,
nodeId: NodeId,
direction: Direction,
predicates: Option[Set[String]] = None,
@@ -82,15 +75,13 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
def buildEdgeQuery(srcOrDst: String): String =
s"""FOR e IN edges
- | FILTER e.tenant == @tenant
- | AND e.$srcOrDst == @nodeId
+ | FILTER e.$srcOrDst == @nodeId
| $deletedFilter
| $predicateFilter
| RETURN e""".stripMargin
def buildBindVars(rev: Rev): Map[String, AnyRef] = {
val base = Map(
- "tenant" -> tenant.value.toString.asInstanceOf[AnyRef],
"nodeId" -> nodeId.value.toString.asInstanceOf[AnyRef],
"rev" -> Long.box(rev.value).asInstanceOf[AnyRef]
)
@@ -105,7 +96,7 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
for {
// I4: resolve revision once at the start so edges and nodes see the same snapshot
- resolvedRev <- asOfRev.fold(getLatestRev(tenant))(IO.pure)
+ resolvedRev <- asOfRev.fold(getLatestRev)(IO.pure)
bindVars = buildBindVars(resolvedRev)
outEdges <- direction match {
@@ -137,12 +128,11 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
val idList = new java.util.ArrayList[String]()
neighborIds.foreach(nid => idList.add(nid.value.toString))
val aql = """FOR n IN nodes
- | FILTER n.id IN @ids AND n.tenant == @tenant
+ | FILTER n.id IN @ids
| AND n.created_rev <= @rev AND (n.deleted_rev == null OR @rev < n.deleted_rev)
| RETURN n""".stripMargin
client.query(aql, Map(
"ids" -> idList.asInstanceOf[AnyRef],
- "tenant" -> tenant.value.toString.asInstanceOf[AnyRef],
"rev" -> Long.box(resolvedRev.value).asInstanceOf[AnyRef]
)).map(_.flatMap(parseNode).toVector)
}
@@ -150,32 +140,29 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
} yield ExpandResult(nodes, allEdges)
}
- override def getClaims(tenant: TenantId, entityId: NodeId): IO[Vector[Claim]] =
+ override def getClaims(entityId: NodeId): IO[Vector[Claim]] =
client.query(
"""FOR c IN claims
- | FILTER c.tenant == @tenant
- | AND c.entity_id == @entityId
+ | FILTER c.entity_id == @entityId
| AND c.deleted_rev == null
| RETURN c""".stripMargin,
Map(
- "tenant" -> tenant.value.toString.asInstanceOf[AnyRef],
"entityId" -> entityId.value.toString.asInstanceOf[AnyRef]
)
).map(_.flatMap(parseClaim).toVector)
- override def getLatestRev(tenant: TenantId): IO[Rev] =
+ override def getLatestRev: IO[Rev] =
client.queryOne(
"""FOR r IN revisions
| FILTER r._key == @key
| RETURN r.rev""".stripMargin,
- Map("key" -> tenant.value.toString.asInstanceOf[AnyRef])
+ Map("key" -> "current".asInstanceOf[AnyRef])
).map(_.flatMap(_.as[Long].toOption).map(Rev(_)).getOrElse(Rev(0L)))
- override def getPatchesForEntity(tenant: TenantId, entityId: NodeId): IO[List[Json]] = {
+ override def getPatchesForEntity(entityId: NodeId): IO[List[Json]] = {
val nodeIdStr = entityId.value.toString
client.query(
"""FOR p IN patches
- | FILTER p.tenant == @tenant
| FILTER LENGTH(
| FOR op IN (IS_ARRAY(p.data.ops) ? p.data.ops : [])
| FILTER op.id == @nodeId OR op.entityId == @nodeId
@@ -184,7 +171,6 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
| SORT p.rev ASC
| RETURN p""".stripMargin,
Map(
- "tenant" -> tenant.value.toString.asInstanceOf[AnyRef],
"nodeId" -> nodeIdStr.asInstanceOf[AnyRef]
)
)
@@ -200,9 +186,6 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
.map(NodeId(_))
kindStr <- c.get[String]("kind").toOption
kind <- NodeKind.decoder.decodeJson(Json.fromString(kindStr)).toOption
- tenantStr <- c.get[String]("tenant").toOption
- .flatMap(s => scala.util.Try(UUID.fromString(s)).toOption)
- .map(TenantId(_))
attrs <- c.get[Json]("attrs").toOption
provenance <- parseProvenance(c.downField("provenance").focus)
createdRev <- c.get[Long]("created_rev").toOption.map(Rev(_))
@@ -211,7 +194,7 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
.flatMap(s => scala.util.Try(Instant.parse(s)).toOption)
updatedAt <- c.get[String]("updated_at").toOption
.flatMap(s => scala.util.Try(Instant.parse(s)).toOption)
- } yield GraphNode(id, kind, tenantStr, attrs, provenance, createdRev, deletedRev, createdAt, updatedAt)
+ } yield GraphNode(id, kind, attrs, provenance, createdRev, deletedRev, createdAt, updatedAt)
if (result.isEmpty) log.warn("Failed to parse node from JSON: {}", json.noSpaces.take(200))
result
}
@@ -229,14 +212,11 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
.flatMap(s => scala.util.Try(UUID.fromString(s)).toOption)
.map(NodeId(_))
predicate <- c.get[String]("predicate").toOption.map(EdgePredicate(_))
- tenantStr <- c.get[String]("tenant").toOption
- .flatMap(s => scala.util.Try(UUID.fromString(s)).toOption)
- .map(TenantId(_))
attrs <- c.get[Json]("attrs").toOption
provenance <- parseProvenance(c.downField("provenance").focus)
createdRev <- c.get[Long]("created_rev").toOption.map(Rev(_))
deletedRev = c.get[Long]("deleted_rev").toOption.map(Rev(_))
- } yield GraphEdge(id, src, dst, predicate, tenantStr, attrs, provenance, createdRev, deletedRev)
+ } yield GraphEdge(id, src, dst, predicate, attrs, provenance, createdRev, deletedRev)
if (result.isEmpty) log.warn("Failed to parse edge from JSON: {}", json.noSpaces.take(200))
result
}
diff --git a/memory-layer/src/main/scala/ix/memory/db/ArangoGraphWriteApi.scala b/memory-layer/src/main/scala/ix/memory/db/ArangoGraphWriteApi.scala
index d81d69d5..185d93e3 100644
--- a/memory-layer/src/main/scala/ix/memory/db/ArangoGraphWriteApi.scala
+++ b/memory-layer/src/main/scala/ix/memory/db/ArangoGraphWriteApi.scala
@@ -28,7 +28,7 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
client.beginTransaction(ReadCollections, WriteCollections).flatMap { txId =>
val commit = for {
// Step 1: Check idempotency inside the transaction
- idempotent <- checkIdempotency(patch.patchId, patch.tenant, txId)
+ idempotent <- checkIdempotency(patch.patchId, txId)
result <- idempotent match {
case Some(storedRev) =>
// Already applied — commit the (read-only) transaction and return
@@ -46,22 +46,22 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
// ── Private helpers ───────────────────────────────────────────────
- private def checkIdempotency(patchId: PatchId, tenant: TenantId, txId: String): IO[Option[Rev]] =
+ private def checkIdempotency(patchId: PatchId, txId: String): IO[Option[Rev]] =
client.queryOne(
"""FOR ik IN idempotency_keys
| FILTER ik.key == @key
| RETURN ik.rev""".stripMargin,
- Map("key" -> idempotencyKey(patchId, tenant).asInstanceOf[AnyRef]),
+ Map("key" -> idempotencyKey(patchId).asInstanceOf[AnyRef]),
txId = Some(txId)
).map(_.flatMap(_.as[Long].toOption).map(Rev(_)))
- private def idempotencyKey(patchId: PatchId, tenant: TenantId): String =
- s"${tenant.value}:${patchId.value}"
+ private def idempotencyKey(patchId: PatchId): String =
+ patchId.value.toString
private def doCommit(patch: GraphPatch, txId: String): IO[CommitResult] =
for {
- // Step 2: Load latest_rev for tenant (inside transaction)
- latestRev <- loadLatestRev(patch.tenant, txId)
+ // Step 2: Load latest_rev (inside transaction)
+ latestRev <- loadLatestRev(txId)
// Step 3: Check baseRev (if > 0, must match latest)
result <- {
@@ -77,9 +77,9 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
// Step 6: Store patch
_ <- storePatch(patch, newRev, txId)
// Step 7: Store idempotency key
- _ <- storeIdempotencyKey(patch.patchId, patch.tenant, newRev, txId)
- // Step 8: Update tenant revision
- _ <- updateTenantRevision(patch.tenant, newRev, txId)
+ _ <- storeIdempotencyKey(patch.patchId, newRev, txId)
+ // Step 8: Update revision
+ _ <- updateRevision(newRev, txId)
// Step 9: Commit the transaction
_ <- client.commitTransaction(txId)
} yield CommitResult(Rev(newRev), CommitStatus.Ok)
@@ -87,12 +87,12 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
}
} yield result
- private def loadLatestRev(tenant: TenantId, txId: String): IO[Long] =
+ private def loadLatestRev(txId: String): IO[Long] =
client.queryOne(
"""FOR r IN revisions
| FILTER r._key == @key
| RETURN r.rev""".stripMargin,
- Map("key" -> tenant.value.toString.asInstanceOf[AnyRef]),
+ Map("key" -> "current".asInstanceOf[AnyRef]),
txId = Some(txId)
).map(_.flatMap(_.as[Long].toOption).getOrElse(0L))
@@ -108,7 +108,6 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
| id: @id,
| kind: @kind,
| name: @name,
- | tenant: @tenant,
| attrs: @attrs,
| created_rev: @created_rev,
| deleted_rev: null,
@@ -130,7 +129,6 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
"id" -> id.value.toString.asInstanceOf[AnyRef],
"kind" -> nodeKindToString(kind).asInstanceOf[AnyRef],
"name" -> name.asInstanceOf[AnyRef],
- "tenant" -> patch.tenant.value.toString.asInstanceOf[AnyRef],
"attrs" -> parseToJavaMap(attrsJson).asInstanceOf[AnyRef],
"created_rev" -> Long.box(newRev).asInstanceOf[AnyRef],
"provenance" -> parseToJavaMap(provenanceJson.noSpaces).asInstanceOf[AnyRef],
@@ -153,7 +151,6 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
| src: @src,
| dst: @dst,
| predicate: @predicate,
- | tenant: @tenant,
| attrs: @attrs,
| created_rev: @created_rev,
| deleted_rev: null,
@@ -181,7 +178,6 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
"src" -> src.value.toString.asInstanceOf[AnyRef],
"dst" -> dst.value.toString.asInstanceOf[AnyRef],
"predicate" -> predicate.value.asInstanceOf[AnyRef],
- "tenant" -> patch.tenant.value.toString.asInstanceOf[AnyRef],
"attrs" -> parseToJavaMap(attrsJson).asInstanceOf[AnyRef],
"created_rev" -> Long.box(newRev).asInstanceOf[AnyRef],
"provenance" -> parseToJavaMap(provenanceJson.noSpaces).asInstanceOf[AnyRef],
@@ -225,7 +221,6 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
| value: @value,
| confidence: @confidence,
| status: @status,
- | tenant: @tenant,
| created_rev: @created_rev,
| deleted_rev: null,
| provenance: @provenance
@@ -237,7 +232,6 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
"value" -> jsonToJava(value).asInstanceOf[AnyRef],
"confidence" -> confidence.map(Double.box).orNull.asInstanceOf[AnyRef],
"status" -> "active".asInstanceOf[AnyRef],
- "tenant" -> patch.tenant.value.toString.asInstanceOf[AnyRef],
"created_rev" -> Long.box(newRev).asInstanceOf[AnyRef],
"provenance" -> parseToJavaMap(provenanceJson.noSpaces).asInstanceOf[AnyRef]
),
@@ -263,14 +257,12 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
"""INSERT {
| _key: @key,
| patch_id: @patch_id,
- | tenant: @tenant,
| rev: @rev,
| data: @data
|} INTO patches""".stripMargin,
Map(
- "key" -> s"${patch.tenant.value}:${patch.patchId.value}".asInstanceOf[AnyRef],
+ "key" -> patch.patchId.value.toString.asInstanceOf[AnyRef],
"patch_id" -> patch.patchId.value.toString.asInstanceOf[AnyRef],
- "tenant" -> patch.tenant.value.toString.asInstanceOf[AnyRef],
"rev" -> Long.box(newRev).asInstanceOf[AnyRef],
"data" -> parseToJavaMap(patchJson).asInstanceOf[AnyRef]
),
@@ -278,7 +270,7 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
)
}
- private def storeIdempotencyKey(patchId: PatchId, tenant: TenantId, newRev: Long, txId: String): IO[Unit] =
+ private def storeIdempotencyKey(patchId: PatchId, newRev: Long, txId: String): IO[Unit] =
client.execute(
"""INSERT {
| key: @key,
@@ -286,20 +278,20 @@ class ArangoGraphWriteApi(client: ArangoClient) extends GraphWriteApi {
| created_at: DATE_NOW() / 1000
|} INTO idempotency_keys""".stripMargin,
Map(
- "key" -> idempotencyKey(patchId, tenant).asInstanceOf[AnyRef],
+ "key" -> idempotencyKey(patchId).asInstanceOf[AnyRef],
"rev" -> Long.box(newRev).asInstanceOf[AnyRef]
),
txId = Some(txId)
)
- private def updateTenantRevision(tenant: TenantId, newRev: Long, txId: String): IO[Unit] =
+ private def updateRevision(newRev: Long, txId: String): IO[Unit] =
client.execute(
"""UPSERT { _key: @key }
| INSERT { _key: @key, rev: @rev }
| UPDATE { rev: @rev }
| IN revisions""".stripMargin,
Map(
- "key" -> tenant.value.toString.asInstanceOf[AnyRef],
+ "key" -> "current".asInstanceOf[AnyRef],
"rev" -> Long.box(newRev).asInstanceOf[AnyRef]
),
txId = Some(txId)
diff --git a/memory-layer/src/main/scala/ix/memory/db/GraphQueryApi.scala b/memory-layer/src/main/scala/ix/memory/db/GraphQueryApi.scala
index ec1a1977..66e46dd9 100644
--- a/memory-layer/src/main/scala/ix/memory/db/GraphQueryApi.scala
+++ b/memory-layer/src/main/scala/ix/memory/db/GraphQueryApi.scala
@@ -5,15 +5,15 @@ import io.circe.Json
import ix.memory.model._
trait GraphQueryApi {
- def getNode(tenant: TenantId, id: NodeId, asOfRev: Option[Rev] = None): IO[Option[GraphNode]]
- def findNodesByKind(tenant: TenantId, kind: NodeKind, limit: Int = 100): IO[Vector[GraphNode]]
- def searchNodes(tenant: TenantId, text: String, limit: Int = 20): IO[Vector[GraphNode]]
- def expand(tenant: TenantId, nodeId: NodeId, direction: Direction,
+ def getNode(id: NodeId, asOfRev: Option[Rev] = None): IO[Option[GraphNode]]
+ def findNodesByKind(kind: NodeKind, limit: Int = 100): IO[Vector[GraphNode]]
+ def searchNodes(text: String, limit: Int = 20): IO[Vector[GraphNode]]
+ def expand(nodeId: NodeId, direction: Direction,
predicates: Option[Set[String]] = None, hops: Int = 1,
asOfRev: Option[Rev] = None): IO[ExpandResult]
- def getClaims(tenant: TenantId, entityId: NodeId): IO[Vector[Claim]]
- def getLatestRev(tenant: TenantId): IO[Rev]
- def getPatchesForEntity(tenant: TenantId, entityId: NodeId): IO[List[Json]]
+ def getClaims(entityId: NodeId): IO[Vector[Claim]]
+ def getLatestRev: IO[Rev]
+ def getPatchesForEntity(entityId: NodeId): IO[List[Json]]
}
sealed trait Direction
diff --git a/memory-layer/src/main/scala/ix/memory/ingestion/GraphPatchBuilder.scala b/memory-layer/src/main/scala/ix/memory/ingestion/GraphPatchBuilder.scala
index 1a19dedb..fb8b17e9 100644
--- a/memory-layer/src/main/scala/ix/memory/ingestion/GraphPatchBuilder.scala
+++ b/memory-layer/src/main/scala/ix/memory/ingestion/GraphPatchBuilder.scala
@@ -15,17 +15,16 @@ object GraphPatchBuilder {
* idempotent upserts.
*/
def build(
- tenant: TenantId,
filePath: String,
sourceHash: Option[String],
parseResult: ParseResult
): GraphPatch = {
def nodeIdFor(name: String): NodeId =
- NodeId(UUID.nameUUIDFromBytes(s"${tenant.value}:$filePath:$name".getBytes("UTF-8")))
+ NodeId(UUID.nameUUIDFromBytes(s"$filePath:$name".getBytes("UTF-8")))
def edgeIdFor(src: String, dst: String, predicate: String): EdgeId =
- EdgeId(UUID.nameUUIDFromBytes(s"${tenant.value}:$src:$dst:$predicate".getBytes("UTF-8")))
+ EdgeId(UUID.nameUUIDFromBytes(s"$src:$dst:$predicate".getBytes("UTF-8")))
val nodeOps = parseResult.entities.map { e =>
PatchOp.UpsertNode(nodeIdFor(e.name), e.kind, e.name, e.attrs)
@@ -43,7 +42,6 @@ object GraphPatchBuilder {
GraphPatch(
patchId = PatchId(UUID.randomUUID()),
- tenant = tenant,
actor = "ix/ingestion",
timestamp = Instant.now(),
source = PatchSource(filePath, sourceHash, "tree-sitter-python/1.0", SourceType.Code),
diff --git a/memory-layer/src/main/scala/ix/memory/ingestion/IngestionService.scala b/memory-layer/src/main/scala/ix/memory/ingestion/IngestionService.scala
index b40fe473..7f2e4cf3 100644
--- a/memory-layer/src/main/scala/ix/memory/ingestion/IngestionService.scala
+++ b/memory-layer/src/main/scala/ix/memory/ingestion/IngestionService.scala
@@ -5,7 +5,7 @@ import java.nio.file.{Files, Path}
import cats.effect.IO
import cats.syntax.all._
import ix.memory.db.{CommitResult, GraphWriteApi}
-import ix.memory.model.{Rev, TenantId}
+import ix.memory.model.Rev
/**
* Orchestrates file ingestion: reads source files, parses them,
@@ -16,7 +16,7 @@ class IngestionService(parserRouter: ParserRouter, writeApi: GraphWriteApi) {
/**
* Ingest a single file: read, parse, build patch, commit.
*/
- def ingestFile(tenant: TenantId, filePath: Path): IO[CommitResult] = {
+ def ingestFile(filePath: Path): IO[CommitResult] = {
for {
source <- IO.blocking {
val s = scala.io.Source.fromFile(filePath.toFile)
@@ -32,7 +32,7 @@ class IngestionService(parserRouter: ParserRouter, writeApi: GraphWriteApi) {
.map("%02x".format(_))
.mkString
)
- patch = GraphPatchBuilder.build(tenant, filePath.toString, hash, result)
+ patch = GraphPatchBuilder.build(filePath.toString, hash, result)
_ <- IO.fromEither(PatchValidator.validate(patch).left.map(msg => new IllegalStateException(msg)))
commit <- writeApi.commitPatch(patch)
} yield commit
@@ -41,21 +41,19 @@ class IngestionService(parserRouter: ParserRouter, writeApi: GraphWriteApi) {
/**
* Ingest all matching files under a path.
*
- * @param tenant the tenant to attribute the patches to
* @param path root directory or single file
* @param language optional language filter (e.g. "python")
* @param recursive whether to recurse into subdirectories
* @return aggregated ingestion result
*/
def ingestPath(
- tenant: TenantId,
path: Path,
language: Option[String],
recursive: Boolean
): IO[IngestionResult] = {
for {
files <- discoverFiles(path, language, recursive)
- results <- files.traverse(f => ingestFile(tenant, f).attempt)
+ results <- files.traverse(f => ingestFile(f).attempt)
successes = results.collect { case Right(cr) => cr }
latestRev = successes.lastOption.map(_.newRev).getOrElse(Rev(0L))
} yield IngestionResult(
diff --git a/memory-layer/src/main/scala/ix/memory/model/Edge.scala b/memory-layer/src/main/scala/ix/memory/model/Edge.scala
index e5583630..f7bf5cd3 100644
--- a/memory-layer/src/main/scala/ix/memory/model/Edge.scala
+++ b/memory-layer/src/main/scala/ix/memory/model/Edge.scala
@@ -14,7 +14,6 @@ final case class GraphEdge(
src: NodeId,
dst: NodeId,
predicate: EdgePredicate,
- tenant: TenantId,
attrs: Json,
provenance: Provenance,
createdRev: Rev,
diff --git a/memory-layer/src/main/scala/ix/memory/model/GraphPatch.scala b/memory-layer/src/main/scala/ix/memory/model/GraphPatch.scala
index 150b629b..05dceabc 100644
--- a/memory-layer/src/main/scala/ix/memory/model/GraphPatch.scala
+++ b/memory-layer/src/main/scala/ix/memory/model/GraphPatch.scala
@@ -73,7 +73,6 @@ object PatchSource {
final case class GraphPatch(
patchId: PatchId,
- tenant: TenantId,
actor: String,
timestamp: Instant,
source: PatchSource,
diff --git a/memory-layer/src/main/scala/ix/memory/model/Identifiers.scala b/memory-layer/src/main/scala/ix/memory/model/Identifiers.scala
index d4605de8..591d51c1 100644
--- a/memory-layer/src/main/scala/ix/memory/model/Identifiers.scala
+++ b/memory-layer/src/main/scala/ix/memory/model/Identifiers.scala
@@ -4,12 +4,6 @@ import java.util.UUID
import io.circe.{Decoder, Encoder}
-final case class TenantId(value: UUID) extends AnyVal
-object TenantId {
- implicit val encoder: Encoder[TenantId] = Encoder[UUID].contramap(_.value)
- implicit val decoder: Decoder[TenantId] = Decoder[UUID].map(TenantId(_))
-}
-
final case class NodeId(value: UUID) extends AnyVal
object NodeId {
implicit val encoder: Encoder[NodeId] = Encoder[UUID].contramap(_.value)
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 bf482568..b47f0b95 100644
--- a/memory-layer/src/main/scala/ix/memory/model/Node.scala
+++ b/memory-layer/src/main/scala/ix/memory/model/Node.scala
@@ -49,7 +49,6 @@ object NodeKind {
final case class GraphNode(
id: NodeId,
kind: NodeKind,
- tenant: TenantId,
attrs: Json,
provenance: Provenance,
createdRev: Rev,
diff --git a/memory-layer/src/test/scala/ix/memory/EndToEndSpec.scala b/memory-layer/src/test/scala/ix/memory/EndToEndSpec.scala
index 83c6fe73..c0a4e5d4 100644
--- a/memory-layer/src/test/scala/ix/memory/EndToEndSpec.scala
+++ b/memory-layer/src/test/scala/ix/memory/EndToEndSpec.scala
@@ -37,7 +37,6 @@ class EndToEndSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
}
private def makePatch(
- tenant: TenantId,
baseRev: Rev = Rev(0L),
ops: Vector[PatchOp] = Vector.empty,
patchId: PatchId = PatchId(UUID.randomUUID()),
@@ -45,7 +44,6 @@ class EndToEndSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
): GraphPatch =
GraphPatch(
patchId = patchId,
- tenant = tenant,
actor = "test-actor",
timestamp = Instant.parse("2025-06-01T12:00:00Z"),
source = source,
@@ -64,14 +62,13 @@ class EndToEndSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
val parserRouter = new ParserRouter()
val ingestion = new IngestionService(parserRouter, writeApi)
val contextService = buildContextService(queryApi)
- val tenant = TenantId(UUID.randomUUID())
for {
_ <- client.ensureSchema()
// Ingest the sample billing_service.py fixture
- commit <- ingestion.ingestFile(tenant, fixtureFilePath)
+ commit <- ingestion.ingestFile(fixtureFilePath)
// Query about billing retry
- result <- contextService.query(tenant, "How does billing retry?")
+ result <- contextService.query("How does billing retry?")
} yield {
// CommitResult should be Ok
commit.status shouldBe CommitStatus.Ok
@@ -110,23 +107,21 @@ class EndToEndSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
val parserRouter = new ParserRouter()
val ingestion = new IngestionService(parserRouter, writeApi)
val contextService = buildContextService(queryApi)
- val tenant = TenantId(UUID.randomUUID())
for {
_ <- client.ensureSchema()
// Step 1: Ingest billing_service.py (creates nodes for BillingService etc.)
- commit1 <- ingestion.ingestFile(tenant, fixtureFilePath)
+ commit1 <- ingestion.ingestFile(fixtureFilePath)
// Compute the deterministic node ID for BillingService
// (same algorithm as GraphPatchBuilder)
billingNodeId = NodeId(UUID.nameUUIDFromBytes(
- s"${tenant.value}:${fixtureFilePath.toString}:BillingService".getBytes("UTF-8")
+ s"${fixtureFilePath.toString}:BillingService".getBytes("UTF-8")
))
// Step 2: Assert a claim from code source (higher authority)
// The statement (field) says "uses exponential backoff for retries"
codePatch = makePatch(
- tenant = tenant,
baseRev = commit1.newRev,
source = PatchSource("code://billing_service.py", Some("abc"), "tree-sitter", SourceType.Code),
ops = Vector(
@@ -138,7 +133,6 @@ class EndToEndSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
// Step 3: Assert a contradictory claim from a README (lower authority)
// The statement (field) says "does not retry on failure" -- contradicts code
readmePatch = makePatch(
- tenant = tenant,
baseRev = commit2.newRev,
source = PatchSource("doc://README.md", Some("def"), "markdown-parser", SourceType.Doc),
ops = Vector(
@@ -148,7 +142,7 @@ class EndToEndSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
commit3 <- writeApi.commitPatch(readmePatch)
// Step 4: Query about the topic
- result <- contextService.query(tenant, "BillingService retry")
+ result <- contextService.query("BillingService retry")
} yield {
// Both commits should succeed
commit2.status shouldBe CommitStatus.Ok
@@ -188,19 +182,17 @@ class EndToEndSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
val contextService = buildContextService(queryApi)
- val tenant = TenantId(UUID.randomUUID())
// Use deterministic IDs for manual patches
- val coreNodeId = NodeId(UUID.nameUUIDFromBytes(s"${tenant.value}:tt:billing_core".getBytes("UTF-8")))
- val newNodeId = NodeId(UUID.nameUUIDFromBytes(s"${tenant.value}:tt:payment_processor".getBytes("UTF-8")))
- val edgeId = EdgeId(UUID.nameUUIDFromBytes(s"${tenant.value}:tt:billing_core:payment_processor:CALLS".getBytes("UTF-8")))
+ val coreNodeId = NodeId(UUID.nameUUIDFromBytes(s"tt:billing_core".getBytes("UTF-8")))
+ val newNodeId = NodeId(UUID.nameUUIDFromBytes(s"tt:payment_processor".getBytes("UTF-8")))
+ val edgeId = EdgeId(UUID.nameUUIDFromBytes(s"tt:billing_core:payment_processor:CALLS".getBytes("UTF-8")))
for {
_ <- client.ensureSchema()
// Step 1: Commit patch at rev N with billing_core node
patch1 = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(coreNodeId, NodeKind.Function, "billing_core", Map.empty[String, Json]),
PatchOp.AssertClaim(coreNodeId, "billing_core_info", Json.fromString("handles billing"), Some(0.9))
@@ -211,7 +203,6 @@ class EndToEndSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
// Step 2: Commit another patch at rev N+1 with a new node + edge
patch2 = makePatch(
- tenant = tenant,
baseRev = revN,
ops = Vector(
PatchOp.UpsertNode(newNodeId, NodeKind.Function, "payment_processor", Map.empty[String, Json]),
@@ -230,10 +221,10 @@ class EndToEndSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
// Step 4: Query at revN -- should only see billing_core node
// The node payment_processor was created at revN+1 so it should NOT appear
// in the expansion (expand filters by created_rev <= asOfRev)
- resultAtRevN <- contextService.query(tenant, "billing_core", asOfRev = Some(revN))
+ resultAtRevN <- contextService.query("billing_core", asOfRev = Some(revN))
// Step 5: Query at latest -- should see both nodes
- resultLatest <- contextService.query(tenant, "billing_core")
+ resultLatest <- contextService.query("billing_core")
} yield {
// At revN: only billing_core should be found, payment_processor should NOT
// appear in the expanded nodes
@@ -264,25 +255,24 @@ class EndToEndSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
val queryApi = new ArangoGraphQueryApi(client)
val parserRouter = new ParserRouter()
val ingestion = new IngestionService(parserRouter, writeApi)
- val tenant = TenantId(UUID.randomUUID())
for {
_ <- client.ensureSchema()
// Step 1: First ingestion
- commit1 <- ingestion.ingestFile(tenant, fixtureFilePath)
+ commit1 <- ingestion.ingestFile(fixtureFilePath)
// Count nodes after first ingestion
- nodesBefore <- queryApi.findNodesByKind(tenant, NodeKind.Class)
- funcsBefore <- queryApi.findNodesByKind(tenant, NodeKind.Function)
+ nodesBefore <- queryApi.findNodesByKind(NodeKind.Class)
+ funcsBefore <- queryApi.findNodesByKind(NodeKind.Function)
totalBefore = nodesBefore.size + funcsBefore.size
// Step 2: Re-ingest the same file with the same content
- commit2 <- ingestion.ingestFile(tenant, fixtureFilePath)
+ commit2 <- ingestion.ingestFile(fixtureFilePath)
// Count nodes after second ingestion
- nodesAfter <- queryApi.findNodesByKind(tenant, NodeKind.Class)
- funcsAfter <- queryApi.findNodesByKind(tenant, NodeKind.Function)
+ nodesAfter <- queryApi.findNodesByKind(NodeKind.Class)
+ funcsAfter <- queryApi.findNodesByKind(NodeKind.Function)
totalAfter = nodesAfter.size + funcsAfter.size
} yield {
// First ingestion should succeed
diff --git a/memory-layer/src/test/scala/ix/memory/api/RoutesSpec.scala b/memory-layer/src/test/scala/ix/memory/api/RoutesSpec.scala
index 7cd28809..2bbcde78 100644
--- a/memory-layer/src/test/scala/ix/memory/api/RoutesSpec.scala
+++ b/memory-layer/src/test/scala/ix/memory/api/RoutesSpec.scala
@@ -28,14 +28,12 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
)
private def makePatch(
- tenant: TenantId,
baseRev: Rev = Rev(0L),
ops: Vector[PatchOp] = Vector.empty,
patchId: PatchId = PatchId(UUID.randomUUID())
): GraphPatch =
GraphPatch(
patchId = patchId,
- tenant = tenant,
actor = "test-actor",
timestamp = Instant.parse("2025-06-01T12:00:00Z"),
source = PatchSource(
@@ -94,10 +92,8 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
val app = buildRoutes(client, writeApi, queryApi)
- val tenant = TenantId(UUID.randomUUID())
val nodeId = NodeId(UUID.randomUUID())
val patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(nodeId, NodeKind.Function, "test_func", Map("lang" -> Json.fromString("scala"))),
PatchOp.AssertClaim(nodeId, "returns", Json.fromString("Int"), Some(0.9))
@@ -107,7 +103,7 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
for {
_ <- client.ensureSchema()
_ <- writeApi.commitPatch(patch)
- req = Request[IO](Method.GET, Uri.unsafeFromString(s"/v1/entity/${nodeId.value}?tenant=${tenant.value}"))
+ req = Request[IO](Method.GET, Uri.unsafeFromString(s"/v1/entity/${nodeId.value}"))
resp <- app.run(req)
body <- resp.as[Json]
} yield {
@@ -121,26 +117,6 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
// ── Test 3: GET /v1/entity/:id returns 404 for missing entity ────────
it should "return 404 for missing entity" in {
- clientResource.use { client =>
- val writeApi = new ArangoGraphWriteApi(client)
- val queryApi = new ArangoGraphQueryApi(client)
- val app = buildRoutes(client, writeApi, queryApi)
- val tenant = TenantId(UUID.randomUUID())
- val fakeId = UUID.randomUUID()
-
- for {
- _ <- client.ensureSchema()
- req = Request[IO](Method.GET, Uri.unsafeFromString(s"/v1/entity/$fakeId?tenant=${tenant.value}"))
- resp <- app.run(req)
- } yield {
- resp.status shouldBe Status.NotFound
- }
- }
- }
-
- // ── Test 4: GET /v1/entity/:id returns 400 for missing tenant ────────
-
- it should "return 400 for missing tenant query param" in {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
@@ -152,23 +128,22 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
req = Request[IO](Method.GET, Uri.unsafeFromString(s"/v1/entity/$fakeId"))
resp <- app.run(req)
} yield {
- resp.status shouldBe Status.BadRequest
+ resp.status shouldBe Status.NotFound
}
}
}
- // ── Test 5: GET /v1/conflicts returns empty list ─────────────────────
+ // ── Test 4: GET /v1/conflicts returns empty list ─────────────────────
- it should "return empty conflicts list for new tenant" in {
+ it should "return empty conflicts list" in {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
val app = buildRoutes(client, writeApi, queryApi)
- val tenant = TenantId(UUID.randomUUID())
for {
_ <- client.ensureSchema()
- req = Request[IO](Method.GET, Uri.unsafeFromString(s"/v1/conflicts?tenant=${tenant.value}"))
+ req = Request[IO](Method.GET, Uri.unsafeFromString(s"/v1/conflicts"))
resp <- app.run(req)
body <- resp.as[Json]
} yield {
@@ -178,17 +153,15 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
}
}
- // ── Test 6: POST /v1/diff returns diff between revisions ─────────────
+ // ── Test 5: POST /v1/diff returns diff between revisions ─────────────
it should "diff between revisions and detect added entity" in {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
val app = buildRoutes(client, writeApi, queryApi)
- val tenant = TenantId(UUID.randomUUID())
val nodeId = NodeId(UUID.randomUUID())
val patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(nodeId, NodeKind.Function, "diff_func", Map.empty[String, Json])
)
@@ -198,7 +171,6 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
_ <- client.ensureSchema()
result <- writeApi.commitPatch(patch)
diffReq = Json.obj(
- "tenant" -> tenant.value.toString.asJson,
"fromRev" -> 0L.asJson,
"toRev" -> result.newRev.value.asJson,
"entityId" -> nodeId.value.toString.asJson
@@ -215,19 +187,17 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
}
}
- // ── Test 7: POST /v1/diff returns 400 for invalid rev order ──────────
+ // ── Test 6: POST /v1/diff returns 400 for invalid rev order ──────────
it should "return 400 for invalid rev order in diff" in {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
val app = buildRoutes(client, writeApi, queryApi)
- val tenant = TenantId(UUID.randomUUID())
for {
_ <- client.ensureSchema()
diffReq = Json.obj(
- "tenant" -> tenant.value.toString.asJson,
"fromRev" -> 5L.asJson,
"toRev" -> 2L.asJson
)
@@ -239,17 +209,15 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
}
}
- // ── Test 8: POST /v1/context returns structured context ──────────────
+ // ── Test 7: POST /v1/context returns structured context ──────────────
it should "return structured context for a query" in {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
val app = buildRoutes(client, writeApi, queryApi)
- val tenant = TenantId(UUID.randomUUID())
val nodeId = NodeId(UUID.randomUUID())
val patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(nodeId, NodeKind.Function, "billing_calc", Map.empty[String, Json]),
PatchOp.AssertClaim(nodeId, "calculates billing", Json.fromString("true"), Some(0.9))
@@ -260,8 +228,7 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
_ <- client.ensureSchema()
_ <- writeApi.commitPatch(patch)
ctxReq = Json.obj(
- "query" -> "billing".asJson,
- "tenant" -> tenant.value.toString.asJson
+ "query" -> "billing".asJson
)
req = Request[IO](Method.POST, uri"/v1/context").withEntity(ctxReq)
resp <- app.run(req)
@@ -273,14 +240,13 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
}
}
- // ── Test 9: POST /v1/ingest ingests a Python file ─────────────────────
+ // ── Test 8: POST /v1/ingest ingests a Python file ─────────────────────
it should "ingest a Python file and return counts" in {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
val app = buildRoutes(client, writeApi, queryApi)
- val tenant = TenantId(UUID.randomUUID())
for {
_ <- client.ensureSchema()
@@ -294,8 +260,7 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
f
}
ingestReq = Json.obj(
- "path" -> tmpFile.toAbsolutePath.toString.asJson,
- "tenant" -> tenant.value.toString.asJson
+ "path" -> tmpFile.toAbsolutePath.toString.asJson
)
req = Request[IO](Method.POST, uri"/v1/ingest").withEntity(ingestReq)
resp <- app.run(req)
@@ -310,20 +275,18 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
}
}
- // ── Test 10: POST /v1/ingest rejects path traversal ────────────────
+ // ── Test 9: POST /v1/ingest rejects path traversal ────────────────
it should "return 400 for path traversal attempt" in {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
val app = buildRoutes(client, writeApi, queryApi)
- val tenant = TenantId(UUID.randomUUID())
for {
_ <- client.ensureSchema()
ingestReq = Json.obj(
- "path" -> "/tmp/../etc/passwd".asJson,
- "tenant" -> tenant.value.toString.asJson
+ "path" -> "/tmp/../etc/passwd".asJson
)
req = Request[IO](Method.POST, uri"/v1/ingest").withEntity(ingestReq)
resp <- app.run(req)
@@ -333,19 +296,17 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
}
}
- // ── Test 11: POST /v1/diff returns 422 without entityId ─────────────
+ // ── Test 10: POST /v1/diff returns 422 without entityId ─────────────
it should "return 422 for diff without entityId" in {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
val app = buildRoutes(client, writeApi, queryApi)
- val tenant = TenantId(UUID.randomUUID())
for {
_ <- client.ensureSchema()
diffReq = Json.obj(
- "tenant" -> tenant.value.toString.asJson,
"fromRev" -> 0L.asJson,
"toRev" -> 1L.asJson
)
@@ -357,17 +318,15 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
}
}
- // ── Test 12: POST /v1/provenance/:id returns provenance chain ─────────
+ // ── Test 11: POST /v1/provenance/:id returns provenance chain ─────────
it should "return provenance chain for entity" in {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
val app = buildRoutes(client, writeApi, queryApi)
- val tenant = TenantId(UUID.randomUUID())
val nodeId = NodeId(UUID.randomUUID())
val patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(nodeId, NodeKind.Function, "prov_func", Map.empty[String, Json])
)
@@ -376,7 +335,7 @@ class RoutesSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
for {
_ <- client.ensureSchema()
_ <- writeApi.commitPatch(patch)
- req = Request[IO](Method.POST, Uri.unsafeFromString(s"/v1/provenance/${nodeId.value}?tenant=${tenant.value}"))
+ req = Request[IO](Method.POST, Uri.unsafeFromString(s"/v1/provenance/${nodeId.value}"))
resp <- app.run(req)
body <- resp.as[Json]
} yield {
diff --git a/memory-layer/src/test/scala/ix/memory/context/ContextServiceSpec.scala b/memory-layer/src/test/scala/ix/memory/context/ContextServiceSpec.scala
index d7f0637e..c9bcf2fc 100644
--- a/memory-layer/src/test/scala/ix/memory/context/ContextServiceSpec.scala
+++ b/memory-layer/src/test/scala/ix/memory/context/ContextServiceSpec.scala
@@ -20,14 +20,12 @@ class ContextServiceSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
)
private def makePatch(
- tenant: TenantId,
baseRev: Rev = Rev(0L),
ops: Vector[PatchOp] = Vector.empty,
patchId: PatchId = PatchId(UUID.randomUUID())
): GraphPatch =
GraphPatch(
patchId = patchId,
- tenant = tenant,
actor = "test-actor",
timestamp = Instant.parse("2025-06-01T12:00:00Z"),
source = PatchSource(
@@ -57,16 +55,14 @@ class ContextServiceSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
- val tenant = TenantId(UUID.randomUUID())
- val billingId = NodeId(UUID.nameUUIDFromBytes(s"${tenant.value}:test:billing_service".getBytes))
- val retryId = NodeId(UUID.nameUUIDFromBytes(s"${tenant.value}:test:retry_handler".getBytes))
+ val billingId = NodeId(UUID.nameUUIDFromBytes(s"test:billing_service".getBytes))
+ val retryId = NodeId(UUID.nameUUIDFromBytes(s"test:retry_handler".getBytes))
val edgeId = EdgeId(UUID.randomUUID())
val contextService = buildContextService(queryApi)
val patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(billingId, NodeKind.Function, "billing_service", Map.empty[String, Json]),
PatchOp.UpsertNode(retryId, NodeKind.Function, "retry_handler", Map.empty[String, Json]),
@@ -78,7 +74,7 @@ class ContextServiceSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
for {
_ <- client.ensureSchema()
_ <- writeApi.commitPatch(patch)
- result <- contextService.query(tenant, "How does billing retry?")
+ result <- contextService.query("How does billing retry?")
} yield {
result.nodes should not be empty
result.metadata.query shouldBe "How does billing retry?"
@@ -94,12 +90,11 @@ class ContextServiceSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
it should "return empty context for unknown query" in {
clientResource.use { client =>
val queryApi = new ArangoGraphQueryApi(client)
- val tenant = TenantId(UUID.randomUUID())
val contextService = buildContextService(queryApi)
for {
_ <- client.ensureSchema()
- result <- contextService.query(tenant, "something totally unknown xyz123")
+ result <- contextService.query("something totally unknown xyz123")
} yield {
result.nodes shouldBe empty
result.claims shouldBe empty
@@ -123,14 +118,12 @@ class ContextServiceSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
- val tenant = TenantId(UUID.randomUUID())
val nodeId = NodeId(UUID.randomUUID())
val contextService = buildContextService(queryApi)
val patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(nodeId, NodeKind.Function, "billing_func", Map.empty[String, Json]),
PatchOp.AssertClaim(nodeId, "returns_int", Json.fromString("true"), Some(0.9)),
@@ -141,7 +134,7 @@ class ContextServiceSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
for {
_ <- client.ensureSchema()
_ <- writeApi.commitPatch(patch)
- result <- contextService.query(tenant, "What does billing do?")
+ result <- contextService.query("What does billing do?")
} yield {
result.claims should not be empty
// All claims should have a score > 0
@@ -161,7 +154,6 @@ class ContextServiceSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
- val tenant = TenantId(UUID.randomUUID())
val billingId = NodeId(UUID.randomUUID())
val retryId = NodeId(UUID.randomUUID())
@@ -170,7 +162,6 @@ class ContextServiceSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
val contextService = buildContextService(queryApi)
val patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(billingId, NodeKind.Service, "billing_service", Map.empty[String, Json]),
PatchOp.UpsertNode(retryId, NodeKind.Function, "retry_logic", Map.empty[String, Json]),
@@ -181,7 +172,7 @@ class ContextServiceSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
for {
_ <- client.ensureSchema()
_ <- writeApi.commitPatch(patch)
- result <- contextService.query(tenant, "How does billing work?")
+ result <- contextService.query("How does billing work?")
} yield {
// Should find billing_service as seed, then expand to find retry_logic
result.nodes.length should be >= 1
@@ -196,13 +187,11 @@ class ContextServiceSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
clientResource.use { client =>
val writeApi = new ArangoGraphWriteApi(client)
val queryApi = new ArangoGraphQueryApi(client)
- val tenant = TenantId(UUID.randomUUID())
val nodeId = NodeId(UUID.randomUUID())
val contextService = buildContextService(queryApi)
val patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(nodeId, NodeKind.Function, "billing_calc", Map.empty[String, Json]),
PatchOp.AssertClaim(nodeId, "billing_info", Json.fromString("test"), Some(0.9))
@@ -212,7 +201,7 @@ class ContextServiceSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
for {
_ <- client.ensureSchema()
_ <- writeApi.commitPatch(patch)
- result <- contextService.query(tenant, "billing info")
+ result <- contextService.query("billing info")
} yield {
result.conflicts shouldBe empty
}
diff --git a/memory-layer/src/test/scala/ix/memory/db/GraphQueryApiSpec.scala b/memory-layer/src/test/scala/ix/memory/db/GraphQueryApiSpec.scala
index 77cd3456..f3dadba3 100644
--- a/memory-layer/src/test/scala/ix/memory/db/GraphQueryApiSpec.scala
+++ b/memory-layer/src/test/scala/ix/memory/db/GraphQueryApiSpec.scala
@@ -19,14 +19,12 @@ class GraphQueryApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
)
private def makePatch(
- tenant: TenantId,
baseRev: Rev = Rev(0L),
ops: Vector[PatchOp] = Vector.empty,
patchId: PatchId = PatchId(UUID.randomUUID())
): GraphPatch =
GraphPatch(
patchId = patchId,
- tenant = tenant,
actor = "test-actor",
timestamp = Instant.parse("2025-06-01T12:00:00Z"),
source = PatchSource(
@@ -49,10 +47,8 @@ class GraphQueryApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
_ <- client.ensureSchema()
writeApi = new ArangoGraphWriteApi(client)
queryApi = new ArangoGraphQueryApi(client)
- tenant = TenantId(UUID.randomUUID())
nodeId = NodeId(UUID.randomUUID())
patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(
id = nodeId,
@@ -63,13 +59,12 @@ class GraphQueryApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
)
)
_ <- writeApi.commitPatch(patch)
- result <- queryApi.getNode(tenant, nodeId)
+ result <- queryApi.getNode(nodeId)
} yield {
result shouldBe defined
val node = result.get
node.id shouldBe nodeId
node.kind shouldBe NodeKind.Function
- node.tenant shouldBe tenant
node.attrs.hcursor.get[String]("lang") shouldBe Right("scala")
node.provenance.extractor shouldBe "test-extractor"
node.provenance.sourceType shouldBe SourceType.Code
@@ -86,11 +81,9 @@ class GraphQueryApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
_ <- client.ensureSchema()
writeApi = new ArangoGraphWriteApi(client)
queryApi = new ArangoGraphQueryApi(client)
- tenant = TenantId(UUID.randomUUID())
nodeId = NodeId(UUID.randomUUID())
// Commit patch1: create the node
patch1 = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(
id = nodeId,
@@ -104,16 +97,15 @@ class GraphQueryApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
rev1 = res1.newRev
// Commit patch2: delete the node
patch2 = makePatch(
- tenant = tenant,
baseRev = rev1,
ops = Vector(PatchOp.DeleteNode(nodeId))
)
res2 <- writeApi.commitPatch(patch2)
rev2 = res2.newRev
// Query as of rev1 → should see the node
- atRev1 <- queryApi.getNode(tenant, nodeId, asOfRev = Some(rev1))
+ atRev1 <- queryApi.getNode(nodeId, asOfRev = Some(rev1))
// Query as of rev2 → should not see the node (deleted)
- atRev2 <- queryApi.getNode(tenant, nodeId, asOfRev = Some(rev2))
+ atRev2 <- queryApi.getNode(nodeId, asOfRev = Some(rev2))
} yield {
atRev1 shouldBe defined
atRev1.get.id shouldBe nodeId
@@ -130,12 +122,10 @@ class GraphQueryApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
_ <- client.ensureSchema()
writeApi = new ArangoGraphWriteApi(client)
queryApi = new ArangoGraphQueryApi(client)
- tenant = TenantId(UUID.randomUUID())
funcId1 = NodeId(UUID.randomUUID())
funcId2 = NodeId(UUID.randomUUID())
classId = NodeId(UUID.randomUUID())
patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(funcId1, NodeKind.Function, "func1", Map.empty[String, Json]),
PatchOp.UpsertNode(funcId2, NodeKind.Function, "func2", Map.empty[String, Json]),
@@ -143,8 +133,8 @@ class GraphQueryApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
)
)
_ <- writeApi.commitPatch(patch)
- funcs <- queryApi.findNodesByKind(tenant, NodeKind.Function)
- classes <- queryApi.findNodesByKind(tenant, NodeKind.Class)
+ funcs <- queryApi.findNodesByKind(NodeKind.Function)
+ classes <- queryApi.findNodesByKind(NodeKind.Class)
} yield {
funcs.length shouldBe 2
funcs.map(_.kind).toSet shouldBe Set(NodeKind.Function)
@@ -162,12 +152,10 @@ class GraphQueryApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
_ <- client.ensureSchema()
writeApi = new ArangoGraphWriteApi(client)
queryApi = new ArangoGraphQueryApi(client)
- tenant = TenantId(UUID.randomUUID())
nodeA = NodeId(UUID.randomUUID())
nodeB = NodeId(UUID.randomUUID())
edgeId = EdgeId(UUID.randomUUID())
patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(nodeA, NodeKind.Function, "funcA", Map.empty[String, Json]),
PatchOp.UpsertNode(nodeB, NodeKind.Function, "funcB", Map.empty[String, Json]),
@@ -175,9 +163,9 @@ class GraphQueryApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
)
)
_ <- writeApi.commitPatch(patch)
- outRes <- queryApi.expand(tenant, nodeA, Direction.Out)
- inRes <- queryApi.expand(tenant, nodeB, Direction.In)
- bothRes <- queryApi.expand(tenant, nodeA, Direction.Both)
+ outRes <- queryApi.expand(nodeA, Direction.Out)
+ inRes <- queryApi.expand(nodeB, Direction.In)
+ bothRes <- queryApi.expand(nodeA, Direction.Both)
} yield {
// Out from nodeA should find nodeB via "calls" edge
outRes.edges.length shouldBe 1
@@ -207,18 +195,16 @@ class GraphQueryApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
_ <- client.ensureSchema()
writeApi = new ArangoGraphWriteApi(client)
queryApi = new ArangoGraphQueryApi(client)
- tenant = TenantId(UUID.randomUUID())
node1 = NodeId(UUID.randomUUID())
node2 = NodeId(UUID.randomUUID())
patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(node1, NodeKind.Service, "billing_service", Map.empty[String, Json]),
PatchOp.UpsertNode(node2, NodeKind.Service, "payment_gateway", Map.empty[String, Json])
)
)
_ <- writeApi.commitPatch(patch)
- results <- queryApi.searchNodes(tenant, "billing")
+ results <- queryApi.searchNodes("billing")
} yield {
results.length shouldBe 1
results.head.id shouldBe node1
@@ -234,17 +220,15 @@ class GraphQueryApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
_ <- client.ensureSchema()
writeApi = new ArangoGraphWriteApi(client)
queryApi = new ArangoGraphQueryApi(client)
- tenant = TenantId(UUID.randomUUID())
nodeId = NodeId(UUID.randomUUID())
patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(nodeId, NodeKind.Function, "myFunc", Map.empty[String, Json]),
PatchOp.AssertClaim(nodeId, "returns", Json.fromString("Int"), Some(0.9))
)
)
_ <- writeApi.commitPatch(patch)
- claims <- queryApi.getClaims(tenant, nodeId)
+ claims <- queryApi.getClaims(nodeId)
} yield {
claims.length shouldBe 1
val claim = claims.head
@@ -264,18 +248,16 @@ class GraphQueryApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
_ <- client.ensureSchema()
writeApi = new ArangoGraphWriteApi(client)
queryApi = new ArangoGraphQueryApi(client)
- tenant = TenantId(UUID.randomUUID())
nodeId = NodeId(UUID.randomUUID())
// Before any commits, rev should be 0
- rev0 <- queryApi.getLatestRev(tenant)
+ rev0 <- queryApi.getLatestRev
patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(nodeId, NodeKind.Module, "mod1", Map.empty[String, Json])
)
)
res <- writeApi.commitPatch(patch)
- rev1 <- queryApi.getLatestRev(tenant)
+ rev1 <- queryApi.getLatestRev
} yield {
rev0 shouldBe Rev(0L)
rev1 shouldBe res.newRev
diff --git a/memory-layer/src/test/scala/ix/memory/db/GraphWriteApiSpec.scala b/memory-layer/src/test/scala/ix/memory/db/GraphWriteApiSpec.scala
index 766e01a1..4923e9c4 100644
--- a/memory-layer/src/test/scala/ix/memory/db/GraphWriteApiSpec.scala
+++ b/memory-layer/src/test/scala/ix/memory/db/GraphWriteApiSpec.scala
@@ -19,14 +19,12 @@ class GraphWriteApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
)
private def makePatch(
- tenant: TenantId,
baseRev: Rev = Rev(0L),
ops: Vector[PatchOp] = Vector.empty,
patchId: PatchId = PatchId(UUID.randomUUID())
): GraphPatch =
GraphPatch(
patchId = patchId,
- tenant = tenant,
actor = "test-actor",
timestamp = Instant.parse("2025-06-01T12:00:00Z"),
source = PatchSource(
@@ -48,10 +46,8 @@ class GraphWriteApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
for {
_ <- client.ensureSchema()
api = new ArangoGraphWriteApi(client)
- tenant = TenantId(UUID.randomUUID())
nodeId = NodeId(UUID.randomUUID())
patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(
id = nodeId,
@@ -76,11 +72,9 @@ class GraphWriteApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
for {
_ <- client.ensureSchema()
api = new ArangoGraphWriteApi(client)
- tenant = TenantId(UUID.randomUUID())
nodeId = NodeId(UUID.randomUUID())
patchId = PatchId(UUID.randomUUID())
patch = makePatch(
- tenant = tenant,
patchId = patchId,
ops = Vector(
PatchOp.UpsertNode(
@@ -108,11 +102,9 @@ class GraphWriteApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
for {
_ <- client.ensureSchema()
api = new ArangoGraphWriteApi(client)
- tenant = TenantId(UUID.randomUUID())
nodeId1 = NodeId(UUID.randomUUID())
// First patch to establish rev 1
patch1 = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(
id = nodeId1,
@@ -126,7 +118,6 @@ class GraphWriteApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
// Second patch with wrong baseRev
nodeId2 = NodeId(UUID.randomUUID())
patch2 = makePatch(
- tenant = tenant,
baseRev = Rev(999L),
ops = Vector(
PatchOp.UpsertNode(
@@ -151,10 +142,8 @@ class GraphWriteApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
for {
_ <- client.ensureSchema()
api = new ArangoGraphWriteApi(client)
- tenant = TenantId(UUID.randomUUID())
nodeId = NodeId(UUID.randomUUID())
patch = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(
id = nodeId,
@@ -174,7 +163,6 @@ class GraphWriteApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
val doc = result.get
doc.hcursor.get[String]("kind") shouldBe Right("file")
doc.hcursor.get[String]("name") shouldBe Right("Main.scala")
- doc.hcursor.get[String]("tenant") shouldBe Right(tenant.value.toString)
// attrs should contain the path attribute
doc.hcursor.downField("attrs").downField("path").as[String] shouldBe Right("/src/Main.scala")
// deleted_rev should be null (not soft-deleted)
@@ -190,11 +178,9 @@ class GraphWriteApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
for {
_ <- client.ensureSchema()
api = new ArangoGraphWriteApi(client)
- tenant = TenantId(UUID.randomUUID())
nodeId = NodeId(UUID.randomUUID())
// First patch: create the node
patch1 = makePatch(
- tenant = tenant,
ops = Vector(
PatchOp.UpsertNode(
id = nodeId,
@@ -207,7 +193,6 @@ class GraphWriteApiSpec extends AsyncFlatSpec with AsyncIOSpec with Matchers {
res1 <- api.commitPatch(patch1)
// Second patch: soft delete the node
patch2 = makePatch(
- tenant = tenant,
baseRev = res1.newRev,
ops = Vector(PatchOp.DeleteNode(nodeId))
)
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 122358a9..9cd0e7a5 100644
--- a/memory-layer/src/test/scala/ix/memory/model/ModelSpec.scala
+++ b/memory-layer/src/test/scala/ix/memory/model/ModelSpec.scala
@@ -38,11 +38,6 @@ class ModelSpec extends AnyFlatSpec with Matchers {
decode[ConflictId](id.asJson.noSpaces) shouldBe Right(id)
}
- it should "round-trip TenantId through JSON" in {
- val id = TenantId(UUID.randomUUID())
- decode[TenantId](id.asJson.noSpaces) shouldBe Right(id)
- }
-
it should "round-trip Rev through JSON" in {
val rev = Rev(42L)
decode[Rev](rev.asJson.noSpaces) shouldBe Right(rev)
@@ -127,7 +122,6 @@ class ModelSpec extends AnyFlatSpec with Matchers {
// ── GraphPatch serialization ────────────────────────────────────────
"GraphPatch" should "serialize with all fields" in {
- val tenantId = TenantId(UUID.randomUUID())
val patchId = PatchId(UUID.randomUUID())
val nodeId = NodeId(UUID.randomUUID())
val edgeId = EdgeId(UUID.randomUUID())
@@ -162,7 +156,6 @@ class ModelSpec extends AnyFlatSpec with Matchers {
val patch = GraphPatch(
patchId = patchId,
- tenant = tenantId,
actor = "extractor:tree-sitter",
timestamp = Instant.parse("2025-06-01T12:00:00Z"),
source = PatchSource(
@@ -184,7 +177,6 @@ class ModelSpec extends AnyFlatSpec with Matchers {
// Verify all top-level fields are present
val cursor = json.hcursor
cursor.downField("patchId").succeeded shouldBe true
- cursor.downField("tenant").succeeded shouldBe true
cursor.downField("actor").succeeded shouldBe true
cursor.downField("timestamp").succeeded shouldBe true
cursor.downField("source").succeeded shouldBe true