Skip to content

fix: address remaining PR #104 review feedback#106

Closed
branarakic wants to merge 3 commits intov10-rcfrom
fix/pr104-followup-review
Closed

fix: address remaining PR #104 review feedback#106
branarakic wants to merge 3 commits intov10-rcfrom
fix/pr104-followup-review

Conversation

@branarakic
Copy link
Copy Markdown
Contributor

Summary

Follow-up to PR #104 (merged). Addresses the remaining Codex Review bot findings:

  • 🔴 Query error→400 mapping (daemon.ts:2119): The substring checks for catching query-layer errors and returning 400 didn't match the actual error messages (agentAddress is required..., requires a contextGraphId...). Fixed to use the correct substrings, preventing invalid view-based requests from falling through as 500s.
  • 🟡 Missing Vary header (daemon.ts:1246): The skill endpoint response body varies by Host/X-Forwarded-* headers but lacked a Vary header, so shared proxies could serve cached responses with the wrong Base URL. Added Vary: Host, X-Forwarded-Host, X-Forwarded-Proto.
  • 🟡 text/markdown falsely advertised (daemon.ts:1230): The extraction pipelines list hardcoded text/markdown even though no such pipeline is registered. Now reports only what's actually in the ExtractionPipelineRegistry.
  • 🟡 subGraphName + view incompatibility (SKILL.md:114): Documented the restriction that subGraphName is legacy-routing-only and cannot be combined with view.
  • 🟡 Non-existent referenced files (SKILL.md:187): Replaced dead references to workflows.md, api-reference.md, and examples/sparql-recipes.md with an inline Common Workflows section.

Test plan

  • All skill-endpoint, extraction-markitdown, document-processor-e2e, and extraction-pipeline tests pass (70 pass, 8 skipped)
  • Query test suite passes (174 tests)
  • tsc --noEmit clean for packages/cli

Made with Cursor

- Fix query error→400 mapping: substring checks now match the actual
  error messages from the query engine ('agentAddress is required',
  'requires a contextGraphId') so invalid view-based requests return
  400 instead of falling through as 500s
- Add Vary header (Host, X-Forwarded-Host, X-Forwarded-Proto) to the
  skill endpoint so proxies don't serve cached responses with wrong
  Base URL to different callers
- Remove hardcoded 'text/markdown' from extraction pipelines list;
  only report what's actually registered in the ExtractionPipelineRegistry
- Document subGraphName restriction in SKILL.md query section (cannot
  be combined with view-based routing)
- Replace references to non-existent workflow/api-reference files with
  inline Common Workflows section showing actual usage patterns

Made-with: Cursor
Comment thread packages/cli/skills/dkg-node/SKILL.md Outdated
- `examples/sparql-recipes.md` — SPARQL query patterns
1. Create a context graph (`POST /api/context-graph/create`)
2. Write triples to shared memory (`POST /api/shared-memory/write`)
3. Publish to verified memory (`POST /api/publish`)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Bug: This workflow switches from staged shared-memory writes to the direct publish endpoint. After POST /api/shared-memory/write, the matching promotion step is POST /api/shared-memory/publish; POST /api/publish expects a fresh quad payload and does not publish the SWM data from step 2.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 2f09d31 — step 3 now uses POST /api/shared-memory/publish to promote the SWM data written in step 2, instead of POST /api/publish which expects its own payload.

Comment thread packages/cli/skills/dkg-node/SKILL.md Outdated

**Query across layers:**

- Shared memory: `{"sparql": "...", "contextGraphId": "...", "includeSharedMemory": true}`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Bug: These query examples do not actually select the layer they claim. includeSharedMemory: true queries the base graph plus SWM, the verified-memory example needs "view": "verified-memory", and the working-memory example below will 400 without contextGraphId/paranetId. Please update the examples to use the view parameter for layer routing and include a graph id for WM.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 2f09d31 — all query examples now use the view parameter: view: "shared-memory", view: "verified-memory", view: "working-memory". Working memory example now includes contextGraphId.

/must start with (SELECT|CONSTRUCT|ASK|DESCRIBE)/i.test(msg) ||
msg.includes('was removed in V10') ||
msg.includes('requires agentAddress') || msg.includes('requires contextGraphId') ||
msg.includes('agentAddress is required') || msg.includes('requires a contextGraphId') ||
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Issue: The 400/500 split here still depends on exact exception text, and this change makes that coupling tighter. A small wording change in @origintrail-official/dkg-query will turn these client errors back into 500s, so add a request-level regression test for missing agentAddress and missing contextGraphId view queries or switch to typed errors/status codes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Acknowledged — this is a known coupling risk. A typed error hierarchy (e.g. QueryValidationError with a statusCode property) in dkg-query would be the clean fix. Tracking for a follow-up.

- Quick Start step 3 now uses POST /api/shared-memory/publish (promotes
  SWM data written in step 2) instead of POST /api/publish (which
  expects its own quad payload)
- Query examples now use the view parameter for layer routing:
  view: "shared-memory", view: "verified-memory", view: "working-memory"
- Working memory query example includes required contextGraphId

Made-with: Cursor
Comment thread packages/cli/skills/dkg-node/SKILL.md Outdated
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"sparql": "SELECT * WHERE { ?s ?p ?o } LIMIT 10", "contextGraphId": "my-context-graph", "includeSharedMemory": true}'
-d '{"sparql": "SELECT * WHERE { ?s ?p ?o } LIMIT 10", "contextGraphId": "my-context-graph", "view": "shared-memory"}'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Bug: shared-memory is not a supported view value. The query handler only accepts working-memory, shared-working-memory, and verified-memory, so copying this example will return 400 Invalid view. Please update this example, and the repeated shared-memory snippet below, to use the real enum (shared-working-memory, or verified-memory here if the intent is to show the post-publish result).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ef5c1a5 — corrected shared-memory to shared-working-memory in both the Quick Start and Common Workflows query examples. These now match the GET_VIEWS enum in core.

shared-memory → shared-working-memory (matches GET_VIEWS in core)

Made-with: Cursor
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"sparql": "SELECT * WHERE { ?s ?p ?o } LIMIT 10", "contextGraphId": "my-context-graph", "includeSharedMemory": true}'
-d '{"sparql": "SELECT * WHERE { ?s ?p ?o } LIMIT 10", "contextGraphId": "my-context-graph", "view": "shared-working-memory"}'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Bug: Step 3 publishes from shared memory with clearAfter defaulting to true, so querying view: "shared-working-memory" in the next step will usually come back empty. If this quick start is meant to confirm the publish, query the context graph without the SWM view instead, or add "clearAfter": false to the publish example.

/must start with (SELECT|CONSTRUCT|ASK|DESCRIBE)/i.test(msg) ||
msg.includes('was removed in V10') ||
msg.includes('requires agentAddress') || msg.includes('requires contextGraphId') ||
msg.includes('agentAddress is required') || msg.includes('requires a contextGraphId') ||
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Bug: agent.query() still throws Invalid sub-graph name for query: ... for bad subGraphName values, but this 400 allowlist does not catch that case, so malformed client input still falls through as a 500. Since this PR now documents subGraphName, add that validation error here or reject it before calling agent.query.

@branarakic branarakic closed this Apr 10, 2026
branarakic added a commit that referenced this pull request Apr 10, 2026
fix: consolidated V10 API hardening + finality principle (supersedes #105, #106, #107)
branarakic added a commit that referenced this pull request Apr 10, 2026
fix: consolidated V10 API hardening + finality principle (supersedes #105, #106, #107)
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