Skip to content

armgit / Ix

Public Imported from GitHub
0

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

feat(client): read the backend's head revision

KageBinary9c97b66cef33
diff --git a/docs/api/README.md b/docs/api/README.md
index 338f36a7..307a07be 100644
--- a/docs/api/README.md
+++ b/docs/api/README.md
@@ -521,6 +521,14 @@ List patches. **Query**: `limit`. **Response** — array of `PatchSummary`:
Fetch a single patch.
+#### GET `/v1/revisions/current`
+
+Head revision of the graph. Every committed patch, in any workspace, advances
+it. **Response**: the head's revision record (`{ "rev": 217, "patchId": "…",
+"timestamp": "…", … }`) when the backend holds one, otherwise the bare number
+(`217`). `ix map` compares it with the revision its cached map was computed at
+and skips `POST /v1/map` when nothing has been committed since.
+
#### POST `/v1/patch`
Commit one patch. Client timeout **5 minutes**.
diff --git a/docs/api/openapi.yaml b/docs/api/openapi.yaml
index 55f3476e..2808fcc8 100644
--- a/docs/api/openapi.yaml
+++ b/docs/api/openapi.yaml
@@ -581,6 +581,29 @@ paths:
"200":
description: Patch
+ /v1/revisions/current:
+ get:
+ tags: [patches]
+ summary: Head revision of the graph
+ description: >-
+ The revision record of the latest commit, or the bare revision number
+ when the backend holds no record for it. Every committed patch in any
+ workspace advances it.
+ operationId: currentRevision
+ responses:
+ "200":
+ description: Head revision
+ content:
+ application/json:
+ schema:
+ oneOf:
+ - type: integer
+ - type: object
+ properties:
+ rev: { type: integer }
+ patchId: { type: string }
+ timestamp: { type: string }
+
/v1/patch:
post:
tags: [patches]
diff --git a/ix-cli/src/client/api.ts b/ix-cli/src/client/api.ts
index cb32682f..11554823 100644
--- a/ix-cli/src/client/api.ts
+++ b/ix-cli/src/client/api.ts
@@ -235,6 +235,18 @@ export class IxClient {
return this.get(`/v1/patches/${id}`);
}
+ /**
+ * The backend's head revision: every committed patch, in any workspace,
+ * advances it. One indexed lookup on the backend, so it is cheap enough to
+ * ask on every `ix map`.
+ *
+ * The body is the head's revision record when the backend has one, and the
+ * bare revision number when it does not; both are returned as-is.
+ */
+ async currentRevision(): Promise<unknown> {
+ return this.get("/v1/revisions/current");
+ }
+
async diff(
fromRev: number,
toRev: number,