Skip to content

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

Description

@objectstack-fleet

repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z

Row 2's contract front, split from epic #38750 (knowledge retrieval rerank), filed by the epic's holder, seat repo:objectstack#3 (7276605368). Row 1 (#38760) merged as PR #38764. Phase 1a's #38720 merged too, so the contract can go first; the rest of row 2 still waits on #38721, #38722 and #38745.

Authority: the maintainer's words quoted verbatim on #38750 (「有就用」, 「开了开关,一律重排」, 「立专题卡,交给3号座位」), 「全部同意」 for D1 to D6 (ruling comment 7276086125), and 「照常做,作为平台能力」.

Grade: p2 (the epic's grade) · area:ai · domain:spec · review at CONTRACT_REVIEW_TIER (published contract).

What

  • Add packages/spec/src/contracts/reranker.ts, mirroring packages/spec/src/contracts/embedder.ts:
    • IReranker { id; rerank(query, documents, opts?: { signal }) }, returning an array of { index, score };
    • RERANKER_SERVICE = 'reranker'.
  • Export it from packages/spec/src/contracts/index.ts beside the embedder.
  • Regenerate the spec artifacts the export moves (api-surface, export-origins, and any others the gates name).
  • Add a changeset for @objectstack/spec: a widening, so Clause-②: yes (widening).
  • The docblock states the ruled contract and no more:
    • the model always comes from the deployment, never from a source;
    • the 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.

Not in this card

Carried to row 2's body

From L2 nit N1 of #38764 (record 7279030801): row 2's acceptance must carry the epic's design lines. The service re-orders per source, by position, among that source's own places. The hit keeps its adapter score.

Acceptance

Activity

  1. added
    priority:p2
    pm:queue
    domain:spec
    area:ai
    on Nov 30, 2026
  2. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v

    Claim: PM loop round 1
    Session: session_01ADHkmPDtfMCw4FJfyFfQ7v
    Account: os-steve
    Branch: claude/issue-38772-reranker-contract
    Worktree: objectstack-issue-38772
    Domain: domain:spec
    Seat: repo:objectstack#3
    Area: o3-K (area:ai p1/p2, knowledge topic first). Kept in the zone as a rule 5 exception the seat granted in its zone order (o3-area-K.md, 13:37Z appendix): one new spec contract file, additive, L2 at CONTRACT_REVIEW_TIER run by the seat.
    File surface: new packages/spec/src/contracts/reranker.ts; packages/spec/src/contracts/index.ts (one export * from './reranker.js'; line, placed beside the knowledge contracts but NOT after the embedder.js line 81, where PR #38744 inserts its own line); a new type-level test packages/spec/src/contracts/reranker.test.ts; the spec artifacts the export moves, regenerated by their generators only (packages/spec/api-surface/contracts.json, packages/spec/export-origins/contracts.json, and any other one a gate names, listed in the report); .changeset/38772-*.md. Anything else ⇒ stop and report.
    Container & model: S, mode:subagent, model: opus (dispatch-gates --tier --repo objectstack-ai/objectstack: "Model tier — no path-derived mandate … floor sonnet · default opus · ceiling fable"), effort: medium
    Clause-②: yes (widening)
    Metadata-protocol: none
    Responsibility: the published contract package @objectstack/spec/contracts has no reranker contract | no existing type covers it (IEmbedder is text → vector; nothing names a reorder-by-query provider) | row 2's service step and row 3's client (#38750), which both resolve RERANKER_SERVICE; no reader today
    Thread-read: none
    Premise: holds (origin/main f576dee: no reranker file or export under packages/spec/src/contracts/; embedder.ts is the shape to mirror; #38720 merged, which the card names as the contract's only precondition)
    Pre-claim lane: domain:spec — packages/spec/src/contracts/** (spec family).
    Pre-claim deps: the card names #38720 only, merged. Row 1 (#38760, PR #38764) merged.
    Prior rulings read: check-prior-rulings.mjs --card 38772 --paths packages/spec/src/contracts/reranker.ts → term hits on ADR-0032 §4/§5, ADR-0055 §1, ADR-0059 §3, ADR-0068 D1, ADR-0076 D9, ADR-0080 §3, ADR-0082 §1/§6, ADR-0087 D1, none on rerankers; card thread 0 rulings. Direction carried: #38750 Design "Contract" line, D1 to D6 「全部同意」 (7276086125), and "Not in v1": no IReranker.model, no vendor preset list.
    Fold-or-serial: no fold; serial against PR #38744 on index.ts only. check-handover --inflight names one overlap, #38710 (claim 7272545883, baozhoutao, dir-wide packages/spec/src/contracts/). File-level the shared file is index.ts; #38744's hunk is one line after embedder.js (:81), this card's line goes elsewhere, and the generated api-surface/** / export-origins/** files are merge=os-regen. overlap-check.mjs runs before every push; on exit 1 this branch queues behind #38744 and rebases under the same name.
    Serial constraints cleared: no other in-flight claim or open PR touches reranker.ts; the one shared file is handled as above.

  3. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 30, 2026
  4. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    ContributorAuthor

    triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ

    Triage: first-touch (type only) · Feature · lane grade kept: p2 (inherits topic #38750) · domain:spec · area:ai · pm:dispatched (claimed by repo:objectstack#3).

    • Feature: a new published contract (IReranker, RERANKER_SERVICE), pre-authorised as a child of a ruled topic (D1–D6, 7276086125). Contract review at CONTRACT_REVIEW_TIER, as the body says.
  5. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v
    os-dev-report

    {
     "issue": 38772,
     "status": "done",
     "branch": "claude/issue-38772-reranker-contract",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/38778",
     "session": "session_01ADHkmPDtfMCw4FJfyFfQ7v",
     "premise_still_valid": true,
     "summary": "Added packages/spec/src/contracts/reranker.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, mirroring embedder.ts; the docblock states only the ruled contract (model from the deployment, never a source; resolved per search as adapters resolve the embedder; one call per search, at most 50 documents; caller passes an AbortSignal; index = position in documents + score). Exported from contracts/index.ts right after knowledge-service.js (not after embedder.js, PR #38744's spot; overlap-check clean against main and #38744). Regenerated api-surface/contracts.json and export-origins/contracts.json (+2 names each); gen:declaration-map wrote nothing. Changeset @objectstack/spec patch (Metadata-protocol: none sets patch per clause2-line.mjs) with Clause-2 yes (widening). No reader wired, no core-service-contracts.ts entry, no runtime change.",
     "tests": "At 7d0eea72: os-verify-lock 'pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 --project local src/contracts/reranker.test.ts src/contracts/core-service-contracts.test.ts && pnpm --filter @objectstack/spec typecheck' VERDICT command-exit 0 (Test Files 2 passed, Tests 13 passed; typecheck includes check:test-typecheck, which compiles the exported Assert<Eq> type pins). Reverse verification: committed first, then added model?: string and a topK option to IReranker; check:test-typecheck exit 1 with 3 type errors in reranker.test.ts; restored with git restore --source=HEAD --staged --worktree, porcelain clean.",
     "gates": "dispatch-gates --commands --repo objectstack-ai/objectstack derived 90 at 7d0eea72; --ran reconciliation: 90 derived, 86 run exit 0, 4 NOT-MEASURED, 0 UNRUN. NOT MEASURED: check:doc-formula-expressions, check:dual-build-cjs-loads, check:lean-entry-closure (exit 3 PREREQUISITE NOT MET, other packages' dist not built); check:type-check-debt (the sequential gate loop was moved to background by the harness at the 10-min foreground cap and killed at the 30-min background cap at gate 86; the remaining four were rerun in the foreground, exit 0; type-check-debt left to CI). overlap-check.mjs VERDICT clean exit 0. CI check-runs not yet concluded at report time; not cited.",
     "mcp_calls": "0",
     "api_writes": "2 relay writes as objectstack-fleet[bot]: pr_create (POST /repos/objectstack-ai/objectstack/pulls draft + POST issues/38778/assignees os-steve) and this report comment (POST issues/38772/comments); plus git push of the branch",
     "classifier_refusals": [],
     "open_questions": [
      {
       "question": "The epic line spells opts?: { signal }; the contract types signal as optional inside the bag ({ signal?: AbortSignal }), per the PM shape note and fetch's RequestInit. Keep it optional or make it required inside opts?",
       "options": [
        "A keep signal optional (as shipped)",
        "B make signal required when opts is passed"
       ],
       "recommendation": "A, because the docblock already says the caller passes one and row 2's service is the only caller; B can be done at L2 for one line if the seat reads the ruling as required."
      }
     ],
     "security_findings": "withheld",
     "out_of_scope_findings": [
      "carrier: none · noted, not filed: the contract defines no order or completeness for rerank's answer (not ruled); row 2's service orders by position per the epic, so no guarantee was invented here."
     ]
    }
  6. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v
    os-dev-report

    {
      "issue": 38772,
      "status": "done",
      "branch": "claude/issue-38772-reranker-contract",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/38778",
      "head": "ef71650f678ddd38cf7f16b982e0c415cea4c3ab",
      "session": "session_01ADHkmPDtfMCw4FJfyFfQ7v",
      "premise_still_valid": true,
      "summary": "Fix round 1 from contract review 7282903130 and L1 7282806115, text only. Merged origin/main (8a7e65b4, clean, no generated-path conflicts) as 136f5b41, then ef71650f edits packages/spec/src/contracts/reranker.ts and .changeset/38772-reranker-contract.md. S1: the sentence 'A higher `score` means the document matches the query better. The caller ranks by `score`; the order of the returned array carries no meaning.' added verbatim to the Conventions list and to the `rerank` jsdoc (both places the review named), and to the changeset. N1: the interface docblock now reads '...resolves it per search, as knowledge adapters resolve the embedder. The reader lands with `retrieval.rerank` (#38750, row 2); until then nothing resolves this service.'; the changeset says the service 'is to resolve' the reranker and that the reader lands with row 2. N4: 'The caller makes one call per search and sends at most 50 documents.' (docblock and changeset). Interface shape, `signal?` optional, reranker.test.ts and generated files unchanged. Left as is (order said nothing else): the RERANKER_SERVICE docblock still says 'The knowledge service resolves this service per search' in convention present tense; the PR body was not edited.",
      "tests": "At 70eb0c83 (same tree as ef71650f; the amend changed only the commit message): `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/contracts/reranker.test.ts` -> Test Files 1 passed (1), Tests 2 passed (2), VERDICT command-exit 0. `pnpm --filter @objectstack/spec typecheck` (tsc --noEmit + check:scripts-typecheck + check:test-typecheck) -> VERDICT command-exit 0; 'check:test-typecheck: OK - @objectstack/spec's test layer compiles ... 131 pinned signature(s) held'. No ablation: no tested behaviour changed.",
      "gates": "Local, narrowed per the fix-round order (declared narrowing; the derived list names 90 commands, the rest belong to CI): check:changeset-fixed EXIT=0; check:changeset-gate-self-tests EXIT=0; check:empty-changeset EXIT=0 ('1 declaring changeset(s) added'); check-changeset-no-major EXIT=0 (no PR payload locally; Check Changeset on the PR is the verdict); check-nul-bytes EXIT=0; overlap-check EXIT=0 'VERDICT clean' (origin/main and #38744 merge cleanly). Spec build and gen:* not re-run: jsdoc-only edit, api-surface/export-origins rows are names only; CI Build Core and generated-artifact gates on ef71650f are the verdict, NOT MEASURED locally. Push hook check:commit-card-trailers refused the first push (model name in co-author trailer); amended the unpublished tip to the model-free pair, no force-push. PR check-runs on ef71650f: not yet read, CI convergence belongs to PM.",
      "mcp_calls": "0",
      "api_writes": "1 - POST issues/38772/comments (this report, via post-stamped.mjs); plus git push (not REST)",
      "classifier_refusals": [],
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [],
      "deviations": "Stale local branch claude/issue-38772-reranker-contract at 7d0eea72 (equal to the remote tip, no worktree holding it) made dev-worktree.sh refuse; deleted it with git branch -d and re-ran. Worktree removed after the push (rm node_modules, git worktree remove, no --force)."
    }
  7. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v
    os-dev-report

    {
      "issue": 38772,
      "status": "done",
      "branch": "claude/issue-38772-reranker-contract",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/38778",
      "head": "b11e9178e6193ac90308dffe48ed9ae8ce90229f",
      "session": "session_01ADHkmPDtfMCw4FJfyFfQ7v",
      "premise_still_valid": true,
      "summary": "Fix round 1, addendum from PM: the RERANKER_SERVICE docblock in packages/spec/src/contracts/reranker.ts now reads 'The knowledge service is to resolve this service per search, the way knowledge adapters resolve `EMBEDDER_SERVICE` (`./embedder.ts`); the deployment configures the reranker once, and no knowledge source names one. The reader lands with `retrieval.rerank` (#38750, row 2).' Nothing else in that docblock or anywhere else changed. Commit b11e9178 sits on ef71650f (the S1/N1/N4 commit). origin/main was already contained, so no new merge was made.",
      "tests": "At b11e9178: `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/contracts/reranker.test.ts` gave Tests 2 passed (2), VERDICT command-exit 0. `pnpm --filter @objectstack/spec typecheck` (incl. check:test-typecheck) gave VERDICT command-exit 0, with 'check:test-typecheck: OK ... 131 pinned signature(s)'. No ablation: no tested behaviour changed.",
      "gates": "Local at b11e9178: check-nul-bytes EXIT=0; overlap-check EXIT=0 'VERDICT clean' (origin/main 8a7e65b4 and #38744 both merge cleanly). The changeset was not touched this time, so the changeset checks were not re-run (they passed at ef71650f). Spec build and gen:* not re-run (jsdoc only): NOT MEASURED locally, CI on b11e9178 is the verdict. PR check-runs not read; CI convergence belongs to PM.",
      "mcp_calls": "0",
      "api_writes": "1 - POST issues/38772/comments (this report via post-stamped.mjs); plus git push (not REST)",
      "classifier_refusals": [],
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [],
      "deviations": "Recreating the worktree needed the local branch (left at ef71650f, equal to the remote tip) deleted with git branch -D. os-regen-merge.sh exited 1 with 'HEAD already contains origin/main', so there was no merge to make. The pin-base call kept its earlier pin at ef71650f. The worktree was removed after the push."
    }
  8. added a commit that references this issue on Dec 1, 2026
    fc198b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:aidomain:specpm:dispatchedpriority:p2

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions