Repository navigation
test(service-bridge): real-Postgres read-model coverage + 2xx OpenAPI tether (#174 remainder) - #21
Merged
Merged
Conversation
… tether (docmost#174 remainder) Post-R3 remainder of wiki-v2#174 (paired with the super PR): re-home the executed contract coverage for the read-model paths proven today only by the Kysely spy (compiled-SQL string matching), and extend the C.4 tether to the response bodies. - read-model-pg.testkit.ts: shared postgres.js + CamelCasePlugin harness (private-schema search_path, base tables, deterministic workspace resolver). - service-content.pg.spec.ts: F1 keyset millisecond-truncation ordering + cross-boundary paging (issue-122 class) and F2 confidentiality (a supplied id that is cross-workspace or soft-deleted is excluded by the engine). - service-space.pg.spec.ts: list / listMembers / getDetail confidentiality (workspace_id, is_personal, deleted_at), previously untested. - service-workspace.pg.spec.ts: settings JSONB shallow-merge round-trip (sibling key survives). - service-bridge.contract.spec.ts: extend the C.4 key-set tether to the 16 body-bearing 2xx ops (typed Record<keyof T,true> maps + per-op body wiring). Mutation-verified (each new assertion reddens on a deliberate defect); every pg spec carries the AUTHZ_REQUIRE_PG anti-vacuity guard and self-skips without AUTHZ_TEST_PG_URL. No runtime code, no upstream edits, no tag. Co-Authored-By: Claude Opus 4.8 <[email protected]>
- service-content.pg.spec.ts: replace the mis-named listSpacesByIds test with a real spaceId-narrowing test on listPagesByIds (the space_id filter branch was untested + a misleading comment; mutation-verified), and add a spaces keyset tie/paging test mirroring the pages fixtures (listSpacesByIds was only smoke-tested). insertSpace now builds sub-ms fixtures via a SQL interval. - service-workspace.pg.spec.ts: cover the no-op update short-circuit and the unknown-mode view normalization on real Postgres. - service-bridge.contract.spec.ts: tether ProvisionedUser to the controller return type instead of a hand-written literal; note the tether validates key-sets, not per-field value types. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…circuit (docmost#174) The workspace no-op test claimed "issues no write" but asserted only that the settings jsonb was unchanged, which stays true under an updated_at-only UPDATE (Testing + Correctness both flagged this). Now capture updated_at before/after and assert it is byte-identical, so dropping the short-circuit (which would run the fragments UPDATE setting updated_at = now()) reddens the test. Mutation-verified. Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
Summary
Post-R3 remainder of wiki-v2#174 (paired with the super PR): re-home the executed real-Postgres contract coverage for the read-model service-bridge paths that today are proven only by the Kysely spy (compiled-SQL string matching), and extend the C.4 OpenAPI key-set tether to the response bodies.
Test-only. No runtime code, no upstream Docmost edits, no tag. Every file lives under
apps/server/src/service-bridge/(boundary-excluded; specs excluded from the runtime image bytsconfig.build.json).What's covered
Real-Postgres pg specs (new; run in the
docmost-authz-pglane via the*.pg.spec.tsglob, each with theAUTHZ_REQUIRE_PGanti-vacuity guard, self-skipping withoutAUTHZ_TEST_PG_URL):service-content.pg.spec.ts— F1 the/v1keyset read model:date_trunc('milliseconds', updated_at)is applied symmetrically in the WHERE tuple and the ORDER BY with anid::texttiebreak, so rows sharing a truncated millisecond page without duplicate or skip (the issue-122 class a SQL-string assertion cannot catch); F2 confidentiality: a supplied id that is cross-workspace or soft-deleted is excluded by the ENGINE (listPagesByIds/listSpacesByIds/getSpace/resolvePageSpace/listPagePermissions).service-space.pg.spec.ts— F2 the space read paths (list/listMembers/getDetail), previously untested:workspace_id,coalesce(is_personal,false)=false,deleted_at is null, live-only member count.service-workspace.pg.spec.ts— F3 the settings JSONB shallow-merge round-trip: a sibling key survivescoalesce(settings,'{}') || jsonb_build_object(...).read-model-pg.testkit.ts— shared harness (postgres.js + PostgresJSDialect + CamelCasePlugin + private-schemasearch_path), mirroring the production Kysely config.OpenAPI tether (
service-bridge.contract.spec.ts): C.4 tethered only the two feed responses; this extends the same typedRecord<keyof T, true>key-map tether to the 16 body-bearing 2xx ops (the 7 reusable component schemas tied to the fork return types + per-op body wiring for arrays /{items}/ inline bodies), so a renamed or dropped response field fails from both directions (compile + runtime).Fixture gotcha (documented in-code): postgres.js coerces a bound ISO string to a millisecond-precision Date before sending, so the sub-millisecond F1 fixtures are built with a SQL interval, not a bound string (
to_char(updated_at,'US')shows the true sub-ms value only via the interval path).Verification
docmost-authz-pgglob: 6 suites / 31 tests green on realpostgres:18; anti-vacuity (AUTHZ_REQUIRE_PG=1, no URL) fails as designed.src/service-bridge src/authz): 44 suites / 363 tests; provider contract spec 22 tests.date_truncremoved to F1 ordering red; WHEREdate_truncremoved to F1 boundary paging red (row skipped);workspace_idremoved to cross-workspace page leaks;deleted_at is nullremoved to soft-deleted leaks;listMembersdeleted_atremoved to deleted member leaks; jsonb merge to plainjsonb_build_objectto sibling key dropped; doc field rename to tether red; op mis-wiring to tether red.tsc: zero new errors vswiki-v2;check-upstream-boundary.shexit 0 (no upstream file touched); no em/en dashes added.Paired with the super PR. Merge this fork PR first, then the super repo repoints its
docmostsubmodule to this PR's merge commit.🤖 Generated with Claude Code