@danypops/jittor 0.13.0 → 0.14.0
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/constants.ts +5 -1
- package/src/domain/context-hub.ts +11 -1
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -132,4 +132,8 @@ export const CONTEXT_HUB_CONTRIBUTION_MAX_AGE_MS = 5 * MILLISECONDS_PER_MINUTE;
|
|
|
132
132
|
export const CONTEXT_HUB_CONTRIBUTION_DEDUP_LIMIT = 1_000;
|
|
133
133
|
/** Matches Papyrus's own CONTEXT_ESTIMATE_CHARACTERS_PER_TOKEN; kept independent since Jittor does not depend on the Papyrus package. */
|
|
134
134
|
export const CONTEXT_ESTIMATE_CHARACTERS_PER_TOKEN = 4;
|
|
135
|
-
|
|
135
|
+
/** Matches Papyrus's own CONTEXT_TREE_MAX_NODES: a bound on the message-history tree walk, independent of any other producer's own item-count bound (CONTEXT_HUB_MAX_ITEMS_PER_SEGMENT). */
|
|
136
|
+
export const CONTEXT_TREE_MAX_NODES = 50_000;
|
|
137
|
+
/** Pi's own documented compaction-reserve default (docs/compaction.md): headroom kept free for the model's response, subtracted from the model's contextWindow to get the real usable budget. */
|
|
138
|
+
export const CONTEXT_DEFAULT_RESERVE_TOKENS = 16_384;
|
|
139
|
+
export const CONTEXT_HUB_CONFIDENCE_TIERS = ["exact-tool", "exact-structural", "exact-cooperative", "correlated", "audited"] as const;
|
|
@@ -39,6 +39,14 @@ export interface ContextSegment {
|
|
|
39
39
|
estimatedTokens: number;
|
|
40
40
|
confidence: ContextConfidenceTier;
|
|
41
41
|
items?: ContextSegmentItem[];
|
|
42
|
+
/**
|
|
43
|
+
* True when this segment's size is genuinely unmeasured (not yet observed), as opposed to
|
|
44
|
+
* measured-and-actually-zero -- e.g. the base system prompt before the first observed turn.
|
|
45
|
+
* A display layer that hides zero-token rows to cut noise must NOT hide an unknown segment
|
|
46
|
+
* just because its placeholder value happens to be zero -- that would silently misrepresent
|
|
47
|
+
* "we don't know" as "there is nothing here".
|
|
48
|
+
*/
|
|
49
|
+
unknown?: boolean;
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
export interface ContextContribution {
|
|
@@ -86,7 +94,7 @@ export function validateContextSegment(value: unknown): ContextSegment {
|
|
|
86
94
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("context segment must be an object");
|
|
87
95
|
const input = value as Record<string, unknown>;
|
|
88
96
|
for (const key of Object.keys(input)) {
|
|
89
|
-
if (key !== "key" && key !== "label" && key !== "estimatedTokens" && key !== "confidence" && key !== "items") {
|
|
97
|
+
if (key !== "key" && key !== "label" && key !== "estimatedTokens" && key !== "confidence" && key !== "items" && key !== "unknown") {
|
|
90
98
|
throw new Error(`context segment contains unexpected field: ${key}`);
|
|
91
99
|
}
|
|
92
100
|
}
|
|
@@ -94,11 +102,13 @@ export function validateContextSegment(value: unknown): ContextSegment {
|
|
|
94
102
|
if (typeof confidence !== "string" || !CONTEXT_HUB_CONFIDENCE_TIERS.includes(confidence as ContextConfidenceTier)) {
|
|
95
103
|
throw new Error(`confidence must be one of ${CONTEXT_HUB_CONFIDENCE_TIERS.join(", ")}`);
|
|
96
104
|
}
|
|
105
|
+
if (input["unknown"] !== undefined && typeof input["unknown"] !== "boolean") throw new Error("segment.unknown must be a boolean");
|
|
97
106
|
const segment: ContextSegment = {
|
|
98
107
|
key: nonEmptyString(input["key"], "segment.key", CONTEXT_HUB_SEGMENT_KEY_MAX_CHARACTERS),
|
|
99
108
|
label: nonEmptyString(input["label"], "segment.label", CONTEXT_HUB_SEGMENT_LABEL_MAX_CHARACTERS),
|
|
100
109
|
estimatedTokens: boundedInteger(input["estimatedTokens"], "segment.estimatedTokens"),
|
|
101
110
|
confidence: confidence as ContextConfidenceTier,
|
|
111
|
+
...(input["unknown"] !== undefined ? { unknown: input["unknown"] as boolean } : {}),
|
|
102
112
|
};
|
|
103
113
|
if (input["items"] !== undefined) {
|
|
104
114
|
if (!Array.isArray(input["items"])) throw new Error("segment.items must be an array");
|