Skip to content

Commit 3b1ae50

Browse files
committed
refactor(metadata-protocol): move the query validation out of protocol.ts into protocol-query-validation.ts
Move-only. The class keeps the nineteen private query-validation methods (assertObjectRegistered, the assert*FieldsExist family, the refuseInternal* walks, servedExpand and their helpers) with their docblocks, signatures and positions; their bodies move unedited into the new module and are handed the members they read through host literals (QueryValidationHost). The eleven module-level declarations only those bodies read move with them, unedited. The ten that code staying in protocol.ts also reads gain export in place; index.ts exports protocol.js by name, so none of them is published. The bracketed-refusal pin follows the 17 moved refusal sites with a PRODUCERS row for the module. Claude-Session: https://claude.ai/code/session_01J8pUyVs5eas1AjMdReJM7C Co-authored-by: Claude <noreply@anthropic.com>
1 parent f38832b commit 3b1ae50

4 files changed

Lines changed: 1544 additions & 1235 deletions

File tree

‎packages/core/src/security/second-object-read-exposure.pin.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,18 @@ type Classification =
125125

126126
/** Every non-test caller of the arbiter, classified. */
127127
const CALLERS: Record<string, Classification> = {
128-
'packages/metadata-protocol/src/protocol.ts': {
128+
'packages/metadata-protocol/src/protocol-query-validation.ts': {
129129
kind: 'decided',
130130
read: "the data door's `$expand` (the list, single-record, query and export routes, every level of the tree)",
131131
operation: 'get',
132-
decision: { file: 'packages/metadata-protocol/src/protocol.ts', fn: 'servesExpansionTarget' },
132+
decision: { file: 'packages/metadata-protocol/src/protocol-query-validation.ts', fn: 'servesExpansionTarget' },
133133
wiring: { file: 'packages/metadata-protocol/src/protocol.ts', call: 'this.servedExpand(' },
134134
pin: 'packages/metadata-protocol/src/protocol.expand-target-exposure.test.ts',
135135
},
136136
'packages/objectql/src/engine.ts': {
137137
kind: 'executes',
138138
read: "the expansion sub-read (`ObjectQL.expandRelatedRecords`), for the data door's `$expand`",
139-
decidedIn: 'packages/metadata-protocol/src/protocol.ts',
139+
decidedIn: 'packages/metadata-protocol/src/protocol-query-validation.ts',
140140
also:
141141
'the write-path reference-existence probe (`referenceExists`: whether a stored id resolves, no field) and ' +
142142
'the validation-predicate reads (`resolvePredicateRelated`: a pass/fail verdict, the value never served). ' +
@@ -162,8 +162,8 @@ const CALLERS: Record<string, Classification> = {
162162
kind: 'decided',
163163
read: "the data door's nested-relation filter condition (`ObjectQL.lowerRelationConditions` reads the related object to lower it), refused rather than withheld",
164164
operation: 'list',
165-
decision: { file: 'packages/metadata-protocol/src/protocol.ts', fn: 'refuseUnservedRelationTarget' },
166-
wiring: { file: 'packages/metadata-protocol/src/protocol.ts', call: 'this.refuseUnservedRelationTarget(' },
165+
decision: { file: 'packages/metadata-protocol/src/protocol-query-validation.ts', fn: 'refuseUnservedRelationTarget' },
166+
wiring: { file: 'packages/metadata-protocol/src/protocol-query-validation.ts', call: 'this.refuseUnservedRelationTarget(' },
167167
pin: 'packages/metadata-protocol/src/protocol.relation-condition-target-exposure.test.ts',
168168
},
169169
'packages/plugins/plugin-approvals/src/approval-service.ts': {
@@ -395,7 +395,7 @@ describe('[#22661] every read that reaches a second object asks that object its
395395
expect(mentioning).toContain(declaration);
396396
expect(callsArbiter(declaration)).toBe(false);
397397
// The body reader reads the right function: the decision lives in it, not beside it.
398-
expect(functionBody('packages/metadata-protocol/src/protocol.ts', 'servedExpand').some((line) => DECISION_CALL.test(line))).toBe(false);
398+
expect(functionBody('packages/metadata-protocol/src/protocol-query-validation.ts', 'servedExpand').some((line) => DECISION_CALL.test(line))).toBe(false);
399399
},
400400
SCAN_TIMEOUT_MS,
401401
);

0 commit comments

Comments
 (0)