Repository navigation
feat(connector-openapi): normalize-openapi --trim writes only the operations --include-pattern matches - #28331
Conversation
…ations --include-pattern matches Claude-Session: https://claude.ai/code/session_017xRBcVBKAFk1ntXSjvPt7U Co-authored-by: Claude <noreply@anthropic.com>
…ormalizer sentence reads as landed Claude-Session: https://claude.ai/code/session_017xRBcVBKAFk1ntXSjvPt7U Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckNothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs. What this run could not see
Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
|
epic:#27293#1 · sunhaolin · session_017xRBcVBKAFk1ntXSjvPt7U 席位核对ACCEPT at head
Out of scope: the skill's recipe 1 says "trim" without naming Landing: not governed: the seat lands it now ( |
Fixes #28309
Clause-②: no
Metadata-protocol: none
维护者速读
normalize-openapi新增--trim开关,配合--include-pattern只写出被匹配的操作;两处文档同步。--trim时输出逐字节不变;回滚即 revert 本 PR。packages/connectors/connector-openapi/scripts/normalize-openapi.mts的trimPaths与第 4 步前的裁剪调用;其测试文件的--trim一节;content/docs/automation/connectors.mdx新段落。pnpm --filter @objectstack/connector-openapi exec vitest run scripts/normalize-openapi.test.ts,预期 20 个测试全部通过。What changes
scripts/normalize-openapi.mtsgains--trim(optiontrimonnormalizeOpenApi). With it, every path operation no--include-patternmatches, every path item left with no operation, andwebhooksare dropped before dereferencing, so only the kept operations are walked and nothing reachable only from a dropped operation reaches the output. A$refpath item is resolved (not walked) before its operations are selected. Theincludelist is computed exactly as before (same patterns, same importedoperationActionKey), and the printedsha256is still the hash of the bytes written, which are now the trimmed bytes. The summary gainstrimmedFrom(operations in the source) when trimming.--trimwith no--include-patternis refused (exit 1); a pattern matching nothing is refused as before.securitySchemesstay, as in the untrimmed path (they are referenced by name, never by$ref, and the provider does not read them); every other component was already dropped after inlining, and under--trimit is never reached from a dropped operation.content/docs/automation/connectors.mdx(the script's paragraph: the example command now carries--trim, and a new paragraph says what trimming writes and when to leave it off);content/docs/deployment/marketplace-handbook.mdx, the one README-section sentence that still described the normalizer as forthcoming now says how a declarative OpenAPI app produces its packaged document and which sha256 to record.src/**) does not change; the script stays a repository script (not infiles[], nobin), so this carriesskip-changeset.Why a separate
--trimflag, not trimming whenever--include-patternis givenincludelets an app widenincludelater by editing config alone; trimmed means widening requires re-running the script. Which one an app wants is the author's call, and the command line that produced the packaged bytes should say which one it was.connectors.mdx(the shelf pipeline is not built yet), so the flag costs nobody a migration; the example now uses--trim, which is what recipe 1 teaches (trim to the operations the app calls).Tests
scripts/normalize-openapi.test.ts, on the existing fixtures, a new--trimblock and one new CLI case:GetCustomers,GetCustomersCustomer,get_v1_balance), drops the unmatched POST from a path item whose GET is kept, has the sameincludelist as the untrimmed run, loads throughcreateOpenApiProviderFactorywith exactly those actions and no$refin the document or the materialized def;balancealone drops the customer path items and leaves no text reachable only from them (A customer.,Error response., the sharedlimitparameter,subscription), with zero cuts counted (only the kept operation was walked);operationId;$refpath item is resolved before selection (its siblingsummarykept) andwebhooksare dropped;--trimwith no pattern; a pattern matching nothing;--trimthe whole document is written, as before;--trim,bytesandsha256equal the written file's length andsha256of its bytes,operationsis 2 andtrimmedFromis 4;--trimalone exits 1 and writes nothing.Package test and typecheck (head 08bf282)
Ablation (one-off, committed fix first, restored)
node scripts/ablation-replace.mjsonnormalize-openapi.mts, anchorif (matches(patterns, { key: operationActionKey(...(hits 1 to 0, blob a2190cd6ea17 to 70610c5bb588) replaced by a condition that keeps every operation. The test file then readsTests 5 failed | 15 passed (20): the four trim selection cases and the CLI--trimcase went red; the refusal and control cases stayed green, as expected. Restored: blob equals HEAD (a2190cd6ea17) andgit diff HEADis empty. No build ordist/leg: the test imports the script from source.Acceptance notes
Measured once against the real Stripe document,
stripe/openapiopenapi/spec3.jsonat51610f5f(MIT; 8,317,513 bytes, sha2567cff4cc46d0654101a36a3302f7544640f5f73e4f3cad6f264f0e23c19fa1776), with the pattern^(GetCustomers|PostCustomers|GetCustomersCustomer|GetCharges|PostPaymentIntents|GetPaymentIntentsIntent)$at the default--max-depth 2:--trim(control)0ea3c37a0854ad2646a156404b1ef86cca57403855e3803cd4630601eb6fc7b2--trimtrimmedFrom612)08d6e40bccec707a0bfc355b1cbf936df29018c22e7be658d616683e501b13d4sha256sumof the trimmed file equals the printed hash;refsLeft0; cuts recursive 38, max-depth 1064, extension 240; the two runs print the sameincludelist.createOpenApiProviderFactorywith exactly the six actions and zero$refkeys in the text and in the materialized def.Verification
Derived gates (dispatch-gates --commands --repo objectstack-ai/objectstack, head 08bf282)
78 commands derived from the 4 changed paths; each run with its exit code captured before any pipe.
--ranreconciliation: 78 derived, 78 run, 0 NOT-MEASURED (a derived zero). On the first run (head e6e7833)check:skill-examplesandcheck:dual-build-cjs-loadsanswered exit 3 PREREQUISITE NOT MET (unbuilt sibling packages); after building the@objectstack/client-reactclosure both measured exit 0. Re-run in full on the final head 08bf282 (after merging origin/main): all 78 exit 0.Not run locally, by rule:
test:repo,pnpm lintand the other repo-wide scans (CI).Generated by Claude Code