Repository navigation
UN-4044 [MISC] Rename the public API path to /api/v1/agentic-extract - #2515
Merged
Merged
Conversation
…2514) * UN-4044 [MISC] Rename the public API path to /api/v1/agentic-extract `POST /api/v1/agent-kv` serves more than the `kv` extractor now -- `table` routes through the same endpoint -- so the path named one of its extractors rather than what it does. Renames the mounted prefix to `agentic-extract` before the API goes live: 0.188 is still an RC, so nobody outside is on the old path yet. Scope is the public execution path only. The Django app, the `AGENT_KV_*` settings and env vars, the internal `/internal/v1/agent-kv/` API, the tenant-scoped `agent-kv/keys/` management routes and the `AgentKVKey` model keep their names. None of them is customer-facing, and renaming them would cost a migration and a frontend change for nothing visible from outside. Also repairs five intra-document anchors in `docs/agent-kv-api.md`. They have pointed at the pre-`/api/v1` heading names since the prefix moved under the platform API prefix, so they were already broken; every anchor in the file resolves now. Adds the guard that would have caught that drift, and this rename's: the documented `curl` URLs must sit under `settings.AGENT_KV_PATH_PREFIX`. Mutation-verified both ways -- one doc URL reverted to the old path fails it, and a regex that stops matching the placeholder host fails on the empty list rather than passing vacuously. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * UN-4044 [MISC] Round 1 review: fix the two guards I broke and say what the old path really does Self-review of this PR through the standardized 19-lens review: eight reviewers plus the vendored security deep-dive (clean at confidence >= 8, not degraded). Two High, six Medium, two Low. The review is posted on the PR; this is the fix. **The old path does not 404, and nothing in the tree said so correctly.** Five reviewers traced it independently: `/api/v1` is still routed to Django, so the request never reaches the SPA; the old prefix is no longer whitelisted, so `CustomAuthMiddleware` takes its Bearer branch and tries the `AgentKVKey` as a Platform key, and the caller gets `401 Invalid or inactive API key` plus a `Platform key rejected` log line -- the signal reserved for credential traversal. A stale caller is told their key is bad when their URL is stale. `docs/agent-kv-api.md` 11 now documents that symptom, the log line to grep, and that rollback is config-only. **Two guards were left asserting dead strings -- both mine, both in this PR.** * `test_queue_consumer_wiring.py` asserted `"/agent-kv" not in rule` while the comment above it had been updated to the new prefix. The term that can now reappear is `/agentic-extract`, so the regression the docstring names passed it. It reads `AGENT_KV_PATH_PREFIX` out of `docker/sample.env` now -- the file is already read by this suite -- and checks the prefix is under `api/v1/` plus that no dedicated term exists for either name. Mutants killed: prefix moved top-level, a `/agentic-extract` term added, a stale `/agent-kv` term left behind. * The new doc guard covered 6 of 31 documented occurrences. Reverting the five endpoint headings, the 1 table and the documented `status_url` while leaving the `curl`s current PASSED -- and `status_url` is the one value a client persists. It scans every `/api/v1/<segment>` in the file now. The 11 upgrade item names the old path on purpose, so that one block is carved out, and the carve-out is itself asserted: deleting the item fails the test rather than silently widening it. That assertion immediately caught a real gap -- the item never wrote the new path as a path. **An upgrade keeps the old path, and nothing pinned the samples.** Both `sample.env` files set the key as an active assignment, and `merge_env.py` preserves an existing `.env` value through `run-platform.sh --update` -- it even re-appends it under `# Additional envs` when the sample drops the line, which is why commenting the key out (two reviewers' suggestion) is a no-op for the case it was proposed for; measured, not assumed. So the samples say what a deployment actually serves, and `test_path_prefix_guard.py` now pins both to the shipped default. Reverting either one used to fail nothing. **Prose that was wrong or had become wrong:** * `settings/base.py` -- my own rewrite had turned a one-time ingress incident into a standing claim about on-prem values files that its own stated mechanism contradicts, and dropped the identifier that made it locatable. Restored and marked historical; the clause was about the top-level prefix and never needed touching. * `test_queue_consumer_wiring.py` -- "It used to sit at `/agent-kv`" now read as this PR's rename rather than the earlier change of depth. Says top-level. * `docs/agent-kv-architecture.md`, `AgentKvKeys.jsx`, `tests/e2e/.../conftest.py` and 12's env row stated the path without `/api/v1` or called it "top-level" -- wrong since the prefix moved under the platform API prefix. A reader calling `https://host/agentic-extract/` lands on the SPA. * The carve-out plan's decision 4 ("Keep the URL `/agent-kv/`") is the committed record that forbids this rename, and it is now marked superseded in place -- including that the risk it names was accepted by the owner rather than missed. * The new docstring cited `backend/base_urls.py`, which does not exist. Verified: 390 passed / 3 skipped in the `agent_kv` unit tier (was 389), 19 passed / 1 skipped in `test_queue_consumer_wiring.py`, all 10 intra-document anchors resolve, and `ruff check` / `ruff format --diff` at 0.15.13 give output identical to `origin/main` on all 15 changed Python files -- 7 errors and 2 would-be-reformatted files on each side, 6 format hunks on each. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * UN-4044 [DOCS] Say why there is no release_notes.json entry for the rename I had queued one as a follow-up, on the premise that it was the channel that reaches an upgrading operator. Checked the premise and it was wrong in two ways, so recording the conclusion where the next person will look instead of leaving the omission to be re-derived. `release_notes.json` is printed by `run-platform.sh --update`, which is the **OSS community compose** path, not an on-prem one -- and it is keyed by the community `vX.Y.Z` series (now at `v0.204.0`), which is a different numbering from the enterprise `ee-v*` line this rename is labelled for. An OSS-only build has no `backend/plugins/agent_kv/__init__.py` marker -- absent from the tree and not gitignored, so it arrives only via the cloud plugin-copy step -- so every submit 501s there whichever prefix is configured. An entry would warn the one audience that cannot reach this endpoint, in a file that currently holds exactly one entry for a real data migration. The deployments that CAN reach it are cloud and enterprise on-prem, and neither reads that file. Nor does any on-prem customer have the API today: `AGENT_KV`/`agentKv`/`agent-kv` appears nowhere in any customer deployment config, the newest enterprise on-prem bundle there is 0.139.2, and the one compose customer runs its own compose at 0.86.12 rather than `run-platform.sh`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * UN-4044 [MISC] Round 2 review: restore the depth check, and fix the operator notice I got wrong Round 2 of the self-review (six reviewers plus the vendored security deep-dive, clean at confidence >= 8 and not degraded) found 15 new items and left 4 prior ones open. All mine. The report is posted on the PR; this is the fix. **The round-1 fix had REMOVED a check.** Prior #4 said the doc guard covered 6 of 31 occurrences and suggested "stop keying on the host"; I read that as replace and it was meant as add. `/api/v1/[a-z0-9-]+` cannot match a path written WITHOUT the prefix, so `POST /agentic-extract/` sailed through where the old host-anchored assertion had failed it -- and that exact mistake was live in `docs/agent-kv-architecture.md` earlier in this branch. There are now three patterns, because none subsumes another: the NAME (slashed or bare -- the bare form is how §1's prose and §12's env row state the value an operator copies into `.env`, and both were unguarded), the DEPTH (host-anchored), and the intra-doc LINKS (slugified, so they contain no slashes; guarding the headings never guarded the links). Six mutants killed, including the two shapes the round-1 rewrite had lost. The carve-out for §11's upgrade item ended at the next section heading, which exempted the whole tail of §11 -- and §11 is a checklist whose natural append point is exactly there. It ends at the next item or section now; an appended item 13 carrying an old path fails. **The operator notice was wrong in three ways, and one of them reversed my conclusion.** `copy_cloud_deps.py` copies `backend/plugins/agent_kv` -- the capability marker -- INTO an OSS checkout, which is the tree holding `run-platform.sh`, both `sample.env` files and `release_notes.json`. So a marker-bearing compose stack reads that channel AND serves this API, and my "it would warn the one audience that cannot reach this endpoint" was false. The decision to add no entry here survives on a different ground -- the key is a release version this PR cannot know -- so the entry is **owed at cut**, and `docker/scripts/release-notes/README.md` now says when one is owed and why the two easy ways to miss it (the cloud-deps audience, and `.env` values surviving upgrades) are easy to miss. Item 12 also told the same operator both "needs one manual edit" and "needs no action" four lines apart; it has a table now, keyed on whether the deployment carries the marker. And its version enumeration was already wrong when written: `ee-v0.188.0-rc.1` was cut the day before and also serves the old path, so the list is gone rather than extended -- it would rot again at the next cut. **Two things I broke while fixing, caught by reading my own diff:** * A blanket `(?<!api/v1)/agentic-extract` pass over the tree rewrote `f"{PATH_PREFIX}/agentic-extract"` in the settings default, which would have made the prefix `api/v1/api/v1/agentic-extract`. It also "corrected" the deliberate counter-example in a comment. Both reverted; the other 20 sites are right, and the nine prose sites three reviewers flagged are among them. * Repadding the env-sample comment column left `...agentic-extract# Public URL` with no space before the `#`. A dotenv parser reads that comment INTO the value. `test_the_env_samples_ship_the_shipped_default` now splits on whitespace-then-`#` the way a parser does, so that exact break fails it -- verified by reproducing it. Also: the retired prefix is still accepted (the documented rollback needs it) but no longer silent -- `validate_agent_kv_path_prefix` warns, naming both values and the 401 symptom. It is the only notice that reaches compose, on-prem and cloud alike without depending on which doc an operator reads. Two tests, mutation-verified both ways, and the comment records that it fires before Django configures LOGGING so it lands on stderr via the last-resort handler. Smaller: the samples are pinned to a literal rather than to the overridable setting (an override used to blame whichever file was correct); the upgrade comment names the target value and `--only-env`; the rollback note says it is symmetric; `docker/sample.env` points at `backend/.env` instead of at itself, four lines under a header that already said so; the design spec's D4 -- the ORIGINATING statement of the decision whose restatement I superseded in round 1 -- is marked in both the banner and the table; `options[+calc]` is `[+calculations]` again, a field that actually exists. Verified: 392 passed / 3 skipped in the `agent_kv` unit tier (was 390; the two warning tests are new), 19 passed / 1 skipped in the workers wiring suite, and `ruff check` / `ruff format --diff` at 0.15.13 identical to `origin/main` on all 15 changed Python files -- 7 errors and 2 would-be-reformatted files on each side. One new format difference was introduced and fixed before commit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * UN-4044 [MISC] Re-apply the backend/sample.env half of the previous commit `backend/sample.env` is missing from `ccc473a35` because I reverted a mutation with `git checkout --` on a file that had UNCOMMITTED work on it, which threw the work away rather than the mutation. So that file kept round 1's wrong comment -- "must change this line itself", with no target value and no `--only-env` -- and the collapsed single-space comment column. Caught by reading the committed file list against what I had edited, not by the suite: `test_the_env_samples_ship_the_shipped_default` checks the parsed VALUE, and one space before `#` is still valid whitespace, so the value was correct and the test was right to pass. Padding is not a value property. Both sample files now carry their own correct wording and sit at the same comment column as every sibling `AGENT_KV_*` line, measured from a sibling rather than hardcoded. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * UN-4044 [MISC] Add the release note for the path rename, keyed v0.205.0 The upgrade channel for a self-hosted compose deployment is `release_notes.json`, printed by `run-platform.sh --update` (`:316`). The round-2 review established that its audience is NOT only OSS-only stacks -- a checkout with `copy_cloud_deps.py` applied carries `backend/plugins/agent_kv/`, the capability marker, and so both reads this file and serves this API. An earlier commit on this branch argued the opposite and was wrong. **The key is computed, not guessed.** The community `vX.Y.Z` series (which is what this file is keyed by -- a different numbering from the enterprise `ee-v*` line) is at `v0.204.0`, and *Create Release*'s `auto` rule bumps minor if any `[FEAT]`/`[GATED-FEAT]` PR merged since the last release. Reproducing that query read-only: 18 of the 45 PRs merged since `v0.204.0` are FEAT, so the next release is a minor -- `v0.205.0`. **The ACTION is "delete the line", which is safe on both sides of the boundary.** If this note fires on a build that does not yet have the rename, removing the `AGENT_KV_PATH_PREFIX` override just makes that deployment take its own code default -- the old path on an old build, the new one on a new build. "Set it to api/v1/agentic-extract" would have broken an early reader. The note also carries a no-auth `curl` whose status code tells the operator which prefix their build actually serves (403 live, 401 not), so they do not have to trust my version number. Boundaries verified against the real printer, ANSI stripped: `0.204.0 -> 0.205.0` and `0.204.0 -> 0.206.0` fire once, `0.205.0 -> 0.206.0` and `0.200.0 -> 0.204.0` fire not at all, `0.92.0 -> 0.205.0` fires twice (this and the v0.93.0 migration note), and `0.205.0 -> 0.205.0` is silent. That third case is the residual risk and is why the README now says to confirm the key at cut: if the rename slips past `v0.205.0`, anyone who stops on `v0.205.0` never sees the note afterwards. The README's new section explains both ways of mis-keying, why they are not symmetric, and gives the dry-run workflow and the local query for finding the next version. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * UN-4044 [DOCS] §11 item 12 said there is no release-note entry; there is one now Stale the moment `a5659eccf` added it. The blockquote now names the entry, its key, why that channel's audience is wider than OSS-only, and the one thing the person cutting the release has to check. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * UN-4044 [MISC] Address both greptile P2s on the release note Both valid, both on the commits I added an hour ago, and both verified against the code rather than taken on the bot's word. **The upgrade probe named the wrong host.** `docker-compose.yaml:74` routes `/api/v1` to the backend only for ``Host(`frontend.unstract.localhost`)``, so a `curl` to plain `localhost` gets a router 404 whichever prefix is live and NEITHER documented outcome applies -- the probe could not do the one job it was added for. It uses the compose host now, says to substitute your own, and names 404 as its own outcome so a wrong host is self-diagnosing rather than looking like the old path. **The README's version lookup could pick a hotfix.** It read the first match from `releases`, while *Create Release* uses `releases/latest` specifically because hotfix releases are created `--latest=false` (the workflow says so at `create-release.yaml:113-115`). On a hotfixed older line the two diverge, and since that tag's publish date is what the FEAT count is measured from, the documented command could produce the wrong key. It uses `releases/latest` now, with the reason inline. The `v0.205.0` key itself is unaffected: both lookups return `v0.204.0` today, which is what I computed from. Boundaries re-verified: `0.204.0 -> 0.205.0` fires once, `0.205.0 -> 0.206.0` is silent, `0.92.0 -> 0.205.0` fires twice. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> (cherry picked from commit 1c15ad5)
Contributor
|
PR author is in the excluded authors list. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Backport of #2514 (
1c15ad5ea592180209988bc33085e5421058b883) torelease/0.188. Clean pick; the bot squash-merges it in the same Backport run.