Repository navigation
feat(tags): reserved system tags, per-tag permission, tags in export (#805) - #875
Conversation
…he export (#805) - tags gain kind (user|system) and apply_min_role (steward|admin, null = the steward route default); the five spec-reserved names are a 422 on create, case-insensitively, and a system tag is a 422 to retire and a 422 to hand-apply (operator excepted — the platform's own credential) - apply_min_role is enforced on apply AND unapply as a 403 naming the required role — 403 on role, never 404, per the house rule - GET .../taggings?subject_type= is the bulk read the segment export prequeries (cap+1 truncation probe, reported in the envelope); the CSV gains a tags column joined through the active vocabulary, and a truncated prequery is named in x-export-summary - pg::create_system_tag is the internal path the platform's writers will use; the pg test drives it to prove the guards
…e MCP + envelope ledgers (#805) pg_serial keys one database per FILE, so the new assertions land as phases 6-9 of the existing test rather than a second #[tokio::test]. tools.json gains the taggings read and the apply_min_role body field; envelopes.json records the {taggings, truncated} envelope.
…ning (#805) pr-review findings: - BLOCKER (entity-framework): the differ reads a missing NOT NULL column as breaking regardless of default, so every store that already had 'tags' would refuse to boot. 0005_tag_kind (BeforeReconcile, Safe) adds kind idempotently; pg_schema_replay phase 5 ages a store and proves the boot heals with the default filling pre-existing rows. - taggings_dataset_subject (dataset_id, subject_type, subject_id) serves for_dataset's filter AND order with no sort. - security hardening taken in-PR: TagIn/TagApplyIn now deny_unknown_fields (seven house precedents), so kind:'system' in a body is a rejected 422 rather than silently ignored; phase 6 pins it. - export docstrings: the tags column is a pg point-in-time read, not snapshot-pinned; the join has an end-to-end assertion (watchlist in the CSV), not just the header.
4fbb9f8 to
97422a3
Compare
|
Flagging a post-merge failure that belongs to this PR — found while landing #895, whose own merge SHA the run is misleadingly labelled with.
Root causeThe helm upgrade rolled back atomically on So of the two columns this PR adds to Where the fix goes
What is NOT brokenDev is still serving. The upgrade was atomic, so it rolled back; The consequence is that |
Closes #805
What
Three residue items from spec unit 1.29: reserved system tag names (
merge,manual_merge,unmatch,link,split) that users can neither create (422) nor retire (kindcolumn + 422), a per-tagapply_min_roleenforced as a 403 on apply/unapply, and atagscolumn in the segment CSV export joined from a new bulk taggings read.Why
The tag service is live but has no system/user distinction — a user can squat a name the system will need — no per-tag permission finer than the route, and the export drops the vocabulary entirely.
Proof
make checkgreen (entities-check regen byte-clean; pg_tags 9 phases green against real Postgres, incl. the reserved-name 422s, the 403-not-404 ladder, and the system-tag guards).make frontendgreen — 549 passed; onedatasets.spec.tsmobile-chrome flake on the first run passed in isolation on all three browsers and on the rerun.Re-verified after a rebase onto a
mainthat had moved four PRs (incl. #519's audit-store schema change):make checkgreen end-to-end, pg_tags / pg_schema_replay / fixups green, frontend types + 17 unit tests green. One conflict (generatedentities-index.mdstatement count) resolved by regen.pr-review round (four fresh-context reviewers, findings verifier-scored):
tags.kind. Fixed with the0005_tag_kindBeforeReconcile fixup (fixups.rs) that adds the column with its default on old stores, plus pg_schema_replay phase 5 which ages a store past the fixup and proves the heal. VERIFIED merge-ready by the same reviewer.#[serde(deny_unknown_fields)]onTagIn/TagApplyIn(phase-6 pin), and the unreadable-apply_min_rolepath now fails CLOSED with a 500 instead of silently lifting the floor.tagscolumn is a pg point-in-time read with unspecified cell order, and grow.spec pinswatchlistin an actual CSV row.make check-e2e: not owed — no lake statement changed (the new read is Postgres-side).Risk & rollback
Additive schema columns with defaults; new 422s only on previously-accepted-but-wrong calls.
git revertis the rollback.Post-merge ledger
Closed by: the post-merge watch on
350cd213and its successor85de6958mainis green with this change on it —350cd213's ownrustpush run was cancelled by the concurrency group when
9583e470landedbehind it;
85de6958(which has350cd213as an ancestor) is all-green:rust42520403802,frontend42520403658,infra42520403770 — and350cd213's ownfrontend/infra/devcontainerruns were green beforethe cancel:
imagesbuilt — success on350cd213(er-server is in the apiimage):
deployconverged — but first it failed, on this change:350cd213's deploy (run 42516648310) died at the schema-migrate hook,which plans before fixups run and read
tags.kindas breaking. Root-causedin migrate --expect-additive refuses a NOT NULL column that carries a default — #805's tags.kind can never deploy #904 with a byte-exact local repro, fixed in fix(schema): a NOT NULL column with a declared default is additive (#904) #905; the very next deploy
(run 42520861582 on
85de6958, carrying this change's schema) emittedSTATUS: deployed … REVISION: 162anddeployment "web-api-blue" successfully rolled out:85de6958(above);driftlatest success (b4b0b0fb);kindnightlylatest success (
0a4aac56):Doneand feat(tags): reserved system tags, per-tag permission, and tags in the export #805 closed — both by the automation onthe merge (verified on the board, not by hand):
(tag prefixes, from feat(ui): group search by member id, and the seven missing group filters #801), Manage a tag's apply_min_role after creation (PATCH route + create-form picker) #876 (
apply_min_rolePATCH + UI), The five standalone telemetry alarms that need no cost model (runner-pending, queue age, failure rate, spot interruptions, impersonation volume) #877 (5standalone alarms, child of Cost attribution: the unbuilt half of the telemetry programme (P16/P17) #667), MCP manifest cannot represent required query params #878 (MCP manifest lacks query params),
Export 502s on a Postgres-less er-server (the 501 shape meets the tags prequery) #896 (export 502s on Postgres-less er-server), Reconciler-added columns never get their CHECK constraints — healed stores drift from fresh DDL #914 (reconciled columns
never gain CHECK constraints; retires the redundant
0005_tag_kind), andmigrate --expect-additive refuses a NOT NULL column that carries a default — #805's tags.kind can never deploy #904 itself, which this change caused and which has landed:
missing_column_is_additivedoc comment now carries thegate-plans-before-fixups mechanism; the store-aging repro technique
(recover a hook refusal without cluster access) is in fix(schema): a NOT NULL column with a declared default is additive (#904) #905's body;
entities-index.md's owner (skills-check.sh regen, noter-entity gen)is in this body's Discoveries:
Specific to this change
Context — plan, discoveries, measurements, files
Plan
entities/tag: +kind(user|system), +apply_min_role(nullable); create statement gains both params; regen.systemtag,pg::create_system_tagfor system writers (tests use it).apply_min_roleonTagIn(values steward|admin), enforced intag_applicationas 403 naming the required role, after the 404 existence check (which leaks nothing — viewers can list the whole vocabulary).tagging.for_datasetdeclared read (cap+1 truncation probe),GET .../taggings?subject_type=entity(Viewer+), BFF segment export joins and gains atagscolumn; truncation reported inx-export-summary.Discoveries
kindcolumn anywhere.ANY($ids)join is not declarable; the export prequery is one dataset-scoped capped read instead, with truncation detected (cap+1) and reported.tag_applicationleaks nothing: Viewer+ already lists the entire vocabulary.Tag/Taggingare not OpenAPI components (they are in 15 entities declare wire: [json] with no OpenAPI component schema — an in-code backlog with no ticket #762's fifteen), so no openapi.json/schema.d.ts regen was owed; the contract surfaces that DID move are the MCP manifest (tools.json: new taggings tool +apply_min_rolebody field) and the envelope ledger (envelopes.json:{taggings, truncated}), both regenerated by their--ignored regeneratearms.#[tokio::test]— and the fold exposed a real ordering fact: a steward's retire attempt on a system tag is the route's 403, not the guard's 422, because the admin floor runs first.BeforeReconcilefixup, and pg_schema_replay is the gate that proves the heal. Plainer-entity gendoes not writeentities-index.md;scripts/skills-check.sh regendoes (caught by skills-check after the rebase).bigint, notint8;list<varchar>exists as a param type (unused here — the capped prequery is the right shape for the export regardless).Measurements
lib.rstaggings_index).make frontend: 549 passed, 117 skipped (device/release tiers), 2.5 min.Files
entities/tag/entity.yaml,create/*,read/*— +kind, +apply_min_role, regenerateder-entities+Tag.tsbinding + DDL.entities/tagging/read/for_dataset.{sql,yaml}— the new capped bulk read.rust/crates/er-server/src/fixups.rs—0005_tag_kindBeforeReconcile fixup.rust/crates/er-server/tests/pg_schema_replay.rs— phase 5: aged store heals through the fixup.rust/crates/er-server/src/pg.rs—RESERVED_TAG_NAMES,create_tag+apply_min_role,create_system_tag,tag_by_id,taggings_for_dataset.rust/crates/er-server/src/lib.rs— reserved-name 422, system-tag retire/apply guards, per-tag role floor (403),taggings_index+ route.rust/crates/er-server/tests/pg_tags.rs— phases 6–9.rust/crates/er-mcp/tools.json,frontend/src/lib/api/envelopes.json— regenerated ledgers.frontend/src/lib/bff/export-tags.ts+tests/unit/export-tags.test.ts— the join and its unit coverage.frontend/src/app/api/.../segments/export/route.ts— prequery,tagscolumn, truncation note.frontend/src/lib/bff/tags.ts—apply_min_rolepassthrough.frontend/tests/mock-erserver/server.mjs— reserved names, new fields, the taggings endpoint.frontend/tests/functional/grow.spec.ts— header pins thetagscolumn last.