@crossworks/client-types 0.237.5 → 0.237.9
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/package.json +1 -1
- package/src/dto/rows.ts +88 -0
package/package.json
CHANGED
package/src/dto/rows.ts
CHANGED
|
@@ -738,6 +738,92 @@ export type SnapshotItem = {
|
|
|
738
738
|
heading?: string | null;
|
|
739
739
|
};
|
|
740
740
|
|
|
741
|
+
/** A context stage the decision trace names (ContextTrace). */
|
|
742
|
+
export type ContextTraceStage =
|
|
743
|
+
| 'embed'
|
|
744
|
+
| 'facts'
|
|
745
|
+
| 'prefs'
|
|
746
|
+
| 'hits'
|
|
747
|
+
| 'search'
|
|
748
|
+
| 'scoring'
|
|
749
|
+
| 'select'
|
|
750
|
+
| 'supersede'
|
|
751
|
+
| 'pruning'
|
|
752
|
+
| 'versions'
|
|
753
|
+
| 'journal'
|
|
754
|
+
| 'map'
|
|
755
|
+
| 'relations'
|
|
756
|
+
| 'digests'
|
|
757
|
+
| 'history';
|
|
758
|
+
|
|
759
|
+
/** What found a candidate: the vector arm, the keyword arm, both, the
|
|
760
|
+
* source note of a matching fact (promoted), always-on (preferences), the
|
|
761
|
+
* Journal tiers. */
|
|
762
|
+
export type ContextTraceArm = 'vector' | 'keyword' | 'both' | 'fact-source' | 'always' | 'journal';
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* One candidate a context stage touched (decision trace v1). Compact on
|
|
766
|
+
* purpose: ids, rounded numbers and reason codes, no text (the text is in the
|
|
767
|
+
* snapshot's sent/dropped lists, and on the node).
|
|
768
|
+
*/
|
|
769
|
+
export type ContextTraceRow = {
|
|
770
|
+
/** Block: fact, pref (preference), hit (content hit), chunk (passage), journal. */
|
|
771
|
+
b: 'fact' | 'pref' | 'hit' | 'chunk' | 'journal';
|
|
772
|
+
/** Item key: fact id, node id, or `nodeId:ordinal` for a passage. */
|
|
773
|
+
k: string;
|
|
774
|
+
/** The outcome for this turn's prompt. */
|
|
775
|
+
out: 'kept' | 'dropped';
|
|
776
|
+
/** The stage that decided the outcome. */
|
|
777
|
+
at: ContextTraceStage;
|
|
778
|
+
/** Reason code. Kept: `sent`, `promote:fact-source`, `always`. Dropped:
|
|
779
|
+
* `guard:0.85` and `cut:<d>` (distance cutoffs), `limit:<n>` (the block's
|
|
780
|
+
* budget cap), `room:promote` (gave its slot to a promoted passage),
|
|
781
|
+
* `judge:<t>` (a Jev score under the threshold), `dedupe:journal`,
|
|
782
|
+
* `dedupe:fact`, `superseded`, `version`, `type:<t>`, `shadow` (a Journal
|
|
783
|
+
* pick in shadow mode). */
|
|
784
|
+
why: string;
|
|
785
|
+
arm?: ContextTraceArm;
|
|
786
|
+
/** 1-based rank in the order the stage received it (search order). */
|
|
787
|
+
rank?: number;
|
|
788
|
+
/** Passages: 1-based rank in the vector arm / the keyword arm. */
|
|
789
|
+
vr?: number;
|
|
790
|
+
kr?: number;
|
|
791
|
+
/** Passages: forced into the tail by the keyword rescue floor. */
|
|
792
|
+
rescued?: true;
|
|
793
|
+
/** Raw cosine distance (Journal: 1 - similarity). */
|
|
794
|
+
d?: number | null;
|
|
795
|
+
/** The distance it was RANKED by (salience, recency), when it differs from `d`. */
|
|
796
|
+
rd?: number;
|
|
797
|
+
/** Jev score 0-3 (passage_scoring, context_pruning, journal_recall). */
|
|
798
|
+
s?: number;
|
|
799
|
+
/** A shadow use's verdict: what WOULD have happened. `out` is unchanged. */
|
|
800
|
+
would?: string;
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
/** Decision trace v1: per stage, what was considered, kept and dropped, and
|
|
804
|
+
* why. Recorded in the load_context snapshot and the search_chunks step.
|
|
805
|
+
* Observation only: it never changes what the model sees. */
|
|
806
|
+
export type ContextTrace = {
|
|
807
|
+
v: 1;
|
|
808
|
+
/** Stages in run order: candidates in, kept out, wall time. */
|
|
809
|
+
stages: Array<{ name: ContextTraceStage; in: number; out: number; ms: number; note?: string }>;
|
|
810
|
+
/** Passage search: pool size of each arm, and the keyword arm's gate. */
|
|
811
|
+
search?: {
|
|
812
|
+
mode: 'vector' | 'hybrid' | 'keyword';
|
|
813
|
+
vectorPool: number;
|
|
814
|
+
keywordPool: number;
|
|
815
|
+
/** `off` = no query text; `silent` = no rare term passed the gate;
|
|
816
|
+
* `and` = no rare term, every word ANDed; `rare` = the rare-term arm ran. */
|
|
817
|
+
keyword: 'off' | 'silent' | 'and' | 'rare';
|
|
818
|
+
/** The stemmed rare terms the keyword arm matched on (at most 8). */
|
|
819
|
+
terms?: string[];
|
|
820
|
+
};
|
|
821
|
+
rows: ContextTraceRow[];
|
|
822
|
+
/** Rows left out past the row cap (kept rows go first). */
|
|
823
|
+
more?: number;
|
|
824
|
+
ms: number;
|
|
825
|
+
};
|
|
826
|
+
|
|
741
827
|
export type ContextSnapshot = {
|
|
742
828
|
query: {
|
|
743
829
|
/** The inbound text as given to retrieval (snipped). */
|
|
@@ -761,6 +847,8 @@ export type ContextSnapshot = {
|
|
|
761
847
|
};
|
|
762
848
|
personaNotes: { count: number };
|
|
763
849
|
corpusMap: { count: number; truncated: boolean };
|
|
850
|
+
/** Decision trace v1 (absent on turns recorded before it). */
|
|
851
|
+
trace?: ContextTrace;
|
|
764
852
|
/** The decider's `context_pruning` use, when it ran on this turn. In
|
|
765
853
|
* `shadow` the counts say what WOULD have been dropped; in `live` they were.
|
|
766
854
|
* Absent when the use is off or the call failed (nothing changed). */
|