Repository navigation
feat(api): /api/v1 projects, states, labels and work items, with the oracle gate on those operations - #99
Merged
Conversation
Byte-for-byte copy of oracle/ at 72b2e01497 on the fork branch feat/plane-b6a-upstream-sync-oracle (tree dda199cc2a, 50 files), extracted with git archive. SOURCE names the commit and tree. The branch exists only in the fork clone and cannot be pushed to its main (Copy Right Check), so Q-0122.4 resolves to vendoring. Edits to the vendored files follow as separate commits and are listed in tools/oracle-v1/README.md. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… oracle EX-001 and EX-002 change from fix to reproduce (Q-0033.2: reproduce every Plane quirk, including the 500s, as a handled error). EX-011 no longer claims the search results omit id. EX-003, EX-004 and EX-010 gain the fixture and component-collision notes from research/0005. Only reason and rust_expectation change. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… as vendored The register row states the one exception to the stdlib-only Python rule (pyyaml, Schemathesis, an oasdiff image). Q-0122.4 is amended in place with the date and the reason, leaving the round-27 answer as written. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…gration 0015 Reads the pinned schema, the 105 in-scope corpus exchanges and the pinned Plane source against migrations 0001 to 0013. Finds that a new state gets max(non-triage sequence) + 15000 regardless of the client value, that triage states are hidden from the v1 list, and that Issue.objects excludes archived and draft items from the state-delete check. Leaves created_by nullability (O-1) open with a recommendation. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…permission, throttle, rate headers New crate thrust-api-v1 (ARCHITECTURE 2a), runtime-free like thrust-api, in CLEAN_CRATES, under the workspace panic lints. It owns every Plane-shaped thing of /api/v1 (#52); no route is mounted yet. - Ctx: authenticates by X-Api-Key only (a bearer token or a cookie is not a credential here), then permission, then the throttle, in DRF order. A missing or empty key is 401; an unknown, expired, revoked or switched-off one is 403; a refused request is not counted. - X-RateLimit-Remaining and -Reset ride every answer that was counted, errors included, through a request slot a layer reads. Reset is a Unix time one whole window ahead, as the pin computes it (rate_limit.py), so the RateLimiter port needs no change. A 429 has Retry-After and neither. - V1Error: Plane two body shapes, the 5900 429 body, and plane_500() for the 500s the owner decided to reproduce (cause logged, never sent). - V1Path: a path that does not match, or an id that is not a canonical lower-case uuid, is the URLconf 404 before any credential is read. - assemble() seals a set of routes with the /api/v1 URLconf 404 and the rate layer; router() is that over the crate own routes. 25 tests, including the exhaustive caller x route x project x slug matrix and a property over limit and call count. cargo mutants: 34, 14 caught, 20 unviable, 0 missed (the first run missed router(), which no test mounted; it has a test now). Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…er sees by Plane v1 rule (migration 0015) Soft deletion: projects.deleted_at, set by the new Database::delete_project. Every read of projects leaves a deleted one out (ten queries in Postgres; the memory adapter moves the row out of the two maps every read goes through), so its work items, states and history are kept and nothing under it can be reached. Its name and key are free again: the two unique indexes now hold among the live projects. The indexes keep their names (the conflict handling reports them) and are replaced with a catalog check instead of a drop on every start. 0012 no longer makes them: migrate runs every file on every start, so 0012 would have made the plain unique index again after 0015 dropped it, which fails once a deleted project name is used again (the trap 0012 own header warns of). The new test proves the index is the same object after a restart. Database::visible_projects is v1 own rule, which does not look at the role in the workspace: the projects the caller is in and the public ones. The internal API workspace_projects says the opposite for a guest and for an admin, and stays as it is. pg_adapter: the column inventory test gains deleted_at on projects. It is a schema inventory that exists to force exactly this edit, so the assertion is extended and not weakened. Controls: with the deleted filter taken off project_detail, the new delete test fails at that assertion; with the DROP INDEX skipped, the migration test fails at "was not replaced"; with visible_projects limited to members, the visibility test fails with an empty list. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… archive, delete, visible_project Plane v1 ProjectBasePermission for a write on one project: a project admin, or a member of the project who administers the workspace; everyone else is Forbidden, a project that is not there included (the pin looks for the caller membership and finds none). The internal API updatable_project lets a workspace admin who is not in the project change it, and v1 does not: the test sets the two side by side. change_project, set_project_archived and delete_project are built on it; update_project is split into its permission and a shared save_patch, so the internal API behaves as before. ProjectPatch gains default_state, checked against the project own states (the triage one is not one: State.objects leaves it out); ProjectError gains NotAState, which compat maps to a 400 that no internal route reaches. visible_project is v1 detail visibility: the caller is a member or the project is public, an archived one is found, anything else is not found. Mutation testing of the changed lines: 22 mutants, 16 caught, 6 unviable, 0 missed (the first run missed two in visible_project, which only the v1 HTTP tests pinned; core now has its own matrix, as AGENTS.md rule 5 asks). Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…eve, change, delete, archive, unarchive The eight project operations of Plane v1, mounted in both composition roots (thrust-server and thrust-worker). Each is a thin reading of the request into a core use-case and of its result into the pin wire shape: the 43-key body (44 in a list, with the caller own sort_order), the 9-key lite body, DRF field messages, and the pin odd 409s. - visibility: the caller projects and the public ones, whatever the workspace role; one that is not visible is a 404 (error body), a project that is not there is a 403 to a writer; an archived one is read as any other. Reads are for any workspace member, a creation for a member or admin, and a change, deletion or archiving for a project admin or a project member who administers the workspace. - lists: cursor pagination as the pin paginator.py has it (default and most 1000; per_page 0 or less is a handled 500, a negative page a 400; 12-key envelope), order_by over the five allowed keys with the default for anything else, fields projection, include_archived. - bodies: JSON only (a wrong content type is a 415, as the corpus records); every field the serializer knows is checked and what is wrong is one 400, then validate() raises at its first refusal; a field it does not know, such as network, is ignored, as on the pin. - the pin odd 409: a taken key is answered as a taken name, and a change reads the body before it refuses an archived project. - THRUST_V1_RATE_LIMIT sets a key allowance in Plane own spelling (100000/minute); both roots read it the same way, the Worker logging and ignoring one that does not read. Tests: 180 in the crate (the exhaustive caller x route x project x slug matrix; every spelling DRF reads as a boolean; the paginator as a property: following the cursors visits every row once, and no input at all makes the reading panic), plus the contract suite on native-memory and native-pg (55 of 55 each) and the full hermetic suite (2803). cargo mutants on the crate: 214 mutants, 164 caught, 50 unviable, 0 missed (the first run missed 27, all in the DRF primitives and two unpinned details: the timestamp form and ordering by updated_at; the dead choice_field and py_str are removed, to come back with the states that use them). V1Config::parse: 23, 14 caught, 0 missed. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Cycles and modules counted as 0, a taken key answered as a taken name, a default state of another project, the JSON parser words, form and multipart bodies, expand, soft deletion of the children, and the order of ties. Each names the pin code behind it and the test that pins Thrust behaviour. Proposed and pending owner confirmation, as D-028 and D-029 were. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…015) Five new Database methods: insert_state, update_state, delete_state, state_has_work_items, project_is_archived. StateRow gains external_source, external_id and updated_by; states gains deleted_at. - insert_state gives a state Plane place (State.save): after the greatest live state that is not the intake one, by 15000, whatever place the row asked for (the first such state keeps its own). The intake state at 65000 does not count: a project of Plane own five states makes the next one 90000, not 105000. - a state that becomes the default takes the default from the others in the same transaction (Postgres has an index that allows one, and checks it per row), and a change that finds no state, or is refused, gives it back. - delete_state marks the row and the three lists leave it out; a work item that names it still reads its group (the memory adapter keeps the row in its list for that, and filters the reads). A name is unique among the live states: 0012 table constraint is replaced by an index of the same name, and a start does it once (a catalog no-op after the first, which a test proves). - state_has_work_items is the pin Issue.objects: not a draft, not archived, not deleted, and nothing in an archived project. Tests: 7 in the memory adapter and 4 in Postgres. The Postgres column inventory test gains the four states columns (a schema inventory that exists to force that edit). Controls: with the triage exclusion removed from the place, the draft exclusion from the count, and the constraint drop from the migration, four tests fail (the fourth because a fresh database then keeps the plain constraint, so a deleted state name is not free). Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ate by Plane's rules A state's writes are for a project admin (new Permission::WriteState). A create places the state after the greatest sequence among the non-triage live states (+15000), refuses the triage group, and answers a taken name with the state that has it, or with an internal error when the state is the hidden intake one, as the pin does by accident. A change finds its state before anything else; delete refuses the default state and a state with live work items. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…delete The 18-key state body, DRF's field validation (choice, float, bool, char), a create that answers 200 and ignores the client's sequence, the three answers to a taken name (409 with the id on create, 400 on change, the pin's 500 for a hidden intake state), the integration-key 409, and a change that finds its state before it reads the body. Reads are for a member of the project, writes for a project admin only; the intake state is never shown. D-031 records the three departures (is_triage follows the group, non-ASCII slugs, non-finite sequences) and research/0013 is corrected: state writes are project-admin only. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…tate; a padded taken name is the pin's 500 BaseAPIView.initial reads request.data before the handler runs, so a body with no parser (415), JSON that does not parse, or a scalar is refused before the 404; only a list or a wrong field comes after the lookup. The first stage had the whole body after the lookup, and its test pinned that. A create looks the clash up by the name as sent, which DRF had trimmed: a taken name with spaces round it finds no row to name, and the pin's view raises (500). Both fixes have a test that fails with the old behaviour put back. Also adds pk_field (DRF's PrimaryKeyRelatedField for a UUID key), which the labels parent uses. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…015) Three new Database methods: insert_label, update_label, delete_label. LabelRow gains external_source, external_id and updated_by; labels gains deleted_at. - insert_label gives a label Plane's place (Label.save): after the greatest live label of the project, by 10000, whatever place the row asked for (the first keeps its own). - delete_label marks the label and, in one statement, every live label under it (a recursive walk that a self-parent or a loop cannot feed) and deletes the work items' join rows to all of them, so no read of a work item needs to know about deletion. The pin does the same in a background task. - a name is unique among the live labels: 0012's table constraint is replaced by an index of the same name, once (a catalog no-op after the first start, which a test proves). Tests: five in the memory adapter, among them a generated forest (prop_) checked against a model of the closure, and three in Postgres. Two schema-inventory assertions change on purpose (the labels column list). Controls: with the walk, the unassign step, the live-only place and the constraint drop each broken in turn, the delete test fails for either of the first two on its own, the place test for the third, and the migration test with the delete and place tests for the fourth. cargo-mutants on the memory adapter's label methods: 46 caught, 3 unviable, none missed. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…bel by Plane's rules A label's writes are for a project admin or member (new Permission::WriteLabel); a read is for any member. A read, a change and a deletion share one lookup that leaves out an archived project (a state's change and deletion do not). A create places the label after the greatest by 10000 and refuses a key that another label has only when both halves are named; a change finds its label first, checks the key (leaving the label itself out, and naming the label it changes), and answers a taken name. A parent is a live label of the same project (D-032). Tests: reads, place (with a generated model of creates, deletes and moves), names, keys (a matrix over the halves), parents, change semantics and the deletion's cascade. cargo-mutants on labels.rs: 28 caught, 6 unviable, none missed; the first run missed one (the label named in a taken-name answer on a change), which is now a test. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…delete The 15-key label body, DRF's field validation in the order of the serializer's fields, a create that answers 201 and ignores the client's place, the three answers to a taken name (409 with the id on create, the pin's 500 for a name sent with spaces, 400 on change), the integration-key 409, and a parent that Django cannot read as a UUID answered by the base view's bare 400 with the other fields unreported. Reads are for a member of the project and writes for a project admin or member; the detail read ignores fields and expand, as the pin's does. D-032 records the five departures (a parent is a project's own live label; expand is ignored on labels and states; a taken key is found by the trimmed text; the deletion cascade is synchronous; ties in the list). research/0013 resolves the open question about ProjectMemberPermission from the source: a member may write a label. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
aRustyDev
marked this pull request as ready for review
November 9, 2026 19:51
aRustyDev
added a commit
that referenced
this pull request
Nov 9, 2026
* feat(core): the work items of the v1 API below the routes: a maker that may be missing, a parent, a point, a key, a search, a delete Schema (migration 0015): work_items.created_by is nullable (WorkItem.created_by is an Option), and the table gains parent_id (a foreign key to itself, which the use-case keeps within a project) and point (a check, 0 to 12). Ports and adapters: work_item_by_sequence, work_item_by_external, search_workspace_work_items (the caller's own projects that are not archived; name, project identifier or number; literal % and _), and a soft delete that takes the live work items under the item in one walk that a self-parent or a loop cannot feed. The whole-row update carries the integration key, the parent and the point. Core: the access proof carries the surface (Compat or V1). A v1 caller sees every work item, a guest too, and writes as a project admin or member only; the compat plane keeps D-028 (a parent is refused) and its guest rules. New: v1_issue_reader and v1_issue_writer, issue_by_sequence, issue_by_external, issue_to_change, search_issues, and delete_issue (a project admin or the maker, else OnlyAdminOrCreator). Ask gains Point, ExternalSource and ExternalId, and Parent may be null. The v1 reads leave out a project that is archived and a change does not. The compat plane shows the parent a work item has (it was hard-coded null) and maps the new error. research/0014 records what the pin does for the 14 operations and what is decided. Tests: core (13: access, parents, whole-row change, archived project, delete rules and cascade, search), the memory adapter (10, with a generated forest checked against the closure) and Postgres (4); the model test and the column inventory follow the schema. Controls: the Postgres walk, the search's membership join and its archived filter were each broken and each caught on its own; the compat parent line likewise. cargo-mutants: core 52 caught/10 unviable/0 missed; the memory adapter's new methods all caught after one test and one restructuring. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * feat(api-v1): the work items of /api/v1: list, create, retrieve, change, delete, search and the lookup by KEY-n The 14 work-item operations of #58, in both families of paths (`issues/` and `work-items/`), over the use-cases of the previous commit: - the 29-key body; `fields` and `expand` (state, assignees, labels); - list: `pql`/`filters` refused in the pin's words, the single-object mode for an integration key, the pin's `order_by` allowlist (`-priority` runs from none, `state__*` by the state's group, anything else the default); - create (201) and change: DRF's field messages collected into one 400, a key Django cannot read a bare 400, `validate()`'s refusals one at a time (dates, description, people), the key's 409 naming the item, the body parsed before the work item is looked for; - delete: a project admin or the maker (403 in the pin's words), what is under the item goes with it; - the workspace search (`{"issues": [...]}`) and the lookup by `KEY-n`, which splits at the last hyphen. D-033 records the ten places this differs from the pin; it is proposed and awaits the owner. `archived_at` has no order arm: a list is of the work items that are not archived, so there is nothing for it to order. Tests: route cases through the crate's own router, generative where the domain allows it (the date orders, the state and completion orders, and a restatement of Django's `parse_date` against text built right and wrong in each part). cargo-mutants on `work_items.rs` and `fields.rs`: the first run missed 17 and timed out 2; the re-run of every function that had one tests 79 mutants, 74 caught, 5 unviable, 0 missed, 0 timed out. `whole_numbers` no longer walks an index (two of the timeouts, and an equivalent `<`). Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 15, 2026
Closed
Merged
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.
Status: draft, the first of the slices of #58
#58 is six workstreams. This PR carries them one resource at a time and stays a draft until the gate is on. Done here: the oracle vendored, the v1 crate's foundation, the projects (8 of the 32 operations), the states (5 more) and the labels (5 more). Not done: work items, the seed and reset, the scoped gate and the corpus comparison, the contract-suite migration off
/api/_slice, and the utoipa andoasdiffcheck. Nothing below is claimed beyond what is listed.oracle-v1.shVERDICT: PASSonnative-pgandworker-cf, and on Planeoasdiffreports no breaking change for the 32 operationsWhat is in it
tools/oracle-v1/, Q-0122.4): a byte-for-byte copy oforacle/at72b2e01497of the fork branch (the subtree hash matches the fork's), withSOURCEnaming the commit. The round-27 register corrections it never received are their own commit (EX-001 and EX-002 toreproduce). ADR-0006's register has the row, with the one exception to "stdlib-only".research/0013: the v1 field inventory, from the schema, the 105 in-scope corpus exchanges and the pinned Plane source. It corrected the plan in five places: a new state'ssequenceis the max non-triage + 15000, not +10000;Issue.objectsleaves archived items out of the state-delete check; states and labels use different permission classes; (found while building the states) every state write is for a project Admin, not an Admin or a Member; and (found while building the labels) a label write is for a project Admin or Member, which settles the question it had left open.thrust-api-v1(new crate, runtime-free, under the panic lints):Ctxauthenticates byX-Api-Keyonly, then permission, then the throttle, in DRF's order;X-RateLimit-Remainingand-Resetride every counted answer, errors included.Resetisint(now + window)as the pin computes it, so theRateLimiterport needed no change.V1Errorhas both of Plane's body shapes, the 5900 429 andplane_500().thrust-serverandthrust-worker. Cursor pagination as the pin has it (including the two reproduced quirks:per_page0 or less is a handled 500, a negative page a 400),order_byover the five allowed keys,fields, DRF's field messages.Cannot create triage stateafter the fields were fine, and the three answers to a taken name: 409 with the id on create, the base view's 400 on change, and the pin's accidental 500 for a name that the hidden intake state has (reproduced, handled).external_sourceandexternal_id) that another state has is a 409 naming it; a delete refuses the default state and a state that holds work items.BaseAPIView.initial), so a body that cannot be parsed (415, malformed JSON, a scalar) is refused before the state is looked for; only a list or a wrong field comes after the 404. The first version put all of it after, and its test pinned that. And a create looks a taken name up by the text as sent, which DRF had trimmed, so a taken name sent with spaces round it is the pin's 500, not a 409. Both are fixed, each with a test that fails with the old behaviour put back.Permission::WriteState). A project member, a guest, a stranger and a workspace admin who is not in the project all get the uncounted 403.order_by; the detail read ignoresfieldsandexpand, as the pin's does.parentthat Django cannot read as a UUID is the base view's bare 400Please provide valid detail, with the other fields unreported (nothing catches it inside the field); a UUID that names no label isInvalid pk "<value>" - object does not exist..deleted_at); every read leaves them out; their name and key are free again. The two unique indexes are replaced once, by a catalog check. 0012 no longer makes them:migrateruns every file on every start, so it would have made the plain index again and failed once a deleted name was reused. A test proves the index is the same object after a restart. States gainexternal_source,external_id,updated_byanddeleted_at, and(project_id, name)becomes a partial unique index on live rows, replaced the same way. A state that is made or becomes the default clears the others' flag in the same transaction. Labels gain the same four columns and the same partial unique index on(project_id, name), replaced once the same way, and an index onparent_idfor the delete's walk.project_writer(v1'sProjectBasePermission: a project admin, or a project member who administers the workspace),change_project,set_project_archived,delete_project,visible_projects,visible_project; andvisible_states,visible_state,find_state,create_state,change_state,delete_state; andvisible_labels,visible_label,is_label_of_project,create_label,change_label,delete_label. The internal API'supdate_projectbehaves as before.For your decision
expand; soft deletion of the children; the order of ties). D-031: three ways the v1 states differ (is_triagefollows the group; a slug drops a character that is not ASCII, where Django folds an accent to its letter; asequenceofnanorinfis refused), and one quirk reproduced on purpose (the 500 for a name that the hidden intake state has).parentmust be a live label of the same project; the pin accepts any label of any project or workspace and returns its id, which tells a caller that a label exists somewhere they cannot see. This one is a security choice, and the corpus names no parent. (2)expandis ignored on the label list and on the state list and detail. (3) A taken external key is found by the trimmed text; a key sent with spaces round it is a 409 here, where the pin stores a second one. (4) A label's deletion cascade is synchronous; the pin finishes it in a background task. (5) Labels made in one instant come last-placed first.work_items.created_bynullable, is decided (yes) and lands with the work items.Verification (run locally on this branch)
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings, the wasm32 Worker clippy,scripts/check-deps.sh: clean.cargo nextest run --profile ci --workspace: 3004 passed, 4 skipped; the doctests pass.pg_adapteragainst Docker: 48 passed.scripts/contract.sh native-memory mainandnative-pg main: 55 of 55 each.cargo mutants): the projects stage as before (the new crate, 214 mutants, 164 caught, 50 unviable, 0 missed). The states stage:thrust-api-v1'sstates.rs,fields.rsandrequest.rs, 130 mutants, 110 caught, 20 unviable, 0 missed;thrust-core'sstates.rs, 29 mutants, 22 caught, 7 unviable, 0 missed. The labels stage:thrust-api-v1'slabels.rsandfields.rs, 130 mutants, 110 caught, 20 unviable, 0 missed;thrust-core'slabels.rs, 34 mutants, 28 caught, 6 unviable, 0 missed; the memory adapter's label methods, 49 mutants, 46 caught, 3 unviable, 0 missed. In every stage the first run missed or timed out on some (here: the label named in a taken-name answer on a change, and a counter in the memory adapter's walk that a mutant turned into an infinite loop, which is now a worklist), and each became a test or a change to the code.pg_adapter's column lists forprojects(gainsdeleted_at), forstates(gains the four columns) and forlabels(gains the four). They exist to force that edit.Not run by me: the Worker contract cells (
worker-cf,worker-memory), which CI runs, andscripts/mutants.sh.Refs: #58
🤖 Generated with Claude Code