@fenglimg/fabric-server 2.3.0-rc.1 → 2.3.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { FabExtractKnowledgeInput, FabExtractKnowledgeOutput, FabReviewInput, FabReviewOutput, FabPendingInput, FabPendingOutput } from '@fenglimg/fabric-shared/schemas/api-contracts';
3
- import { EventLedgerEventInput, EventLedgerEvent, RuleDescriptionIndexItem, LedgerEntry, AgentsMeta } from '@fenglimg/fabric-shared';
3
+ import { EventLedgerEventInput, EventLedgerEvent, RuleDescriptionIndexItem, RecallScore, RecallScoreBreakdown, LedgerEntry, AgentsMeta } from '@fenglimg/fabric-shared';
4
4
  import { PayloadGuardOptions } from '@fenglimg/fabric-shared/node/mcp-payload-guard';
5
5
 
6
6
  interface InFlightTracker {
@@ -394,6 +394,29 @@ interface Bm25Model {
394
394
  * query property).
395
395
  */
396
396
  scoreDoc(id: string, queryTerms: string[]): number;
397
+ /**
398
+ * P1 recall-engine-refactor (TASK-002): the plain JSON-safe snapshot of the
399
+ * corpus statistics this model scores against, attached so the model can be
400
+ * serialized to disk (`serializeBm25Model`) and a cold hook can `rehydrate`
401
+ * an identical scorer without re-tokenizing the corpus.
402
+ */
403
+ readonly __serialized: SerializedBm25Model;
404
+ }
405
+ interface SerializedBm25Model {
406
+ /** Schema/format version — bump on any layout change so a stale on-disk cache
407
+ * (different shape) is detected and discarded rather than mis-rehydrated. */
408
+ version: 1;
409
+ totalDocs: number;
410
+ /** term → document frequency (union-of-fields df), as [term, count] pairs. */
411
+ documentFrequency: [string, number][];
412
+ /** Per-field corpus average length. */
413
+ avgFieldLength: Record<Bm25Field, number>;
414
+ /** Per-doc stats: id → { per-field [term,freq] pairs, per-field length }. */
415
+ perDoc: {
416
+ id: string;
417
+ fieldTermFreq: Record<Bm25Field, [string, number][]>;
418
+ fieldLength: Record<Bm25Field, number>;
419
+ }[];
397
420
  }
398
421
  /**
399
422
  * Build a BM25F model over `docs`. Corpus statistics (per-field document
@@ -594,8 +617,10 @@ declare function reviewKnowledge(projectRoot: string, input: FabReviewInput): Pr
594
617
  * from `reviewKnowledge`. list browses the store-backed pending backlog;
595
618
  * search ranges over BOTH pending and canonical knowledge. Neither mutates
596
619
  * state — the fab_pending tool is registered readOnlyHint:true / idempotentHint:true.
597
- * The underlying listPending / searchEntries helpers are unchanged (verbatim
598
- * relocation), so behavior is identical to the prior fab_review list/search.
620
+ * P1 recall-engine-refactor (TASK-005): search now routes through `triageSearch`,
621
+ * which gates on the substring query then RANKS the matches via the shared
622
+ * rankDescriptionItems('triage') — NO top_k, NO floor, so pending review never
623
+ * silently drops a match. The old substring-only search machine is gone.
599
624
  */
600
625
  declare function reviewPending(projectRoot: string, input: FabPendingInput): Promise<FabPendingOutput>;
601
626
 
@@ -729,6 +754,7 @@ type PlanContextResult = {
729
754
  previous_revision_hash?: string;
730
755
  redirects?: Record<string, string>;
731
756
  related_appended?: Record<string, string>;
757
+ candidate_scores?: Map<string, RecallScore>;
732
758
  /** Internal service→tool signal; stripped before MCP output. */
733
759
  payload_trimmed?: boolean;
734
760
  /** Internal service→tool signal; stripped before MCP output. */
@@ -773,8 +799,10 @@ type RecallEntry = {
773
799
  alias: string;
774
800
  };
775
801
  body_in_context?: boolean;
802
+ score?: number;
803
+ score_breakdown?: RecallScoreBreakdown;
776
804
  };
777
- type RecallResult = Omit<PlanContextResult, "selection_token" | "payload_trimmed" | "payload_over_budget" | "entries" | "candidates"> & {
805
+ type RecallResult = Omit<PlanContextResult, "selection_token" | "payload_trimmed" | "payload_over_budget" | "entries" | "candidates" | "candidate_scores"> & {
778
806
  entries: RecallEntry[];
779
807
  directive: string;
780
808
  next_steps?: string[];