Skip to content

feat(spec): IReranker contract and RERANKER_SERVICE token - #38778

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-38772-reranker-contract
Nov 30, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-38772-reranker-contract

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v
Fixes #38772

Clause-②: yes (widening)
Metadata-protocol: none

维护者速读

  • 用户无感:开发者在规范包的契约入口里多了一个“重排器”接口和它的服务名,运行时行为不变。
  • 属于“知识检索重排”专题,先把重排器的契约立住,后续的知识服务重排步骤按它接入。
  • 目前没有任何代码读取它,出错也只影响类型声明,整个改动可直接撤回。
  • 无

What changes

  • New packages/spec/src/contracts/reranker.ts, mirroring embedder.ts: IReranker { readonly id: string; rerank(query: string, documents: string[], opts?: { signal?: AbortSignal }): Promise<Array<{ index: number; score: number }>> } and RERANKER_SERVICE = 'reranker' as const.
  • The docblock states the ruled contract and no more: the model always comes from the deployment, never from a knowledge source; the knowledge service resolves it per search, as adapters resolve the embedder; one call per search, at most 50 documents; the caller passes an AbortSignal for its time limit; each entry names a document by its position in documents plus the reranker's score. No order or completeness guarantee is stated (not ruled).
  • packages/spec/src/contracts/index.ts: one export * from './reranker.js'; line, placed right after knowledge-service.js (not after embedder.js, where feat(service-segmenter): a segmenter service that cuts a Chinese question into real words for the keyword leg #38744 inserts its own line; overlap-check.mjs reads both merges clean).
  • Regenerated by their generators: packages/spec/api-surface/contracts.json and packages/spec/export-origins/contracts.json (+2 names each). gen:declaration-map wrote nothing.
  • Changeset .changeset/38772-reranker-contract.md: @objectstack/spec patch (Metadata-protocol: none sets patch).
  • Not here: no IReranker.model, no vendor list, no reader, no core-service-contracts.ts entry (the embedder has none either), no runtime change.

Tests

  • packages/spec/src/contracts/reranker.test.ts: type-level pins (exported Assert<Eq<…>> aliases compiled by check:test-typecheck) for the member set (id | rerank only), readonly id, the exact parameter tuple, the options bag, optional opts, the Promise<Array<{ index; score }>> answer, the barrel re-export and the 'reranker' literal; plus two runtime cases.
  • Reverse verification: adding model?: string and a topK option to the interface turned check:test-typecheck red with 3 type errors in reranker.test.ts; restored from HEAD, clean.

Acceptance notes

  • opts.signal is typed optional ({ signal?: AbortSignal }), as fetch's RequestInit spells it; the epic's line writes opts?: { signal }. The docblock says the caller passes one.
  • Returned order and count are not defined by the contract (the ruling says index + score per document only); row 2's service orders by position.

Verification

Local gates

At head 7d0eea72. node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 90 commands; --ran reconciliation: 90 derived, 86 run (exit 0), 4 NOT MEASURED, 0 unrun.

  • Spec package: pnpm --filter @objectstack/spec typecheck (tsc, check:scripts-typecheck, check:test-typecheck) exit 0; vitest run --project local src/contracts/reranker.test.ts src/contracts/core-service-contracts.test.ts 2 files, 13 tests passed.
  • check:api-surface, check:export-origins, check:generated, check:authorable-surface, check:dual-source-exports, check:entry-nameability, check:exported-any, check:spec-docblock-symbol-anchors, check:changeset-no-major, check:empty-changeset, check:nul-bytes: exit 0 (all within the 86).
  • NOT MEASURED, to CI: check:doc-formula-expressions, check:dual-build-cjs-loads, check:lean-entry-closure (exit 3, prerequisite: other packages' dist not built here); check:type-check-debt (whole-workspace ratchet, not reached within the local time cap).
  • node scripts/pm/overlap-check.mjs: clean against origin/main and feat(service-segmenter): a segmenter service that cuts a Chinese question into real words for the keyword leg #38744.

Two-minute check: pnpm --filter @objectstack/spec exec vitest run --project local src/contracts/reranker.test.ts prints 2 passed.

Read first: packages/spec/src/contracts/reranker.ts (the docblock is the contract text), then reranker.test.ts.


Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. ⚠️ 3 changed file(s) yielded no anchor (packages/spec/api-surface/contracts.json, packages/spec/export-origins/contracts.json, packages/spec/src/contracts/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

What this run could not see
  • 3 changed file(s) yielded no anchor (packages/spec/api-surface/contracts.json, packages/spec/export-origins/contracts.json, packages/spec/src/contracts/index.ts) — pages documenting those are invisible to this run
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 182 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 16aa8b97bcde4da5b3de08814f7e9ed4b8c966d0 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 66ce546b1f1361c8941f331482953bff14005073 — the merge of head b11e9178e6193ac90308dffe48ed9ae8ce90229f into base 16aa8b97bcde4da5b3de08814f7e9ed4b8c966d0, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 66ce546b1f1361c8941f331482953bff14005073 && git checkout 66ce546b1f1361c8941f331482953bff14005073
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 16aa8b97bcde4da5b3de08814f7e9ed4b8c966d0 b11e9178e6193ac90308dffe48ed9ae8ce90229f && git checkout -B drift-repro 16aa8b97bcde4da5b3de08814f7e9ed4b8c966d0 && git merge --no-ff b11e9178e6193ac90308dffe48ed9ae8ce90229f

node scripts/docs-audit/affected-docs.mjs --json 16aa8b97bcde4da5b3de08814f7e9ed4b8c966d0

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v

Final head for review — zone o3-K · 2026-11-30T15:15Z
Head-sha: 7d0eea72881c6c851fa41783a6ff0a63df68cee5
CI: every check-run on this head is success or an expected skip (60 success, 13 skipped, 0 failed, 0 running). mergeable_state clean.
Contract: a new published spec contract (IReranker, RERANKER_SERVICE), Clause-②: yes (widening), kept in the zone as a rule 5 exception; L2 at CONTRACT_REVIEW_TIER by the seat. Open question from the dev report, left to the L2: opts?.signal is typed optional inside the options object; the epic's line spells opts?: { signal }. Serial: index.ts export placed after knowledge-service.js, clear of PR #38744's line; overlap-check clean against main and #38744. Next: L1 (L1-b).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmT9HTWLMN33WUVxVWB
L1-b, the seat's L1 thread · 2026-11-30T15:19Z · first review

席位核对

ACCEPT @ 7d0eea7 (card #38772; #38750 row 2, the contract half). The PR adds 6 files, +133/−0, all add-only.

What it adds

  • packages/spec/src/contracts/reranker.ts defines IReranker { readonly id; rerank(query, documents, opts?: { signal? }) → Promise<{ index, score }[]> } and RERANKER_SERVICE = 'reranker' as const.
  • Its shape mirrors embedder.ts. The barrel line goes after knowledge-service.js.
  • api-surface/contracts.json and export-origins/contracts.json each gain exactly the two rows.
  • Nothing else moves, so Clause-②: yes (widening), Metadata-protocol: none and spec patch match the diff.
  • Dogfood is not owed: there is no ! and no (narrowing) arm. That accounts for the face's only flag, the battery's skip.

Measured in a scratchpad worktree at this head

  • reranker.test.ts passes 2/2.
  • The type pins hold. Under check-test-typecheck --project tsconfig.test.json, the head reports no diagnostic on reranker. The run exits 1 for reasons outside this file; CI's TypeScript Type Check is green.
  • Two ablations each put a reranker diagnostic in that run:
    • opts made required;
    • a model? member added.
  • So the "exactly two members" and "opts optional" pins bind.
  • The question of whether signal is optional or required is left to L2, as the seat said.

Nit (N1). The changeset and the reranker.ts docblock say "the knowledge service resolves the reranker per search, as knowledge adapters resolve the embedder". The changeset's last line says "Nothing reads the contract yet". Both are read as conventions of the contract, but the first sentence is in the present tense about a reader that does not exist at this head. Wording such as "is to resolve" or "the knowledge service will resolve" would make it true of the tree. Fold it in if the head moves anyway.

Checks: Fixes #38772 is right; the card asks only for the contract and its token, and this delivers both. Check-runs at this head: 60 success, 13 skipped, 0 failure. mergeable_state is clean. Not governed. L2 is owed by the seat (rule-5 exception, claim 7280261872).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 7d0eea72881c6c851fa41783a6ff0a63df68cee5
Local-runs: none
Scope: packages/spec/src/contracts/index.ts, packages/spec/src/contracts/reranker.ts + packages/spec/src/contracts/reranker.test.ts
Security-touching: no
Rule-change-verified: none

PR #38778, card #38772 (the contract front of row 2 of epic #38750). Six files, +133 / -0, no existing line edited. Read: the card and its three comments (claim 7280261872, triage 7280869179, dev report 7281861708), the epic body (Design "Contract" line, Rulings 1 to 3, D1 to D6, "Not in v1") and its ruling records 7276086125 and 7276135635, the PR body, the net diff, the three source files at the head, packages/spec/src/contracts/embedder.ts and scripts/pm/clause2-line.mjs on main (9bb27620ba), and the check-runs on the head. Between the PR's base (bb8634726e) and main, nothing under packages/spec/src/contracts/, packages/spec/api-surface/contracts.json or packages/spec/export-origins/contracts.json changed.

① Derived judgments

  • Public surface: @objectstack/spec/contracts gains two names, IReranker (interface) and RERANKER_SERVICE (const, the literal 'reranker'). Right: these are the two names of the epic's Contract line, and no third.
  • IReranker against the Contract line, member by member. readonly id: string: right, spelled as IEmbedder.id. rerank(query: string, documents: string[], opts?: { signal?: AbortSignal }): right; the optional signal is decided under ③. The answer Promise<Array<{ index: number; score: number }>>: right. No model, no vendor preset, no topK, no second method: right ("Not in v1").
  • RERANKER_SERVICE = 'reranker' as const: right, the spelling of EMBEDDER_SERVICE. On main no other service token, file or export carries the name, so nothing collides.
  • Accept-set: none changes. No schema, no authorable key, no metadata type. Metadata-protocol: none is right.
  • Runtime: the barrel gains one export * line, which adds one constant to the runtime module. No file resolves the token, and no entry is added to core-service-contracts.ts. Right: the embedder has none there either, and the card says no reader is wired.
  • Barrel and generated rows: the line is in packages/spec/src/contracts/index.ts, the module that the package's ./contracts export serves. api-surface/contracts.json gains IReranker (interface) and RERANKER_SERVICE (const). export-origins/contracts.json gains both, each pointing to src/contracts/reranker.ts. Both files keep their sort order, and each row matches the source. Right.
  • Gate verdicts on the head: 73 check-runs, all completed; 60 are success, 13 are skipped, none failed. Check Changeset, Governed Surface Queue Guard, the PR-body guards, every Lint family, every Type Check family, Test Core, Build Core and Spec property liveness are success.

② Semver level

The changeset names @objectstack/spec at patch. That is the level the repository's rule sets: by scripts/pm/clause2-line.mjs, the level follows the metadata protocol alone, and none ("non-authorable internal types and interfaces, and every non-protocol change") takes patch. An additive service contract is such a change. Clause-②: yes (widening) is correct on the PR body and in the changeset: the diff adds two exports and removes or narrows nothing.

③ Boundary flags

open_questions in the dev report holds one entry.

  • opts?: { signal?: AbortSignal } or opts?: { signal: AbortSignal }. Decided: optional, as shipped. Reasons:
    • The epic's opts?: { signal } names the member and says nothing of its optionality, so neither spelling contradicts it.
    • opts is itself optional, so a required signal would not make a caller apply a time limit. The only call it would refuse is rerank(q, d, {}).
    • The 3 s limit is the service's: it builds one signal for its one call per search (D2). That is a rule for row 2's caller, and the docblock states it as one.
    • An implementation must handle a missing signal under either spelling, because opts can be absent. A fake in row 2's tests and a client in row 3 both satisfy either.
    • A later optional member can join the bag without forcing a signal on callers that have none.
    • embedder.ts gives no precedent: embed(texts) takes no options, and no contract under packages/spec/src names an AbortSignal on main.

Deviations and notes in the report, each answered:

  • The export line stands after knowledge-service.js, not after embedder.js: accepted. The card says "beside the embedder", and the line is two lines above it, in the same block. The reason given (PR feat(service-segmenter): a segmenter service that cuts a Chinese question into real words for the keyword leg #38744 inserts after embedder.js) holds for either merge order.
  • gen:declaration-map wrote nothing: consistent, the diff holds no schema.
  • Four gates not measured locally: closed by the check-runs on the head.
  • The out-of-scope note, "the contract defines no order or completeness for rerank's answer": not accepted as it stands for the direction of the score; see S1. Accepted for completeness; see N2.

SQL push-down: not applicable. The diff holds no query, no id materialisation and no join.

Security: neither hits path is under skills/** or ui/skills/**. No changed hunk states permission, sharing, credential, token or authentication behaviour.

④ Design judgment

packages/spec/src/contracts/reranker.ts

(1) Shape against the ruling: holds, as ① shows.

(2) The docblock against the ruled contract, sentence by sentence:

  • "The model always comes from the deployment, never from a knowledge source": Rulings item 1.
  • "the knowledge service resolves it per search, as knowledge adapters resolve the embedder": the Contract line. The comparison is true on main: knowledge-pgvector/src/plugin.ts resolves EMBEDDER_SERVICE inside a function that the adapter calls when it embeds, and knowledge-service-plugin.ts says "A consumer resolves EMBEDDER_SERVICE where it embeds, not at boot".
  • "One call per search, with at most 50 documents": the design's "Who reranks" line and Rulings item 3.
  • "The caller passes an AbortSignal (opts.signal) for its time limit": D2. The 3 s figure is left out, and rightly so: it is the service's constant, not the contract's.
  • "Each returned entry names one document by its position in the documents input": this is the meaning of index, which the type needs.
  • "the deployment configures the reranker once, and no knowledge source names one": Rulings item 1 again.

The docblock states nothing beyond the ruling. It states one thing too few, which is S1.

(3) Trying to break it. A reader of this file who writes the first implementation (row 3) and a reader who writes the first consumer (row 2) must reach the same ranking from the text alone. They cannot. The type gives score: number, and the text says "the score the reranker gave it". Nothing says whether a higher score is a better match, and nothing says whether the order of the array is the ranking. IEmbedder, which this file mirrors, states the matching rule for its own answer ("Output order MUST match input order exactly").

packages/spec/src/contracts/index.ts

One line, .js suffix as its neighbours, inside the knowledge block. Holds.

packages/spec/src/contracts/reranker.test.ts (implementing: the type-level pin)

It agrees with the contract, and it pins the shape:

  • MembersAreIdAndRerank pins the member set, so an added model fails the type check.
  • IdIsReadonly uses an identity-style equality that tells readonly apart.
  • RerankTakesQueryDocumentsOpts pins the parameter tuple with its optional third place, and OptsCarryOnlyASignal pins the bag.
  • OptsAreOptional pins that rerank(query, documents) is a call.
  • RerankAnswersIndexAndScore pins the answer.
  • BarrelExportsTheContract and TokenIsTheLiteral pin the export route and the literal.

The pins are compiled by check:test-typecheck, which is inside "Type Check · source gates" (success on the head). The runtime fixture gives the first document the highest score; that is the direction S1 asks the docblock to state.

Findings.

  • S1 (should-fix) — packages/spec/src/contracts/reranker.ts does not say which way score orders. An implementation whose larger score means a worse match satisfies this contract, and so does one that returns the best match first with scores a consumer must not sort by. Row 2's service has to rank from this answer, and row 3's client and row 2's fake are written against this text. The epic does not rule the direction because it takes it as read: its wire format is relevance_score. So the sentence is the meaning of a ruled member, not a new decision. Fix, in the rerank jsdoc and the Conventions list: "A higher score means the document matches the query better. The caller ranks by score; the order of the returned array carries no meaning." The second sentence may be dropped if the seat reads it as unruled; the first may not. No type changes, so the test and the generated rows stand.

  • N1 (nit) — The docblock and the changeset speak in the present tense ("a deployment registers one implementation", "the knowledge service resolves it per search") while no registrar and no reader exist on this head. This is not a misstatement of the contract: the two sentences state the convention each side of the contract follows, as embedder.ts does ("consumed by every knowledge adapter"), and the changeset ends with "Nothing reads the contract yet, and no runtime behaviour changes." The source file carries no such sentence, and it is what ships in the type declarations. Wording, if the head moves for S1: in the interface docblock, "…and the knowledge service resolves it per search, as knowledge adapters resolve the embedder. The reader lands with retrieval.rerank (专题:知识检索重排(rerank):知识源开关 + 部署配置模型,开了就一律重排 #38750, row 2); until then nothing resolves this service." Row 2 removes that last sentence. Otherwise an accepted deviation.

  • N2 (nit) — Completeness is not defined: the contract does not say that every document gets an entry, or that an index appears once and is in range. Leaving it out is right here; it is not ruled, and row 3's wire format has top_n. Follow-up, not a change here: row 2's card should carry as acceptance that the service does not trust the answer. A missing, repeated or out-of-range index must not drop or double a hit, and the card names what the service does then (adapter order for the units not named, or the failed marker).

  • N3 (nit) — The docblock says the caller passes a signal, and does not say what an implementation does when it aborts. D2 needs the service to answer inside 3 s whether or not the implementation honours the signal. Follow-up for row 2: the service bounds the call with its own timer as well, and a test covers a fake that ignores the signal.

  • N4 (nit) — "at most 50 documents" stands in the interface docblock without a subject. It is the caller's ceiling (Rulings item 3), not a limit an implementation may enforce by refusing. "The caller makes one call per search and sends at most 50 documents" removes the doubt. Fold into the S1 edit if the head moves; otherwise an accepted deviation.

Implemented-by: claude/issue-38772-reranker-contract
Reviewed-by: session_01ADHkmSAjFEZHRpRq3WCj6z

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v

Final head for review — zone o3-K · 2026-11-30T16:09Z
Head-sha: b11e9178e6193ac90308dffe48ed9ae8ce90229f
CI: every check-run on this head is success or an expected skip (60 success, 13 skipped, 0 failed, 0 running). mergeable_state clean. (The red aggregators on the intermediate head ef71650f were lanes cancelled by the next push; that head is superseded.)
Round 1 (answers contract review 7282903130 and L1 nit 7282806115; dev reports on #38772), text only: S1, the docblock and the changeset say a higher score means a better match, the caller ranks by score, and the returned order carries no meaning; N1, the interface and RERANKER_SERVICE docblocks and the changeset no longer state a reader in the present tense ("is to resolve"; the reader lands with retrieval.rerank, #38750 row 2); N4, "at most 50 documents" is the caller's limit. signal stays optional as ruled. The interface shape, reranker.test.ts and the generated files are unchanged. Next: L1 delta (L1-b), then the seat's L2 delta.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmT9HTWLMN33WUVxVWB
L1-b, the seat's L1 thread · 2026-11-30T16:12Z · delta review

席位核对

ACCEPT @ b11e917 (card #38772). This is the delta from my ACCEPT 7282806115 @7d0eea72. It has three commits: a merge of main 8a7e65b4 (136f5b4) and two wording commits (ef71650, b11e917). The wording answers the seat's L2 7282903130 and my N1.

The merge is clean. Against each side's merge base, the PR touches the same 6 files. The patch is identical in every one except the two this round edits on purpose, .changeset/38772-reranker-contract.md and reranker.ts. contracts.json (api-surface, export-origins) and reranker.test.ts are unchanged.

The wording, read against the code. These are docblock and changeset sentences only; the interface shape does not move.

  • S1. "A higher score means the document matches the query better. The caller ranks by score; the order of the returned array carries no meaning." This now appears on the interface docblock, on rerank, and in the changeset. It is a stated convention, and nothing in the type contradicts it.
  • N1. Both docblocks and the changeset now place the reader in the future. The changeset says "is to resolve", and "that reader lands with retrieval.rerank (专题:知识检索重排(rerank):知识源开关 + 部署配置模型,开了就一律重排 #38750, row 2)". The interface docblock adds "until then nothing resolves this service", and RERANKER_SERVICE says "is to resolve". They agree with the changeset's own last line, "Nothing reads the contract yet". The interface docblock's first sentence keeps "resolves" in the present tense, but the next sentence qualifies it, so it does not mislead.
  • N4. "The caller makes one call per search and sends at most 50 documents" puts the limit on the caller, as the card's convention means.
  • signal stays optional, as ruled; the type pin OptsCarryOnlyASignal is unchanged.

Not re-run: the type pins and reranker.test.ts. No code, generated file or test moved since my measured run at 7d0eea7 (2/2, with ablations on opts-required and an extra member, each reporting reranker).

Checks at this head (filter=all): 60 success, 13 skipped, 0 failure. mergeable_state is clean. The red at the intermediate head ef71650 was a cancelled run, superseded. L2: the seat's delta on this head is owed. Not governed.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: b11e9178e6193ac90308dffe48ed9ae8ce90229f
Local-runs: none
Scope: packages/spec/src/contracts/index.ts, packages/spec/src/contracts/reranker.ts + packages/spec/src/contracts/reranker.test.ts
Security-touching: no
Rule-change-verified: none

Delta review of PR #38778 (card #38772), from record 7282903130 on 7d0eea7288 to this head. Read: the compare of the two heads (10 commits, 95 files), the three commits that are this branch's own (136f5b4149, ef71650f67, b11e9178e6), reranker.ts and the changeset at the head, the PR's file list against its new base (8a7e65b438), the two dev reports of the fix round (7283143388, 7283271472), L1's delta record 7284299955, and the check-runs on the head.

① Derived judgments

  • What moved in this PR's own files: two, both prose. packages/spec/src/contracts/reranker.ts (+14 / -6, comment lines only) and .changeset/38772-reranker-contract.md (+1 / -1, the body paragraph). ef71650f67 touches those two files and b11e9178e6 touches reranker.ts alone.
  • What did not move: index.ts, reranker.test.ts, api-surface/contracts.json and export-origins/contracts.json are absent from the compare, so they are identical to the reviewed head. Lines 35 to 39 and 50 of reranker.ts, the signature and the token, are unchanged. Right: no type, no export and no generated row changes, so ① of record 7282903130 stands as written.
  • The merge of main (136f5b4149, up to 8a7e65b438): it brings 93 files, and none is under packages/spec/src/contracts/. embedder.ts, which the contract mirrors, is not among them. Neither is scripts/pm/clause2-line.mjs, which sets the semver level, nor either contracts.json. The spec files it does bring are data/object.*, two compose tests and the generated data.json and liveness rows for object and knowledge_source; this PR's files read none of them. The PR's file list against the new base is the same six files, with reranker.ts at +50.
  • The merge also brings the service files that row 2 will edit (knowledge-service-search.ts, knowledge-retrieval-mode.ts). They do not resolve RERANKER_SERVICE, so "until then nothing resolves this service" is true on this head.
  • Nothing moved undeclared. The two dev reports name exactly these two files and these sentences, and the compare shows no other change of this branch's own.
  • Gate verdicts on the head: 73 check-runs, all completed; 60 are success, 13 are skipped, none failed.

② Semver level

Holds. The changeset still names @objectstack/spec at patch with Metadata-protocol: none, and its front matter and both declaration lines are unchanged. The rule file did not move in the merge. Clause-②: yes (widening) is correct in the changeset and on the PR body: the published surface on this head is the same two added exports, and the fix round narrows nothing. The added sentences bind a future implementation and a future caller of a contract that no release has published, so no existing consumer is narrowed.

③ Boundary flags

  • open_questions: none new. The signal question was decided in record 7282903130 (optional), and opts?: { signal?: AbortSignal } is unchanged, as is its pin OptsCarryOnlyASignal.
  • Declared in the fix round, each confirmed: the merge of main is clean, the S1 sentence is added in the two places the record named and in the changeset, N1 and N4 are reworded, and the RERANKER_SERVICE docblock follows in the second commit.
  • The red run on the intermediate head ef71650f67 that L1 mentions is not this head's. This head's check-runs are the verdicts, and none failed.

SQL push-down: not applicable. Security: no hits path is under skills/** or ui/skills/**, and no changed hunk states permission, sharing, credential, token or authentication behaviour.

④ Design judgment

packages/spec/src/contracts/reranker.ts

  • The Conventions list and the rerank jsdoc both carry "A higher score means the document matches the query better. The caller ranks by score; the order of the returned array carries no meaning." The two copies are word for word the same, and the changeset repeats them. An implementation and a consumer now reach the same ranking from the text. The sentence agrees with the type, with the test's fixture (the first document has the highest score), with the wire format ruled for row 3 (relevance_score), and with the epic's design: the service ranks a source's pooled units by this answer and places them by position.
  • The interface docblock now ends its opening paragraph with "The reader lands with retrieval.rerank (专题:知识检索重排(rerank):知识源开关 + 部署配置模型,开了就一律重排 #38750, row 2); until then nothing resolves this service." The token's docblock says "is to resolve" and names the same row. The sentence before, "a deployment registers one implementation … and the knowledge service resolves it per search", keeps the present tense as the statement of the convention, and the next sentence bounds it. A reader of the published declarations is not misled. Row 2 removes both "reader lands" sentences when it wires the reader; that belongs in its acceptance.
  • "The caller makes one call per search and sends at most 50 documents" gives the ceiling its subject. An implementation cannot read it as a limit it may enforce by refusing.
  • Every other sentence is as reviewed. The docblock still states nothing beyond the ruling and the meaning of its own members.

packages/spec/src/contracts/index.ts and packages/spec/src/contracts/reranker.test.ts: unchanged, and ④ of record 7282903130 stands. No pin needs to change, because no type changed.

Findings.

S1: closed

No must-fix, no should-fix.

  • N1 (nit) — closed by the two "reader lands" sentences and "is to resolve".
  • N4 (nit) — closed by "The caller makes one call per search and sends at most 50 documents."
  • N2 (nit) — unchanged, and correctly so: completeness of the answer is not ruled. Follow-up for row 2's card: the service does not trust the answer. A missing, repeated or out-of-range index must not drop or double a hit, and the card names what the service does then. With "the caller ranks by score" now stated, the card should also name the order of two units with equal scores (adapter order).
  • N3 (nit) — unchanged. Follow-up for row 2's card: the service bounds the call with its own timer as well as the signal, and a test covers a fake that ignores the signal.
  • N5 (nit) — new, for row 2's card only: the two sentences that say no reader exists must be removed in the change that wires the reader, in reranker.ts alone; the changeset is consumed at release.

Implemented-by: claude/issue-38772-reranker-contract
Reviewed-by: session_01ADHkmSAjFEZHRpRq3WCj6z

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v

Landing — zone o3-K · 2026-11-30T16:16Z

Probe Reading on head b11e9178e6193ac90308dffe48ed9ae8ce90229f
check-governed-merges --pr 38778 NOT governed; under the human-merge threshold; the generated api-surface/contracts.json and export-origins/contracts.json rows did not move in the fix round (L2 delta 7284376959 ①), and the merge of main brought no packages/spec/src/contracts/** change
CI check-runs 60 success, 13 skipped, 0 failed, 0 running; mergeable_state clean

L1 ACCEPT 7282806115 and delta ACCEPT 7284299955 (L1-b); contract review PASS 7282903130 and delta PASS 7284376959 (seat, CONTRACT_REVIEW_TIER). A widening, no !, no narrowing arm. State change: draft → ready, auto-merge armed; the card closes on merge via Fixes #38772. L2 nits N2, N3 and N5 are carried to the #38750 row 2 card's acceptance (zone order 15:25Z appendix).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 30, 2026 16:16
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit fc198b2 Nov 30, 2026
74 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-38772-reranker-contract branch November 30, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spec: the reranker contract — IReranker and RERANKER_SERVICE, mirroring the embedder contract (#38750 row 2, contract front)

2 participants