@cortexkit/opencode-magic-context 0.43.2 → 0.44.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/README.md +18 -2
- package/dist/config/index.d.ts +13 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/project-security.d.ts +6 -3
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +27 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-hyk9y29x.js → conflict-warning-hook-48f7np9d.js} +5 -5
- package/dist/{derive-budgets-b8ybssh9.js → derive-budgets-8kgevxmx.js} +2 -2
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-embedding.d.ts +3 -2
- package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/curate-category-rotation.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/failed-invocation-evidence.d.ts +13 -0
- package/dist/features/magic-context/dreamer/failed-invocation-evidence.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/lease.d.ts +5 -2
- package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/memory-claim-safety.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/module-apply.d.ts +1 -0
- package/dist/features/magic-context/dreamer/module-apply.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/retrospective-learnings.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +1 -1
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +2 -0
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts +19 -0
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/fail-closed-block.d.ts +7 -0
- package/dist/features/magic-context/fail-closed-block.d.ts.map +1 -1
- package/dist/features/magic-context/index.d.ts +1 -0
- package/dist/features/magic-context/index.d.ts.map +1 -1
- package/dist/features/magic-context/install-instance-id.d.ts +33 -0
- package/dist/features/magic-context/install-instance-id.d.ts.map +1 -0
- package/dist/features/magic-context/memory/constants.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/memory/single-store-embedding-drain.d.ts +35 -0
- package/dist/features/magic-context/memory/single-store-embedding-drain.d.ts.map +1 -0
- package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +23 -0
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts +7 -0
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +31 -8
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +40 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/session-decision-calibration.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +1 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +20 -5
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +1 -1
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage-notes.d.ts +1 -0
- package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
- package/dist/features/magic-context/storage-primers.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/storage-unavailable-reason.d.ts +17 -0
- package/dist/features/magic-context/storage-unavailable-reason.d.ts.map +1 -0
- package/dist/features/magic-context/storage.d.ts +1 -1
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/features/magic-context/store-generation-rebase.d.ts +33 -1
- package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
- package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/features/magic-context/types.d.ts +8 -3
- package/dist/features/magic-context/types.d.ts.map +1 -1
- package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +105 -9
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-parser.d.ts +2 -0
- package/dist/hooks/magic-context/compartment-parser.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +1 -0
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +2 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/context-limit-resolution.d.ts +31 -0
- package/dist/hooks/magic-context/context-limit-resolution.d.ts.map +1 -0
- package/dist/hooks/magic-context/embed-history-runner.d.ts +0 -1
- package/dist/hooks/magic-context/embed-history-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/format-embed-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-host-runner.d.ts +233 -0
- package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook.d.ts +1 -3
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/image-token-estimate.d.ts +9 -0
- package/dist/hooks/magic-context/image-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +60 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +6 -0
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-client.d.ts +21 -0
- package/dist/hooks/magic-context/module-client.d.ts.map +1 -0
- package/dist/hooks/magic-context/module-state-sync.d.ts +6 -2
- package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-tool-backends.d.ts +47 -0
- package/dist/hooks/magic-context/module-tool-backends.d.ts.map +1 -0
- package/dist/hooks/magic-context/module-transport.d.ts +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/persist-filtered-noise.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +12 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +35 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-refusal-recovery.d.ts +18 -0
- package/dist/hooks/magic-context/rust-refusal-recovery.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-served-m0.d.ts +20 -0
- package/dist/hooks/magic-context/rust-served-m0.d.ts.map +1 -0
- package/dist/hooks/magic-context/store-ahead-refusal.d.ts +40 -0
- package/dist/hooks/magic-context/store-ahead-refusal.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-content.d.ts +5 -5
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +19 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts +14 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-input-size.d.ts +21 -0
- package/dist/hooks/magic-context/tool-input-size.d.ts.map +1 -0
- package/dist/hooks/magic-context/tool-sweep-policy.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +124 -11
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +13 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-0ccmyzbj.js → index-01ft0h3p.js} +1 -1
- package/dist/{index-tdrv6nd0.js → index-2zf5fv89.js} +254 -61
- package/dist/{index-6j8th2hd.js → index-5f4qsnaq.js} +2 -2
- package/dist/{index-jgnag7sa.js → index-c906f3ff.js} +4 -4
- package/dist/{index-pa67brzn.js → index-cj5qe2nw.js} +3 -3
- package/dist/{index-febg06dy.js → index-dx0xnd4q.js} +1 -1
- package/dist/{index-bmzt6xgy.js → index-pye48m79.js} +1 -1
- package/dist/{index-g6hpfkqa.js → index-rdey8znw.js} +932 -261
- package/dist/{index-wgzyeyf5.js → index-tjq5jztd.js} +22 -6
- package/dist/{index-9r1cbh9e.js → index-v6wsttqt.js} +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3323 -1629
- package/dist/{message-time-backfill-0ccvyk9n.js → message-time-backfill-rm9wmcem.js} +3 -3
- package/dist/plugin/dream-timer.d.ts +2 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/plugin/native-compaction-guard.d.ts +22 -0
- package/dist/plugin/native-compaction-guard.d.ts.map +1 -0
- package/dist/plugin/rpc-handlers.d.ts +11 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{read-session-chunk-53a7qbrh.js → read-session-chunk-ktz5zt70.js} +5 -3
- package/dist/{recomp-orchestrator-adsgqgse.js → recomp-orchestrator-ahekzt0s.js} +8 -8
- package/dist/{safe-notification-target-vrkjrbgb.js → safe-notification-target-6w0esgd6.js} +2 -2
- package/dist/{send-session-notification-e28r4xx2.js → send-session-notification-w7xbnrsm.js} +4 -4
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/logger.d.ts.map +1 -1
- package/dist/shared/model-suggestion-retry.d.ts +13 -1
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/prompt-async-transport.d.ts +25 -0
- package/dist/shared/prompt-async-transport.d.ts.map +1 -0
- package/dist/shared/rpc-server.d.ts +1 -0
- package/dist/shared/rpc-server.d.ts.map +1 -1
- package/dist/shared/rpc-types.d.ts +16 -0
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/rpc-utils.d.ts +3 -0
- package/dist/shared/rpc-utils.d.ts.map +1 -1
- package/dist/shared/sqlite-write-locker-test-support.d.ts +7 -0
- package/dist/shared/sqlite-write-locker-test-support.d.ts.map +1 -0
- package/dist/shared/status-summary.d.ts +9 -1
- package/dist/shared/status-summary.d.ts.map +1 -1
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/shared/user-facing-codes.d.ts +10 -5
- package/dist/shared/user-facing-codes.d.ts.map +1 -1
- package/dist/shared/window-geometry.d.ts +6 -3
- package/dist/shared/window-geometry.d.ts.map +1 -1
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/v2/fold/boundary.d.ts +61 -0
- package/dist/v2/fold/boundary.d.ts.map +1 -0
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/hidden-completion.d.ts +16 -3
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts +45 -14
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +6 -0
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/rpc-live-state.d.ts +1 -1
- package/dist/v2/hooks/rpc-live-state.d.ts.map +1 -1
- package/dist/v2/hooks/rust-mode.d.ts +47 -0
- package/dist/v2/hooks/rust-mode.d.ts.map +1 -0
- package/dist/v2/hooks/session-project-backfill.d.ts +15 -0
- package/dist/v2/hooks/session-project-backfill.d.ts.map +1 -0
- package/dist/v2/hooks/storage-gate.d.ts +42 -0
- package/dist/v2/hooks/storage-gate.d.ts.map +1 -0
- package/dist/v2/hooks/storage-notice.d.ts +29 -0
- package/dist/v2/hooks/storage-notice.d.ts.map +1 -0
- package/dist/v2/hooks/store.d.ts +16 -0
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts +11 -2
- package/dist/v2/hooks/tools.d.ts.map +1 -1
- package/dist/v2/hooks/types.d.ts +4 -0
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/hooks/usage-persist.d.ts +31 -0
- package/dist/v2/hooks/usage-persist.d.ts.map +1 -0
- package/dist/v2/server.js +12216 -7963
- package/dist/v2/store-reader.d.ts +9 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/wrapup-orchestrator-9srk0kjf.js +18 -0
- package/package.json +1 -1
- package/src/agents/magic-context-prompt.ts +3 -3
- package/src/config/index.ts +40 -0
- package/src/config/misplaced-agent-model.test.ts +61 -0
- package/src/config/project-security.test.ts +17 -0
- package/src/config/project-security.ts +28 -4
- package/src/config/schema/magic-context.ts +29 -2
- package/src/shared/index.ts +1 -0
- package/src/shared/logger.test.ts +63 -2
- package/src/shared/logger.ts +23 -5
- package/src/shared/model-suggestion-retry.test.ts +115 -4
- package/src/shared/model-suggestion-retry.ts +57 -12
- package/src/shared/prompt-async-transport.test.ts +217 -0
- package/src/shared/prompt-async-transport.ts +242 -0
- package/src/shared/prompt-surface-a1-golden.md +8 -8
- package/src/shared/rpc-server.ts +13 -1
- package/src/shared/rpc-types.ts +17 -0
- package/src/shared/rpc-utils.ts +28 -0
- package/src/shared/sqlite-transaction-mode-guard.test.ts +198 -0
- package/src/shared/sqlite-write-locker-test-support.ts +62 -0
- package/src/shared/status-detail-text.test.ts +23 -0
- package/src/shared/status-summary.ts +25 -1
- package/src/shared/tag-transcript.ts +82 -19
- package/src/shared/user-facing-codes.ts +12 -5
- package/src/shared/window-geometry.ts +6 -3
- package/dist/v2/hooks/provider-admission.d.ts +0 -22
- package/dist/v2/hooks/provider-admission.d.ts.map +0 -1
- package/dist/wrapup-orchestrator-8xzbpvm8.js +0 -18
|
@@ -105,6 +105,15 @@ export declare class V2StoreReader {
|
|
|
105
105
|
*/
|
|
106
106
|
messagePage(sessionID: string, afterOrdinal: number, limit: number, finalWatermark: number): StoreRow[];
|
|
107
107
|
messageCount(sessionID: string): number;
|
|
108
|
+
/**
|
|
109
|
+
* One page of host sessions with the directory each was created in, in
|
|
110
|
+
* ascending id order after `afterSessionID` (exclusive; null starts at the
|
|
111
|
+
* beginning). Feeds the session-to-project backfill.
|
|
112
|
+
*/
|
|
113
|
+
sessionDirectoryPage(afterSessionID: string | null, limit: number): Array<{
|
|
114
|
+
sessionId: string;
|
|
115
|
+
directory: string;
|
|
116
|
+
}>;
|
|
108
117
|
storedMessageCount(sessionID: string): number;
|
|
109
118
|
messageById(sessionID: string, id: string): StoreRow | null;
|
|
110
119
|
messageExistsById(sessionID: string, id: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-reader.d.ts","sourceRoot":"","sources":["../../src/v2/store-reader.ts"],"names":[],"mappings":"AAOA,yFAAyF;AACzF,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,MAAM,CAAC,UAAwB,GACrC,MAAM,CAER;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,CAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,SAAW,EAClB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACrC,MAAM,CAER;AAGD,MAAM,MAAM,WAAW,GACjB,gBAAgB,GAChB,gBAAgB,GAChB,mBAAmB,GACnB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,OAAO,GACP,OAAO,GACP,WAAW,GACX,YAAY,GACZ,MAAM,CAAC;AAEb,eAAO,MAAM,iBAAiB,yEAOa,CAAC;AAI5C,eAAO,MAAM,mBAAmB,QAkBP,CAAC;AAC1B,MAAM,WAAW,WAAW;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,aAAa,CAAC;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAA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GAAG,SAAS;IAWrE,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS;IAW3D,8EAA8E;IAC9E,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE;IASrC;;;;OAIG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE;IAItC,OAAO,CAAC,GAAG;CAcd"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runManagedWrapup2
|
|
3
|
+
} from "./index-cj5qe2nw.js";
|
|
4
|
+
import"./index-rdey8znw.js";
|
|
5
|
+
import"./index-sd3egckz.js";
|
|
6
|
+
import"./index-01ft0h3p.js";
|
|
7
|
+
import"./index-c906f3ff.js";
|
|
8
|
+
import"./index-2zf5fv89.js";
|
|
9
|
+
import"./index-y5145x8k.js";
|
|
10
|
+
import"./index-pye48m79.js";
|
|
11
|
+
import"./index-v6wsttqt.js";
|
|
12
|
+
import"./index-jdxxq8cz.js";
|
|
13
|
+
import"./index-dx0xnd4q.js";
|
|
14
|
+
import"./index-tjq5jztd.js";
|
|
15
|
+
import"./index-6z9g64js.js";
|
|
16
|
+
export {
|
|
17
|
+
runManagedWrapup2 as runManagedWrapup
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -55,9 +55,9 @@ const BASE_INTRO = (
|
|
|
55
55
|
|
|
56
56
|
Think of your context as a desk. Every message and every tool output lands on it, and each item arrives with a §N§ tag (§1§, §42§) — the tag is the item's handle.
|
|
57
57
|
|
|
58
|
-
When an item no longer needs to stay on the desk for the work ahead, stamp it: \`ctx_reduce\` with its tag. Stamping does not remove anything — the item stays on the desk, fully readable. From time to time, when stamped items have piled up and the desk needs room, Magic Context clears them all in one sweep; you don't pick the moment, you only stamp. Stamp as soon as an item has served its purpose, not at the end of the turn, and do it silently: nobody wants to read "I'll drop these outputs". Never stamp a user message for what it asks of you; a large paste inside one is fine once you have used it.
|
|
58
|
+
When an item no longer needs to stay on the desk for the work ahead, stamp it: \`ctx_reduce\` with its tag. Stamping does not remove anything — the item stays on the desk, fully readable. From time to time, when stamped items have piled up and the desk needs room, Magic Context clears them all in one sweep; you don't pick the moment, you only stamp. Stamp as soon as an item has served its purpose, not at the end of the turn, and do it silently: nobody wants to read "I'll drop these outputs". An output is used once you've taken what you need from it into your reasoning or your answer. Never stamp a user message for what it asks of you; a large paste inside one is fine once you have used it.
|
|
59
59
|
|
|
60
|
-
Nothing stamped is ever lost. A cleared item goes to the archive — a recent one leaves a \`[dropped §N§]\` placeholder on the desk, an older one leaves nothing — and \`ctx_expand(message=N)\` brings it back whole: text, tool input, tool output. Now and then Magic Context leaves a short reminder on the desk saying how much unstamped material is lying around
|
|
60
|
+
Nothing stamped is ever lost. A cleared item goes to the archive — a recent one leaves a \`[dropped §N§]\` placeholder on the desk, an older one leaves nothing — and \`ctx_expand(message=N)\` brings it back whole: text, tool input, tool output. Now and then Magic Context leaves a short reminder on the desk saying how much unstamped material is lying around. A reminder means stamping is overdue: act on it in your next step. It isn't a warning about the desk's size. The desk never gets smaller for it.
|
|
61
61
|
|
|
62
62
|
${TOOL_HISTORY_GUIDANCE}
|
|
63
63
|
|
|
@@ -106,7 +106,7 @@ const BASE_INTRO_LIGHT = (
|
|
|
106
106
|
temporalAwarenessEnabled: boolean,
|
|
107
107
|
): string => `### Your desk
|
|
108
108
|
|
|
109
|
-
Your context is a desk. Every message and tool output lands on it with a §N§ tag as its handle. When an item no longer needs to stay for the work ahead, stamp it: \`ctx_reduce\` with its tag. Stamping removes nothing — the item stays readable; from time to time, when stamped items have piled up and the desk needs room, Magic Context clears them in one sweep (you only stamp, you don't pick the moment). Stamp as soon as an item has served its purpose, silently; never stamp a user message for what it asks (a used paste inside one is fine). Nothing is lost: a cleared item goes to the archive (a recent one leaves \`[dropped §N§]\`, an older one nothing) and \`ctx_expand(message=N)\` brings it back whole. Occasional reminders about unstamped material
|
|
109
|
+
Your context is a desk. Every message and tool output lands on it with a §N§ tag as its handle. When an item no longer needs to stay for the work ahead, stamp it: \`ctx_reduce\` with its tag. Stamping removes nothing — the item stays readable; from time to time, when stamped items have piled up and the desk needs room, Magic Context clears them in one sweep (you only stamp, you don't pick the moment). Stamp as soon as an item has served its purpose, silently; never stamp a user message for what it asks (a used paste inside one is fine). An output is used once you've taken what you need from it into your reasoning or your answer. Nothing is lost: a cleared item goes to the archive (a recent one leaves \`[dropped §N§]\`, an older one nothing) and \`ctx_expand(message=N)\` brings it back whole. Occasional reminders about unstamped material may appear. A reminder means stamping is overdue: act on it in your next step. It isn't a warning about the desk's size. The desk never gets smaller.
|
|
110
110
|
|
|
111
111
|
${TOOL_HISTORY_GUIDANCE_LIGHT}
|
|
112
112
|
|
package/src/config/index.ts
CHANGED
|
@@ -339,6 +339,45 @@ export function formatProtectedTokensBelowMinWarning(value: number): string {
|
|
|
339
339
|
return `protected_tokens is a token floor (minimum ${PROTECTED_TOKENS_MIN}, default derived from the context window); ${value} looks like the old protected_tags count. Remove the key to use the default, or set a token count such as 16000.`;
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
+
/** The blocks `resolveHistorianModel` and `resolveDreamerTaskModel` actually read. */
|
|
343
|
+
const MODEL_HARNESS_BLOCKS = ["opencode", "pi", "omp"] as const;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Warn when an agent's model is configured somewhere the resolver never looks.
|
|
347
|
+
*
|
|
348
|
+
* Agent models are resolved per harness: `historian.opencode.model`,
|
|
349
|
+
* `historian.pi.model`, `historian.omp.model`. A bare `historian.model` is
|
|
350
|
+
* schema-valid and reads naturally, but nothing consumes it —
|
|
351
|
+
* `resolveHistorianModel({historian:{model}}, "opencode")` returns no models at
|
|
352
|
+
* all, and the only outward sign is a historian that silently never runs (the
|
|
353
|
+
* Rust module reports it as `historian_no_fire=no_models`). Saying so at load
|
|
354
|
+
* time is the difference between a five-minute fix and a subsystem that looks
|
|
355
|
+
* configured and is not.
|
|
356
|
+
*/
|
|
357
|
+
export function misplacedAgentModelWarnings(rawConfig: Record<string, unknown>): string[] {
|
|
358
|
+
const warnings: string[] = [];
|
|
359
|
+
for (const agent of ["historian", "dreamer"]) {
|
|
360
|
+
const block = rawConfig[agent];
|
|
361
|
+
if (!block || typeof block !== "object" || Array.isArray(block)) continue;
|
|
362
|
+
const record = block as Record<string, unknown>;
|
|
363
|
+
if (!Object.hasOwn(record, "model")) continue;
|
|
364
|
+
const harnessWithModel = MODEL_HARNESS_BLOCKS.find((harness) => {
|
|
365
|
+
const sub = record[harness];
|
|
366
|
+
return (
|
|
367
|
+
sub !== null &&
|
|
368
|
+
typeof sub === "object" &&
|
|
369
|
+
!Array.isArray(sub) &&
|
|
370
|
+
Object.hasOwn(sub as Record<string, unknown>, "model")
|
|
371
|
+
);
|
|
372
|
+
});
|
|
373
|
+
if (harnessWithModel) continue;
|
|
374
|
+
warnings.push(
|
|
375
|
+
`${agent}.model is not read: the ${agent} model is resolved per harness, so it has to be ${agent}.opencode.model (OpenCode 1 and 2), ${agent}.pi.model, or ${agent}.omp.model. As written the ${agent} resolves to no models and never runs.`,
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
return warnings;
|
|
379
|
+
}
|
|
380
|
+
|
|
342
381
|
export function resetProtectedTagsDeprecationWarningForTest(): void {
|
|
343
382
|
warnedProtectedTagsDeprecation = false;
|
|
344
383
|
}
|
|
@@ -366,6 +405,7 @@ export function parsePluginConfig(
|
|
|
366
405
|
"protected_tags is deprecated and ignored; use protected_tokens instead.",
|
|
367
406
|
);
|
|
368
407
|
}
|
|
408
|
+
preMigrationWarnings.push(...misplacedAgentModelWarnings(rawConfig));
|
|
369
409
|
const migratedExperimental = migrateLegacyExperimental(
|
|
370
410
|
configWithoutRemovedAgent,
|
|
371
411
|
preMigrationWarnings,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/// <reference types="bun-types" />
|
|
2
|
+
|
|
3
|
+
import { describe, expect, it } from "bun:test";
|
|
4
|
+
import { resolveHistorianModel } from "../shared/model-resolution";
|
|
5
|
+
import { misplacedAgentModelWarnings, parsePluginConfig } from "./index";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A bare `historian.model` is schema-valid, reads naturally, and resolves to
|
|
9
|
+
* nothing. These tests pin both halves: that the resolver really does ignore it,
|
|
10
|
+
* and that the loader now says so instead of leaving the user with a subsystem
|
|
11
|
+
* that looks configured and never runs.
|
|
12
|
+
*/
|
|
13
|
+
describe("misplaced agent model warning", () => {
|
|
14
|
+
it("is what a top-level historian.model actually resolves to", () => {
|
|
15
|
+
// The premise, asserted rather than assumed: if this ever starts
|
|
16
|
+
// resolving, the warning below becomes wrong and should be deleted.
|
|
17
|
+
expect(resolveHistorianModel({ historian: { model: "openai/gpt-5" } }, "opencode")).toEqual(
|
|
18
|
+
{
|
|
19
|
+
primary: undefined,
|
|
20
|
+
fallbacks: [],
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("warns when the model sits outside every harness block", () => {
|
|
26
|
+
const warnings = misplacedAgentModelWarnings({ historian: { model: "openai/gpt-5" } });
|
|
27
|
+
expect(warnings).toHaveLength(1);
|
|
28
|
+
expect(warnings[0]).toContain("historian.model is not read");
|
|
29
|
+
expect(warnings[0]).toContain("historian.opencode.model");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("stays quiet when a harness block carries the model", () => {
|
|
33
|
+
expect(
|
|
34
|
+
misplacedAgentModelWarnings({
|
|
35
|
+
historian: { model: "openai/gpt-5", opencode: { model: "openai/gpt-5" } },
|
|
36
|
+
}),
|
|
37
|
+
).toEqual([]);
|
|
38
|
+
expect(
|
|
39
|
+
misplacedAgentModelWarnings({ historian: { opencode: { model: "openai/gpt-5" } } }),
|
|
40
|
+
).toEqual([]);
|
|
41
|
+
expect(misplacedAgentModelWarnings({})).toEqual([]);
|
|
42
|
+
expect(misplacedAgentModelWarnings({ historian: { disable: true } })).toEqual([]);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("covers the dreamer on the same rule", () => {
|
|
46
|
+
const warnings = misplacedAgentModelWarnings({ dreamer: { model: "openai/gpt-5" } });
|
|
47
|
+
expect(warnings).toHaveLength(1);
|
|
48
|
+
expect(warnings[0]).toContain("dreamer.model is not read");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("reaches the pinned config-warning channel", () => {
|
|
52
|
+
// configWarnings is what /ctx-status, the Pi session-start notice and
|
|
53
|
+
// doctor read, so landing here is what makes the warning visible.
|
|
54
|
+
const parsed = parsePluginConfig({ historian: { model: "openai/gpt-5" } });
|
|
55
|
+
expect(
|
|
56
|
+
(parsed.configWarnings ?? []).some((warning) =>
|
|
57
|
+
warning.includes("historian.model is not read"),
|
|
58
|
+
),
|
|
59
|
+
).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -225,6 +225,23 @@ describe("stripUnsafeProjectConfigFields", () => {
|
|
|
225
225
|
expect(warning).toContain("historian.pi.thinking_level");
|
|
226
226
|
});
|
|
227
227
|
|
|
228
|
+
it("strips the historian runner from project config so a repo cannot redirect the completion", () => {
|
|
229
|
+
const raw: Record<string, unknown> = {
|
|
230
|
+
historian: {
|
|
231
|
+
runner: "host",
|
|
232
|
+
opencode: { runner: "host" },
|
|
233
|
+
temperature: 0.2,
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const warnings = stripUnsafeProjectConfigFields(raw);
|
|
238
|
+
|
|
239
|
+
expect(raw.historian).toEqual({ opencode: {}, temperature: 0.2 });
|
|
240
|
+
const warning = warnings.join("\n");
|
|
241
|
+
expect(warning).toContain("historian.runner");
|
|
242
|
+
expect(warning).toContain("historian.opencode.runner");
|
|
243
|
+
});
|
|
244
|
+
|
|
228
245
|
it("strips mural.model from project config but keeps the feature switch", () => {
|
|
229
246
|
const raw: Record<string, unknown> = {
|
|
230
247
|
mural: { enabled: true, model: "repo-controlled-model" },
|
|
@@ -23,7 +23,17 @@ const HARNESS_KEYS = PER_HARNESS_MODEL_KEYS;
|
|
|
23
23
|
/** Every historian model-resolution field, including per-harness qualifiers.
|
|
24
24
|
* Variant and thinking_level merge onto the user's historian model at resolve
|
|
25
25
|
* time, so leaving them would let a cloned repo force extra spend. */
|
|
26
|
-
const HISTORIAN_USER_ONLY_FIELDS =
|
|
26
|
+
const HISTORIAN_USER_ONLY_FIELDS = [
|
|
27
|
+
...PER_HARNESS_MIGRATION_INVENTORY.historian.migrated_execution,
|
|
28
|
+
// `runner` chooses which process and which provider account runs the hidden
|
|
29
|
+
// historian completion. A cloned repo redirecting it would move that spend and
|
|
30
|
+
// that prompt text somewhere the user never agreed to.
|
|
31
|
+
"runner",
|
|
32
|
+
// `host_runner` turns this machine's pull loop on and off. A cloned repo
|
|
33
|
+
// turning it ON would start spending the user's provider account on folds for
|
|
34
|
+
// every project this process serves, not just its own.
|
|
35
|
+
"host_runner",
|
|
36
|
+
] as const;
|
|
27
37
|
const PROMPT_SURFACE_USER_ONLY_FIELDS = ["guidance_override_path", "tool_descriptions"] as const;
|
|
28
38
|
|
|
29
39
|
/**
|
|
@@ -348,10 +358,13 @@ function makeProjectThresholdWarning(field: string, reason: string): string {
|
|
|
348
358
|
* can opt its own runtime into the experimental Rust pipeline. The resolver
|
|
349
359
|
* requires trusted user-level `subc` configuration before Rust can activate.
|
|
350
360
|
* - historian model-resolution fields (model, fallback_models, variant,
|
|
351
|
-
* thinking_level)
|
|
352
|
-
* spend is user-level only. Qualifiers merge onto the user's historian
|
|
361
|
+
* thinking_level) and `runner`, including both per-harness blocks — historian
|
|
362
|
+
* model spend is user-level only. Qualifiers merge onto the user's historian
|
|
353
363
|
* model at resolve time, so a cloned repo cannot force extra thinking or
|
|
354
|
-
* variant cost
|
|
364
|
+
* variant cost, and cannot move the completion to a different process or
|
|
365
|
+
* provider account. `host_runner` is stripped for the same reason in the other
|
|
366
|
+
* direction: a repo must not switch this machine's pull loop on and start
|
|
367
|
+
* spending the user's provider account on folds.
|
|
355
368
|
* - `mural.model` at the top-level block, the legacy experimental spelling,
|
|
356
369
|
* and any nested `mural.model` under hidden agents — a cloned repo cannot
|
|
357
370
|
* choose where project memory is sent.
|
|
@@ -579,6 +592,17 @@ export function stripUnsafeProjectConfigFields(projectRaw: Record<string, unknow
|
|
|
579
592
|
}
|
|
580
593
|
}
|
|
581
594
|
|
|
595
|
+
// `dreamer.runner` chooses which process and which provider account runs the
|
|
596
|
+
// module-routed dreamer completions, for the same reason `historian.runner`
|
|
597
|
+
// is user-level only.
|
|
598
|
+
const dreamer = projectRaw.dreamer;
|
|
599
|
+
if (isPlainObject(dreamer) && "runner" in dreamer) {
|
|
600
|
+
delete dreamer.runner;
|
|
601
|
+
warnings.push(
|
|
602
|
+
"Ignoring dreamer.runner from project config (security: which process and provider account run dreamer completions is a user-level setting).",
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
|
|
582
606
|
const mural = projectRaw.mural;
|
|
583
607
|
if (isPlainObject(mural) && "model" in mural) {
|
|
584
608
|
delete mural.model;
|
|
@@ -624,6 +624,12 @@ const AgentMetadataSchema = AgentOverrideConfigSchema.pick({
|
|
|
624
624
|
|
|
625
625
|
/** Combined dreamer metadata plus independent strict execution blocks. */
|
|
626
626
|
export const DreamerConfigSchema = AgentMetadataSchema.extend({
|
|
627
|
+
runner: z
|
|
628
|
+
.enum(["broca", "host"])
|
|
629
|
+
.optional()
|
|
630
|
+
.describe(
|
|
631
|
+
'Which side runs the dreamer completions the Rust module routes (classify-memories) in Rust transform mode: "host" runs them on this process\'s carrier, "broca" routes them to the Broca module. When unset, historian.runner applies, and when that is unset too the harness decides the same way it does for the historian. User-level config only.',
|
|
632
|
+
),
|
|
627
633
|
opencode: DreamerOpenCodeHarnessBlockSchema.optional(),
|
|
628
634
|
pi: DreamerPiHarnessBlockSchema.optional(),
|
|
629
635
|
omp: DreamerOmpHarnessBlockSchema.optional(),
|
|
@@ -645,6 +651,25 @@ export const HistorianConfigSchema = AgentMetadataSchema.extend({
|
|
|
645
651
|
opencode: OpenCodeHarnessBlockSchema.optional(),
|
|
646
652
|
pi: PiHarnessBlockSchema.optional(),
|
|
647
653
|
omp: OmpHarnessBlockSchema.optional(),
|
|
654
|
+
runner: z
|
|
655
|
+
.enum(["broca", "host"])
|
|
656
|
+
.optional()
|
|
657
|
+
.describe(
|
|
658
|
+
'Which side runs the historian completion in Rust transform mode: "host" queues it for this process to run on the configured historian model, "broca" routes it to the Broca module. When unset the harness decides: OpenCode 1 and OpenCode 2 use "host", Claude Code (through the Thalamus gateway, which has no host to run a completion) uses "broca". User-level config only — it decides whose provider account pays for the call.',
|
|
659
|
+
),
|
|
660
|
+
host_runner: z
|
|
661
|
+
.object({
|
|
662
|
+
enabled: z
|
|
663
|
+
.boolean()
|
|
664
|
+
.optional()
|
|
665
|
+
.describe(
|
|
666
|
+
"Whether this process answers historian runs queued for a claimant (default true). Setting it to false stops the pull loop without changing historian.runner, so an operator can take one machine out of the lane and leave the queued runs for another claimant or for the runner setting to be changed deliberately.",
|
|
667
|
+
),
|
|
668
|
+
})
|
|
669
|
+
.optional()
|
|
670
|
+
.describe(
|
|
671
|
+
"Controls for this process's historian pull loop, which answers runs the Rust module queues for the host runner (`historian.runner: \"host\"`, or unset on OpenCode 1 and OpenCode 2). User-level config only — it decides whether this machine's provider account is spent on folds.",
|
|
672
|
+
),
|
|
648
673
|
two_pass: z
|
|
649
674
|
.boolean()
|
|
650
675
|
.default(false)
|
|
@@ -675,7 +700,7 @@ const BaseEmbeddingConfigSchema = z
|
|
|
675
700
|
.enum(["local", "openai-compatible", "off", "synapse"])
|
|
676
701
|
.default("local")
|
|
677
702
|
.describe(
|
|
678
|
-
"Embedding provider. 'local' uses Xenova/all-MiniLM-L6-v2, 'openai-compatible' requires endpoint and model, 'synapse' uses the certified local Synapse lane with an explicit fallback provider, and 'off' disables embeddings.",
|
|
703
|
+
"Embedding provider. 'local' uses Xenova/all-MiniLM-L6-v2, 'openai-compatible' requires endpoint and model, 'synapse' uses the certified local Synapse lane with an explicit fallback provider, and 'off' disables embeddings. Session history is embedded for semantic ctx_search whenever the provider is not 'off', regardless of memory.enabled; memories are embedded only while memory.enabled is true.",
|
|
679
704
|
),
|
|
680
705
|
fallback_provider: EmbeddingFallbackProviderSchema.optional().describe(
|
|
681
706
|
"Fallback provider for the Synapse lane. Required when provider is 'synapse'; local, openai-compatible, and off are valid.",
|
|
@@ -1413,7 +1438,9 @@ export const MagicContextConfigSchema = z
|
|
|
1413
1438
|
enabled: z
|
|
1414
1439
|
.boolean()
|
|
1415
1440
|
.default(true)
|
|
1416
|
-
.describe(
|
|
1441
|
+
.describe(
|
|
1442
|
+
"Enable cross-session memory (default: true). Does not affect history embedding or semantic ctx_search over session history; set embedding.provider to 'off' to stop all embedding.",
|
|
1443
|
+
),
|
|
1417
1444
|
injection_budget_tokens: z
|
|
1418
1445
|
.number()
|
|
1419
1446
|
.min(500)
|
package/src/shared/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./logger";
|
|
2
2
|
export * from "./model-suggestion-retry";
|
|
3
3
|
export * from "./normalize-sdk-response";
|
|
4
|
+
export * from "./prompt-async-transport";
|
|
4
5
|
export * from "./prompt-surface";
|
|
5
6
|
export * from "./prompt-surface-runtime";
|
|
6
7
|
export * from "./resolve-fallbacks";
|
|
@@ -30,6 +30,8 @@ type RotationScenarioResult = {
|
|
|
30
30
|
files: string[];
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
type RetryScenarioResult = { content: string; failed: number };
|
|
34
|
+
|
|
33
35
|
type HotPathScenarioResult = {
|
|
34
36
|
statCalls: number;
|
|
35
37
|
};
|
|
@@ -49,6 +51,16 @@ if (!root || !loggerModuleUrl || !scenario) {
|
|
|
49
51
|
const logPath = path.join(root, "nested", "magic-context.log");
|
|
50
52
|
process.env.MAGIC_CONTEXT_LOG_PATH = logPath;
|
|
51
53
|
let statCalls = 0;
|
|
54
|
+
if (scenario === "retry") {
|
|
55
|
+
let attempts = 0;
|
|
56
|
+
mock.module("node:fs", () => ({
|
|
57
|
+
...fs,
|
|
58
|
+
appendFileSync: (...args) => {
|
|
59
|
+
if (attempts++ === 0) throw new Error("injected transient write failure");
|
|
60
|
+
return fs.appendFileSync(...args);
|
|
61
|
+
},
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
52
64
|
if (scenario === "hot-path") {
|
|
53
65
|
mock.module("node:fs", () => ({
|
|
54
66
|
...fs,
|
|
@@ -61,7 +73,28 @@ if (scenario === "hot-path") {
|
|
|
61
73
|
|
|
62
74
|
const logger = await import(loggerModuleUrl);
|
|
63
75
|
|
|
64
|
-
if (scenario === "
|
|
76
|
+
if (scenario === "retry") {
|
|
77
|
+
logger.log("first buffered line");
|
|
78
|
+
logger.log("second buffered line");
|
|
79
|
+
logger.flushLogger();
|
|
80
|
+
const failed = logger.getLoggerDiagnostics().swallowedWriteCount;
|
|
81
|
+
logger.log("third buffered line");
|
|
82
|
+
logger.flushLogger();
|
|
83
|
+
console.log(JSON.stringify({ content: fs.readFileSync(logPath, "utf8"), failed }));
|
|
84
|
+
} else if (scenario === "oversized") {
|
|
85
|
+
logger.log("x".repeat(2_000_000));
|
|
86
|
+
logger.flushLogger();
|
|
87
|
+
console.log(JSON.stringify({ content: fs.readFileSync(logPath, "utf8"), failed: logger.getLoggerDiagnostics().swallowedWriteCount }));
|
|
88
|
+
} else if (scenario === "bounded") {
|
|
89
|
+
const failedPath = path.join(root, "unwritable-target");
|
|
90
|
+
fs.mkdirSync(failedPath);
|
|
91
|
+
process.env.MAGIC_CONTEXT_LOG_PATH = failedPath;
|
|
92
|
+
for (let i = 0; i < 100; i++) logger.log("line-" + i + "-" + "x".repeat(20_000));
|
|
93
|
+
logger.flushLogger();
|
|
94
|
+
process.env.MAGIC_CONTEXT_LOG_PATH = logPath;
|
|
95
|
+
logger.flushLogger();
|
|
96
|
+
console.log(JSON.stringify({ content: fs.readFileSync(logPath, "utf8"), failed: logger.getLoggerDiagnostics().swallowedWriteCount }));
|
|
97
|
+
} else if (scenario === "rotation") {
|
|
65
98
|
const maxLogBytes = 32 * 1024 * 1024;
|
|
66
99
|
fs.mkdirSync(path.dirname(logPath), { recursive: true });
|
|
67
100
|
fs.writeFileSync(logPath, Buffer.alloc(maxLogBytes, "o"));
|
|
@@ -144,7 +177,14 @@ afterEach(() => {
|
|
|
144
177
|
});
|
|
145
178
|
|
|
146
179
|
async function runLoggerScenario<T>(
|
|
147
|
-
scenario:
|
|
180
|
+
scenario:
|
|
181
|
+
| "recovery"
|
|
182
|
+
| "diagnostics"
|
|
183
|
+
| "rotation"
|
|
184
|
+
| "hot-path"
|
|
185
|
+
| "retry"
|
|
186
|
+
| "bounded"
|
|
187
|
+
| "oversized",
|
|
148
188
|
): Promise<T> {
|
|
149
189
|
const root = mkdtempSync(path.join(os.tmpdir(), "magic-context-logger-test-"));
|
|
150
190
|
scenarioRoots.push(root);
|
|
@@ -171,6 +211,27 @@ async function runLoggerScenario<T>(
|
|
|
171
211
|
}
|
|
172
212
|
|
|
173
213
|
describe("logger", () => {
|
|
214
|
+
test("retries the whole buffered batch after a transient append failure", async () => {
|
|
215
|
+
const result = await runLoggerScenario<RetryScenarioResult>("retry");
|
|
216
|
+
expect(result.failed).toBe(1);
|
|
217
|
+
expect(result.content).toContain("first buffered line");
|
|
218
|
+
expect(result.content).toContain("second buffered line");
|
|
219
|
+
expect(result.content).toContain("third buffered line");
|
|
220
|
+
});
|
|
221
|
+
test("reports a single oversized line even if no payload remains buffered", async () => {
|
|
222
|
+
const result = await runLoggerScenario<RetryScenarioResult>("oversized");
|
|
223
|
+
expect(result.content).toMatch(/logger dropped 1 line: buffer exceeded/);
|
|
224
|
+
expect(Buffer.byteLength(result.content)).toBeLessThan(1000);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
test("bounds failed batches and reports the number of discarded lines", async () => {
|
|
228
|
+
const result = await runLoggerScenario<RetryScenarioResult>("bounded");
|
|
229
|
+
expect(result.failed).toBeGreaterThan(0);
|
|
230
|
+
expect(Buffer.byteLength(result.content)).toBeLessThan(1_100_000);
|
|
231
|
+
expect(result.content).toMatch(/logger dropped \d+ lines: buffer exceeded/);
|
|
232
|
+
expect(result.content).toContain("line-99-");
|
|
233
|
+
});
|
|
234
|
+
|
|
174
235
|
test("recreates a log directory removed while the process is running", async () => {
|
|
175
236
|
const result = await runLoggerScenario<LoggerScenarioResult>("recovery");
|
|
176
237
|
|
package/src/shared/logger.ts
CHANGED
|
@@ -9,6 +9,16 @@ let buffer: string[] = [];
|
|
|
9
9
|
let flushTimer: ReturnType<typeof setTimeout> | null = null;
|
|
10
10
|
const FLUSH_INTERVAL_MS = 500;
|
|
11
11
|
const BUFFER_SIZE_LIMIT = 50;
|
|
12
|
+
const MAX_BUFFERED_BYTES = 1024 * 1024;
|
|
13
|
+
let bufferedBytes = 0;
|
|
14
|
+
let droppedLines = 0;
|
|
15
|
+
|
|
16
|
+
function boundBuffer(): void {
|
|
17
|
+
while (bufferedBytes > MAX_BUFFERED_BYTES && buffer.length > 0) {
|
|
18
|
+
bufferedBytes -= Buffer.byteLength(buffer.shift() ?? "");
|
|
19
|
+
droppedLines++;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
12
22
|
const MAX_LOG_FILE_BYTES = 32 * 1024 * 1024;
|
|
13
23
|
const SIZE_CHECK_INTERVAL_FLUSHES = 64;
|
|
14
24
|
|
|
@@ -141,11 +151,12 @@ function flush(): void {
|
|
|
141
151
|
clearTimeout(flushTimer);
|
|
142
152
|
flushTimer = null;
|
|
143
153
|
}
|
|
144
|
-
if (buffer.length === 0) return;
|
|
145
|
-
const
|
|
146
|
-
|
|
154
|
+
if (buffer.length === 0 && droppedLines === 0) return;
|
|
155
|
+
const notice = droppedLines
|
|
156
|
+
? `[${new Date().toISOString()}] [magic-context][global] logger dropped ${droppedLines} ${droppedLines === 1 ? "line" : "lines"}: buffer exceeded ${MAX_BUFFERED_BYTES} bytes while writes were pending\n`
|
|
157
|
+
: "";
|
|
147
158
|
try {
|
|
148
|
-
const data = capLogData(
|
|
159
|
+
const data = capLogData(notice + buffer.join(""));
|
|
149
160
|
const logFile = getMagicContextLogPath();
|
|
150
161
|
ensureDir(logFile);
|
|
151
162
|
let currentSize = getCurrentLogSize(logFile);
|
|
@@ -155,6 +166,9 @@ function flush(): void {
|
|
|
155
166
|
currentSize = 0;
|
|
156
167
|
}
|
|
157
168
|
fs.appendFileSync(logFile, data, { encoding: "utf8", mode: 0o600 });
|
|
169
|
+
buffer = [];
|
|
170
|
+
bufferedBytes = 0;
|
|
171
|
+
droppedLines = 0;
|
|
158
172
|
activeLogFile = logFile;
|
|
159
173
|
activeLogSize = currentSize + dataSize;
|
|
160
174
|
flushesSinceSizeCheck++;
|
|
@@ -163,6 +177,7 @@ function flush(): void {
|
|
|
163
177
|
activeLogSize = null;
|
|
164
178
|
flushesSinceSizeCheck = 0;
|
|
165
179
|
recordSwallowedWrite(error);
|
|
180
|
+
boundBuffer();
|
|
166
181
|
}
|
|
167
182
|
}
|
|
168
183
|
|
|
@@ -186,7 +201,10 @@ export function log(message: string, data?: unknown): void {
|
|
|
186
201
|
`${data.message}${data.stack ? `\n${data.stack}` : ""}`,
|
|
187
202
|
)}`
|
|
188
203
|
: ` ${JSON.stringify(sanitizeConfigValue(data))}`;
|
|
189
|
-
|
|
204
|
+
const line = `[${timestamp}] ${sanitizeDiagnosticText(message)}${serialized}\n`;
|
|
205
|
+
buffer.push(line);
|
|
206
|
+
bufferedBytes += Buffer.byteLength(line);
|
|
207
|
+
boundBuffer();
|
|
190
208
|
if (buffer.length >= BUFFER_SIZE_LIMIT) {
|
|
191
209
|
flush();
|
|
192
210
|
} else {
|