Skip to content

Stack 3/4: expose Ladybug graph search to Codex - #320

Open
vishaltandale00 wants to merge 12 commits into
codex/issue-52-query-executorfrom
codex/issue-52-prime-search
Open

Stack 3/4: expose Ladybug graph search to Codex#320
vishaltandale00 wants to merge 12 commits into
codex/issue-52-query-executorfrom
codex/issue-52-prime-search

Conversation

@vishaltandale00

@vishaltandale00 vishaltandale00 commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Final Apple-Silicon stack layer for #52 and #266, stacked on #319.

This replaces the obsolete Prime-oriented prototype with the existing packaged codex.basic harness path. It does not merge or release anything, and it does not claim Windows or Intel macOS graph-search support.

Product outcome

  • Teaches Codex to call graph.search() through the same bundled executable TypeScript client used for graph authoring.
  • Keeps search capability-scoped to the canonical current interaction and thread; the public request has no caller-selected target, project, thread, scope, permit, credential, or database field.
  • Preserves SQLite as canonical writes, Ladybug as the only search store, acknowledgement-level freshness, and no SQLite search fallback.
  • Packages and verifies RelayerGraphClient.prototype.search in the desktop graph client.
  • Bumps the checked-in codex-basic configuration revision so product threads receive the new guidance.

Deterministic product proof

Adds graph-memory.prior-accepted-reference and npm run eval:graph-memory.

The inference-free path starts the real Rust graph server, Ladybug index, Node harness host, and public TypeScript client. It proves:

  • turn 1 submits an accepted graph containing a run-unique anchor;
  • turn 2 uses a distinct capability in the same thread and persisted harness session;
  • a same-anchor draft exists during search but is excluded and stopped afterward;
  • only a search after the explicit second-turn boundary can satisfy the memory gate;
  • graph.search() returns exactly the prior accepted root layer;
  • the accepted turn-2 typed reference action targets that exact searched identity;
  • server response order is submit-1 acknowledgement < second-turn search < matching reference action < submit-2 acknowledgement;
  • both capabilities are revoked after their calls settle.

Exact retained local run: issue-52-final-deterministic-3. Result: PASS.

Live Codex product proof

Exact retained metered run at 5d29fe1aa2c8c2a1308b0ff975d74a2558acb4d4:

RELAYER_CODEX_BINARY=/opt/homebrew/bin/codex npm run eval:graph-memory:live -- --configuration codex-basic --output-dir .relayer/evals/graph-memory-live --test-run-id issue-52-live-codex-2

Result: PASS. One Codex harness object handled both interactions in the same persisted Codex session with distinct, later-revoked capabilities. Submit 1 acknowledged at audit sequence 23; the second-turn search at sequence 32 returned exactly layer 1; the typed reference at sequence 35 targeted layer 1; submit 2 acknowledged at sequence 37. Harness configuration digest: sha256:f906d7dd7dc3cd92402addca69ef3e796b38d13a2940d1ab314044ea2af8d434.

The first live attempt correctly exposed an evaluator weakness: an optional successful search from turn 1 could be selected as the alleged turn-2 evidence. The product behavior itself succeeded, but the run was retained as failed. The evaluator now records an explicit second-turn boundary and rejects all earlier searches; deterministic regression and the second live run pass that hardened boundary.

Paid inference remains opt-in and is not part of the default suite.

Exact local verification

At 5d29fe1aa2c8c2a1308b0ff975d74a2558acb4d4:

  • npm run check — PASS
    • 135 Vitest files / 1,560 tests
    • 21 Python tests
    • all Rust workspace, crash-reconciliation, query conformance, route, lifecycle, corpus, receipt, and PRD readability chapters passed
  • npm run build — PASS
  • npm run eval:graph-memory -- --output-dir .relayer/evals/graph-memory-final-3 --test-run-id issue-52-final-deterministic-3 — PASS
  • live Codex graph-memory command above — PASS
  • git diff --check — PASS

One earlier full-check attempt hit an ambient wall-time timeout in the unchanged Ladybug aggregate-allowlist chapter. Its exact focused rerun passed immediately, and the subsequent full npm run check passed on this head.

Adversarial assertion

Reviewer: final_graph_search_adversary.

The main implementation review covered exact workspace digest 4cb71d3594ee8b336576c27b25c431415e5699de, which became 02791a0b281f5a78636821b5e475420ff691c5a2 without source changes. A follow-up review covered exact diff digest 784d9f6354f81d1ca972baf55ff991d7de2182f6, which became 5d29fe1aa2c8c2a1308b0ff975d74a2558acb4d4 without further changes.

Scope: PRD/spec fidelity, authority scoping, public-client packaging, prompt/query correctness, accepted/draft isolation, same-session distinct-capability proof, exact search/reference identity and response ordering, no fallback, opt-in inference boundaries, and resistance to pre-turn search-evidence laundering.

Verdict: certifying PASS, no unresolved findings.

Stack and remaining gate

  1. Stack 1/4: make accepted closures atomically searchable #313 — searchable SQLite-to-Ladybug projection, recovery/rebuild, Apple-Silicon packaging and latency.
  2. Stack 2/4: execute bounded graph queries in Ladybug #319 — bounded authorized v1 Ladybug query executor.
  3. This PR — public clients plus packaged Codex search and two-turn reference proof.

Hosted check and the macOS ARM target package passed on exact head 5d29fe1a in run 33321019108. Windows is intentionally skipped and Intel macOS is out of this narrowed release slice. No merge is requested.

@vishaltandale00
vishaltandale00 force-pushed the codex/issue-52-prime-search branch from 750b5b4 to 02791a0 Compare August 30, 2026 15:18
@vishaltandale00 vishaltandale00 changed the title Stack 3/3: expose graph search to Prime Agent Stack 3/3: expose Ladybug graph search to Codex Aug 30, 2026
@vishaltandale00

Copy link
Copy Markdown
Owner Author

Apple-Silicon graph-search handoff

The authorized Apple-Silicon delivery slice for #52 is implemented as a three-PR stack:

  1. Stack 1/4: make accepted closures atomically searchable #313 — accepted SQLite closures project atomically into one shared Ladybug store, with per-target readiness, recovery/rebuild, and macOS ARM packaging.
  2. Stack 2/4: execute bounded graph queries in Ladybug #319 — authorized bounded read-only v1 query execution with typed rows/errors and no SQLite search fallback.
  3. Stack 3/4: expose Ladybug graph search to Codex #320 — equivalent public clients plus the existing packaged codex.basic harness using graph.search() across interactions.

Exact final head: 5d29fe1aa2c8c2a1308b0ff975d74a2558acb4d4 (tree ff58e149f132e4daf9dea4bccc01a5ab838fc5ab).

Evidence ledger

  • Local npm run check: PASS — 135 Vitest files / 1,560 tests, 21 Python tests, Rust/Ladybug/query/route/lifecycle/corpus/receipt/lint/readability chapters all passed.
  • Local npm run build: PASS.
  • Deterministic real-server/Ladybug/public-client proof issue-52-final-deterministic-3: PASS.
  • Live Codex proof issue-52-live-codex-2: PASS in one persisted Codex session over two interactions.
    • submit 1 acknowledgement: audit sequence 23
    • second-turn graph.search(): sequence 32, returned exactly prior accepted layer 1
    • typed reference creation: sequence 35, targeted layer 1
    • submit 2 acknowledgement: sequence 37
    • configuration digest: sha256:f906d7dd7dc3cd92402addca69ef3e796b38d13a2940d1ab314044ea2af8d434
  • Hosted exact-head check: PASS (run 33321019108).
  • Hosted exact-head actual macOS ARM target package: PASS (same run).
  • Windows qualification: intentionally skipped/blocked; Intel macOS is outside this narrowed slice.

Adversarial findings

The review first found that reference authorship could precede the alleged search and that no concurrent same-anchor draft challenged accepted-only isolation; both were fixed. The first live run then exposed that a successful turn-1 search could be selected as turn-2 evidence; the evaluator now records an explicit second-turn boundary and rejects all earlier searches. The hardened deterministic and live runs pass.

Final certifying review covered diff digest 784d9f6354f81d1ca972baf55ff991d7de2182f6, which became 5d29fe1a without further changes. Verdict: PASS, no unresolved findings.

Remaining

The PRs remain unmerged. Merge in stack order (#313, #319, #320), preserving exact heads or rerunning invalidated evidence after rebases. GitHub issues remain open until their corresponding stack layers land. Windows and Intel macOS support remain deferred rather than silently claimed.

@vishaltandale00
vishaltandale00 marked this pull request as ready for review August 30, 2026 16:22
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T03:01:22.586612Z 10e2fd5 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d29fe1aa2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (method === "POST" && path === "/api/graph/actions") return withRecord(event, "action", response?.action);
if (method === "POST" && path === "/api/graph/actions") return withAction(event, response?.action);
if (method === "POST" && /^\/api\/graph\/layers\/\d+\/discard$/.test(path)) return withRecord(event, "layer", response?.layer);
if (method === "POST" && path === "/api/graph/search" && status >= 200 && status < 300) return withSearchResult(event, response);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate the audited search request

When live Codex performs any successful one-result search—such as MATCH (l:Layer) RETURN l AS layer in this isolated run—and references the returned first layer, this audit records only the response layer IDs, so checkGraphMemorySecondTurn passes without proving that the required anchor query and tagged parameter were used. This can falsely certify the paid graph-memory evaluation despite the PRD requiring the exact bounded search and prohibiting a hard-coded or inferred target; sanitize and checkpoint the search request's version, query, and anchor parameter as well as its response.

AGENTS.md reference: AGENTS.md:L18-L20

Useful? React with 👍 / 👎.

# Conflicts:
#	packages/harness-host/test/configuration.test.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da610e3acf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


The current interaction may carry an invoke lease created by the product. Before authoring, use graph.getNode(${interactionNode.id}) and graph.getNeighbors(${interactionNode.id}) to inspect the current node and any relevant source context exposed by the graph. Treat that context as input to your answer; do not copy, forge, or manage lease metadata. Author the response normally. A successful ordinary graph.submit(${interactionNode.id}) automatically fulfills any lease held by this interaction. There is no separate resolveAction call.

Graph search is available through the same executable JavaScript client as await graph.search(request, options). It is not a provider-native tool or MCP function. The public search request is capability-scoped to the current interaction's thread and accepts exactly queryContractVersion, query, optional parameters, and optional budget. Never add target, thread, project, scope, permit, credential, database, candidate-source, or other authority fields. Search sees accepted published graph records only; it never exposes drafts and never falls back to SQLite when the Ladybug index is unavailable.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Advance the configuration revision with the search prompt

This rebased change materially alters the codex.basic prompt, but harnesses/codex-basic.yaml remains byte-identical to the parent at revision 4 because an intervening main commit had already consumed the revision that the original graph-search stack used. Consequently, executions with and without this search guidance can record the same configuration revision and harnessConfigurationDigest, undermining the PRD-required exact snapshot/digest identity used for Eval and promotion comparisons; advance the affected configuration to a new revision.

AGENTS.md reference: AGENTS.md:L18-L18

Useful? React with 👍 / 👎.

...base,
{
name: "search-returned-prior-root",
passed: successfulSearches.length === 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow repeated qualifying searches after repair

When a later action or submission fails validation, the harness guidance tells Codex to repair and rerun the same whole authoring program, which legitimately repeats the successful anchor search before creating the final matching reference. Requiring exactly one successful search therefore marks an otherwise correct and fully ordered live run as failed; the PRD requires the exact prior layer to be searched before the reference, not that the search occur only once, so reconcile repeated qualifying searches instead of failing solely on their count.

AGENTS.md reference: AGENTS.md:L18-L18

Useful? React with 👍 / 👎.


The current interaction may carry an invoke lease created by the product. Before authoring, use graph.getNode(${interactionNode.id}) and graph.getNeighbors(${interactionNode.id}) to inspect the current node and any relevant source context exposed by the graph. Treat that context as input to your answer; do not copy, forge, or manage lease metadata. Author the response normally. A successful ordinary graph.submit(${interactionNode.id}) automatically fulfills any lease held by this interaction. There is no separate resolveAction call.

Graph search is available through the same executable JavaScript client as await graph.search(request, options). It is not a provider-native tool or MCP function. The public search request is capability-scoped to the current interaction's thread and accepts exactly queryContractVersion, query, optional parameters, and optional budget. Never add target, thread, project, scope, permit, credential, database, candidate-source, or other authority fields. Search sees accepted published graph records only; it never exposes drafts and never falls back to SQLite when the Ladybug index is unavailable.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate graph search on the qualified target

This guidance is emitted for every codex.basic turn, including macOS x64 and Windows x64 development packages, even though the PRD explicitly keeps graph search unsupported on those targets until their qualification gates pass. Those platforms remain configured desktop targets, their package builds compile the graph server with Ladybug enabled by default, and the packaged-client verifier requires the search-enabled client without a platform condition, so they expose and encourage an unqualified search path rather than withholding it; gate the prompt and runtime/package surface on the qualified platform.

AGENTS.md reference: AGENTS.md:L18-L19

Useful? React with 👍 / 👎.

@vishaltandale00 vishaltandale00 changed the title Stack 3/3: expose Ladybug graph search to Codex Stack 3/4: expose Ladybug graph search to Codex Aug 31, 2026
@vishaltandale00

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 10e2fd5935

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant