Commit a7ab047
fix(rest): a public form that cannot take intake on a walled posture is not offered; the admin read says why (#21580)
Part of #21476
Clause-②: no
This delivers the doors half and the administrator's read half of the
triage ruling (`5962758813`). The publish half is left open on purpose:
its contract-faithful channel sits behind
`packages/metadata-protocol/src/protocol.ts`, which open PRs hold. The
call sites are under "Not in this PR". The keyword is `Part of`, so the
card stays open after this merges, while that half waits for a decision.
## What
On a walled tenancy posture, a public form bound to an object walled by
an organization column is no longer offered to anonymous visitors.
An anonymous submission carries no organization. On a walled posture the
engine refuses an insert without one into such an object
(`resolveSystemInsertOrganization`). So the form was served (`GET
/forms/contact-us` 200), and then every submit answered `500
ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED`. This was reproduced on
`origin/main` (`6dd99b82c3`) with `bootStack(showcaseStack, {
multiTenant: 'posture-only' })`.
- **One predicate.** `anonymousFormIntakeUnavailability` in
`packages/rest/src/rest-server.ts` returns null when the form can take
intake, otherwise why it cannot. It reads two facts and restates
neither:
- the tenancy service's in-force `posture`. This is the value
SecurityPlugin hands the engine (`setTenancyPostureProvider`), so a
degraded walled request reads `single` there, and the engine derives the
install's organization.
- the wall column, from `@objectstack/metadata-core`'s existing
`resolveRecordWallOrganizationField`, read over the served object schema
(which carries the injected `organization_id`).
The object is read only once a wall is in force, so single-posture
deployments pay nothing new.
- **Both doors read it in one place.** It is called inside
`resolveFormBySlug`, the one resolution both `GET /forms/:slug` and
`POST /forms/:slug/submit` already call. An unavailable form resolves to
`null`, which is exactly the withdrawn form's `404 FORM_NOT_FOUND`, byte
for byte. Anonymous callers learn nothing about the tenancy, and there
is no second check per door.
- **The administrator's read names why.** `GET /meta/view/:name` puts
one warning in `item._diagnostics.warnings` per unavailable open form.
It sits on both arms (cached and uncached), is located at the form's
`sharing` (`config.sharing`, `formViews.KEY.sharing` or `form.sharing`),
and names the slug, the object, the wall column, the posture and the
remedy (`tenancy: { enabled: false }` when the rows belong to no
organization). The reason depends on facts the protocol's validator
never hashes, so on the cached arm a `view`'s If-None-Match is compared
in REST against an ETag with the reason folded in (the ADR-0106 D3
shape). With no reason, the ETag and the 304 are byte-identical to
before (pinned).
### Placement: the predicate lives in `rest`, not `metadata-core`
The dispatch assumed `metadata-core`'s `anonymous-form-intake.ts`. I
measured that first: any new export there enlarges
`@objectstack/metadata-core`'s published index (`export *`), which is a
`Clause-②: yes (widening)` change by #21566's own grading. The dispatch
pins `Clause-②: no`.
Every reader of the predicate (two doors, one admin read) is in
`rest-server.ts`. The predicate composes two rules that are already
shared (`postureEnforcesWall` from spec,
`resolveRecordWallOrganizationField` from metadata-core), so no rule
gains a second spelling. It moves into `metadata-core` on the day a
reader outside `rest` exists, for example the publish half's option A
below.
## Pins
- `packages/rest/src/public-form-intake-availability.test.ts` (16
tests):
- The doors are enumerated off the registered routes. The set under
`/forms/` must be exactly the two doors, and each door on each walled
posture (`isolated`, `group`) is its own row: it answers the withdrawn
form's answer byte for byte, and `createData` is never called.
- Controls, all accepted: a `tenancy: { enabled: false }` object, the
single posture (where the object is not even read), a degraded walled
request, and no tenancy service.
- Admin read on both arms: the located warning appears on the walled
cases, and `_diagnostics` is untouched on the controls.
- Validator: the bare protocol ETag revalidates into the reason, the
folded ETag gives 304, and the control's ETag is unchanged and still
gives 304.
-
`packages/qa/dogfood/test/showcase-public-form-walled-intake.dogfood.test.ts`
(real walled showcase boot):
- both doors' raw answers equal the same form's answers once withdrawn
env-wide on the same boot, and no `showcase_inquiry` row lands;
- the admin read names the reason at `config.sharing`.
- `public-form-withdrawal-walled.dogfood.test.ts`: the dogfood control.
A tenancy-disabled object on the walled boot still accepts intake, and
its admin read now also asserts that no intake warning is present.
## Ablation (one-shot, not kept)
Each mutation was applied with `scripts/ablation-replace.mjs` against
`packages/rest/src/rest-server.ts`, whose HEAD blob is `239ac2d6` at
both `8a8839f9ab` and the final `66ee5294a6`. The direction was
predicted before each run.
- **A, unit leg: the doors stop reading the predicate.** `return
unavailable ? null : { ...match, organizationId };` became `return {
...match, organizationId };` (anchor 1 to 0, blob `239ac2d6` to
`43fdf709`).
- Predicted: exactly the 4 door rows red, everything else green.
- Observed: 4 failed, 12 passed. The GET rows received 200 and the POST
rows 201 where 404 was expected; the admin-read rows stayed green
because they reach the predicate from their own call site.
- Restore: blob equals HEAD and `git diff HEAD` is empty.
- **A, dist leg (dogfood).**
- The first attempt was a no-op. The same replacement left `unavailable`
unused, and the DTS build refused it (`noUnusedLocals`) after the JS
bundle had already been emitted, so no test ran. I rebuilt from the
restored source, and `ablation-dist-preflight` confirmed the guard
present in `dist/index.js` and `dist/index.cjs` with a clean tree.
- Re-run with `return unavailable && false ? null : { ...match,
organizationId };` (blob `2b2e9c9f`), rebuilt; the preflight found the
plant marker in 2 built files.
- Predicted: 1 red. Observed: 1 failed (`expected 200 to be 404` on the
doors row), 8 passed.
- Restore: blob equals HEAD, rebuilt; the preflight found the guard in 2
files, the mutation absent from all 6, and a clean tree; the dogfood run
went back to 9/9.
- **B: the predicate itself answers "available".** `return tenantField
=== null ? null : ...` became `return tenantField === null || true ?
null : ...` (blob `25ef3c8e`).
- Predicted: 7 red (4 door rows, plus the 3 walled admin-read rows:
uncached, cached, validator) and 9 green.
- Observed: 7 failed, 9 passed. Restore: blob equals HEAD and the tree
is clean.
The pins asked for an ablation "on one door". There is no per-door read
site to ablate: the predicate is read once, in the resolution both doors
call. Ablation A removes that one read, and each door's own row goes
red.
## Tests (at `66ee5294a6`, after merging `origin/main` `44072fc2b9`)
- `@objectstack/rest` full suite (`--project local`): 258 files passed;
4883 tests passed, 326 skipped. `typecheck`: `tsc --noEmit` clean, and
`check:test-typecheck` OK.
- `@objectstack/metadata-core`: 17 files / 311 passed; `typecheck` clean
(it is unchanged).
- `@objectstack/dogfood` `typecheck` clean. Public-form dogfood files
(walled intake, walled withdrawal, showcase withdrawal, showcase public
form, read-back masking): 5 files / 20 passed.
- `@objectstack/runtime` `/meta` parity census, run because it reads
`rest-server.ts` source and `rest`'s `dist/`. The four files
`meta-list-projection-parity`, `meta-item-read-gate-parity`,
`meta-read-org-scope-parity` and `meta-item-envelope` gave 780 passed.
- `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--commands`: 68 commands; 67 exit 0. `check:dual-build-cjs-loads`
answered PREREQUISITE NOT MET (it needs a full workspace build), so it
is NOT MEASURED and left to CI. The `--ran` reconciliation accounted for
68 of 68: 67 run, 1 NOT MEASURED, 0 unrun.
- eslint, narrowed to the 4 changed `.ts` files (`--no-inline-config
--format json`): 4 files, 0 errors, 0 warnings, none ignored. The fifth
changed path is a changeset `.md`. The narrowing is sound because
`eslint.config.mjs` never enables type-aware linting (no
`parserOptions.project`), so this diff cannot move any untouched file's
verdict. The full `pnpm lint` is CI's.
## Not in this PR: the publish half
The ruling asks the publish surfaces (`PUT /meta/view/:name`, `POST
/meta/view/:name/publish`) to say why too. The only located, structured
channel those responses carry is `advisories`, and both
`SaveMetaItemResponseSchema` and `PublishMetaItemResponseSchema` declare
the runtime authoring gate as its producer. The places that would have
to change:
- `packages/metadata-protocol/src/runtime-authoring-gate.ts`: a
gate-local rule would sit beside `findPlatformScheduleOrgGaps`, around
line 300.
- `packages/metadata-protocol/src/protocol.ts:5612`: the gate is fed
`orgWallEnforced: this.orgWallEnforced()`.
- `protocol.ts:5938`: `orgWallEnforced()` reads the requested posture
(`postureEnforcesWall(resolveTenancyPosture())`), which disagrees with
the doors' in-force reading on a degraded deployment.
- `protocol.ts:18673` and `protocol.ts:19612`: the attach sites.
`protocol.ts` is held by open PRs #21545 and #21512, so this PR stops
there. The options and a recommendation are in the report on the card.
## Acceptance notes
- **Boundary of the predicate.** It reads declarations. The engine also
passes a federated (`external`) object, a platform object its inventory
has not admitted, and a row a `beforeInsert` hook stamped. A form bound
to one of those that also carries a wall column is withheld here
although the engine would accept it, which is the fail-closed direction.
No shipped hook stamps `organization_id` (`git grep` over the CRM and
showcase hooks: exit 1, with a `beforeInsert` control at exit 0).
- **New failure mode on walled postures.** An object-metadata read
failure now fails both doors closed (GET `500 FORM_RESOLVE_FAILED`;
submit through `mapDataError`). Single-posture deployments make no new
read.
- **Cached arm.** For every `view` read, If-None-Match is now compared
in REST rather than in the protocol. Server work is unchanged, because
`getMetaItemCached` already delegates to `getMetaItem`. Response bytes,
the ETag and the 304 are identical when there is no reason.
- **Not stamped by this PR.** The list read (`GET /meta/view`),
`/layers`, and the runtime HTTP dispatcher's `/meta` item read. The
dispatcher serves no `/forms/*` door, so a dispatcher-only composition
has no intake that could be unavailable.
- **CRM.** `app-crm`'s lead form (`/forms/contact-us`) is the same class
on a walled CRM deployment. Not booted here.
- **Console.** Whether the console renders `_diagnostics.warnings`: NOT
MEASURED (no `objectui` checkout in this container).
---
_Generated by [Claude
Code](https://claude.ai/code/session_01DiCSbmJrkzNhuEAier4VoJ)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent cc645f2 commit a7ab047
5 files changed
Lines changed: 620 additions & 42 deletions
File tree
- .changeset
- packages
- qa/dogfood/test
- rest/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
165 | 169 | | |
166 | 170 | | |
167 | 171 | | |
| |||
Lines changed: 116 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
Lines changed: 239 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
0 commit comments