clinkx 1.0.0 → 1.1.1
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/CHANGELOG.md +95 -0
- package/README.md +184 -112
- package/clinkx-workflows/dist/chairman-knobs.d.ts +24 -0
- package/clinkx-workflows/dist/chairman-knobs.js +27 -0
- package/clinkx-workflows/dist/chairman-knobs.js.map +1 -0
- package/clinkx-workflows/dist/clink-client.d.ts +10 -0
- package/clinkx-workflows/dist/clink-client.js +39 -1
- package/clinkx-workflows/dist/clink-client.js.map +1 -1
- package/clinkx-workflows/dist/config.d.ts +29 -1
- package/clinkx-workflows/dist/config.js +35 -2
- package/clinkx-workflows/dist/config.js.map +1 -1
- package/clinkx-workflows/dist/context-preflight.d.ts +5 -0
- package/clinkx-workflows/dist/context-preflight.js.map +1 -1
- package/clinkx-workflows/dist/council-execution-policy.d.ts +68 -0
- package/clinkx-workflows/dist/council-execution-policy.js +110 -0
- package/clinkx-workflows/dist/council-execution-policy.js.map +1 -0
- package/clinkx-workflows/dist/council-expander.d.ts +9 -8
- package/clinkx-workflows/dist/council-expander.js +18 -9
- package/clinkx-workflows/dist/council-expander.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/activity-contract.d.ts +5557 -4
- package/clinkx-workflows/dist/dashboard/activity-contract.js +55 -3
- package/clinkx-workflows/dist/dashboard/activity-contract.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/activity-reader.d.ts +9 -5
- package/clinkx-workflows/dist/dashboard/activity-reader.js +15 -2
- package/clinkx-workflows/dist/dashboard/activity-reader.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/api-routes.d.ts +4 -0
- package/clinkx-workflows/dist/dashboard/api-routes.js +133 -25
- package/clinkx-workflows/dist/dashboard/api-routes.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/context-builder-invocation-contract.d.ts +3865 -0
- package/clinkx-workflows/dist/dashboard/context-builder-invocation-contract.js +69 -0
- package/clinkx-workflows/dist/dashboard/context-builder-invocation-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/context-run-reader.d.ts +36 -2
- package/clinkx-workflows/dist/dashboard/context-run-reader.js +142 -19
- package/clinkx-workflows/dist/dashboard/context-run-reader.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/contracts.d.ts +20027 -480
- package/clinkx-workflows/dist/dashboard/contracts.js +133 -6
- package/clinkx-workflows/dist/dashboard/contracts.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/index.d.ts +4 -0
- package/clinkx-workflows/dist/dashboard/index.js +4 -0
- package/clinkx-workflows/dist/dashboard/index.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/invocation-contract.d.ts +786 -0
- package/clinkx-workflows/dist/dashboard/invocation-contract.js +201 -0
- package/clinkx-workflows/dist/dashboard/invocation-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/lazy-content.d.ts +14 -1
- package/clinkx-workflows/dist/dashboard/lazy-content.js +53 -2
- package/clinkx-workflows/dist/dashboard/lazy-content.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/native-transcript/contract.d.ts +90 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/contract.js +31 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/projection.d.ts +12 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/projection.js +286 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/projection.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/progress-report-contract.d.ts +147 -4
- package/clinkx-workflows/dist/dashboard/progress-report-contract.js +11 -11
- package/clinkx-workflows/dist/dashboard/progress-report-contract.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/progress-report-reader.js +4 -56
- package/clinkx-workflows/dist/dashboard/progress-report-reader.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.d.ts +2 -1
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.js +6 -5
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-contract.d.ts +194 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-contract.js +89 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-store.d.ts +26 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-store.js +102 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-store.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/request-admission.js +4 -0
- package/clinkx-workflows/dist/dashboard/request-admission.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/scanner.d.ts +3 -0
- package/clinkx-workflows/dist/dashboard/scanner.js +52 -8
- package/clinkx-workflows/dist/dashboard/scanner.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/server-factory.d.ts +14 -1
- package/clinkx-workflows/dist/dashboard/server-factory.js +73 -21
- package/clinkx-workflows/dist/dashboard/server-factory.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/session-log-contract.d.ts +223 -56
- package/clinkx-workflows/dist/dashboard/session-log-contract.js +26 -0
- package/clinkx-workflows/dist/dashboard/session-log-contract.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/session-log-journal.js +10 -3
- package/clinkx-workflows/dist/dashboard/session-log-journal.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/session-log-redaction.d.ts +9 -1
- package/clinkx-workflows/dist/dashboard/session-log-redaction.js +793 -59
- package/clinkx-workflows/dist/dashboard/session-log-redaction.js.map +1 -1
- package/clinkx-workflows/dist/dashboard-ui/assets/index-JPHQVtn9.js +106 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/style-DOMHk-j6.css +1 -0
- package/clinkx-workflows/dist/dashboard-ui/index.html +2 -2
- package/clinkx-workflows/dist/delegate-finalizer-policy.d.ts +26 -0
- package/clinkx-workflows/dist/delegate-finalizer-policy.js +72 -0
- package/clinkx-workflows/dist/delegate-finalizer-policy.js.map +1 -0
- package/clinkx-workflows/dist/delegate-signature.d.ts +14 -0
- package/clinkx-workflows/dist/delegate-signature.js +14 -0
- package/clinkx-workflows/dist/delegate-signature.js.map +1 -0
- package/clinkx-workflows/dist/delegate-validate.d.ts +32 -2
- package/clinkx-workflows/dist/delegate-validate.js +51 -0
- package/clinkx-workflows/dist/delegate-validate.js.map +1 -1
- package/clinkx-workflows/dist/engine.d.ts +113 -3
- package/clinkx-workflows/dist/engine.js +476 -80
- package/clinkx-workflows/dist/engine.js.map +1 -1
- package/clinkx-workflows/dist/errors.d.ts +22 -2
- package/clinkx-workflows/dist/errors.js +30 -2
- package/clinkx-workflows/dist/errors.js.map +1 -1
- package/clinkx-workflows/dist/fidelity.d.ts +47 -1
- package/clinkx-workflows/dist/fidelity.js +54 -1
- package/clinkx-workflows/dist/fidelity.js.map +1 -1
- package/clinkx-workflows/dist/fingerprint.d.ts +24 -6
- package/clinkx-workflows/dist/fingerprint.js +32 -9
- package/clinkx-workflows/dist/fingerprint.js.map +1 -1
- package/clinkx-workflows/dist/index.js +53 -1
- package/clinkx-workflows/dist/index.js.map +1 -1
- package/clinkx-workflows/dist/logger.d.ts +1 -1
- package/clinkx-workflows/dist/logger.js +17 -3
- package/clinkx-workflows/dist/logger.js.map +1 -1
- package/clinkx-workflows/dist/monotonic-clock.d.ts +19 -0
- package/clinkx-workflows/dist/monotonic-clock.js +22 -0
- package/clinkx-workflows/dist/monotonic-clock.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/contract.d.ts +52 -52
- package/clinkx-workflows/dist/plan-review/publication.d.ts +4 -4
- package/clinkx-workflows/dist/plan-review/run-state.d.ts +16 -16
- package/clinkx-workflows/dist/roster-contract.d.ts +889 -0
- package/clinkx-workflows/dist/roster-contract.js +180 -0
- package/clinkx-workflows/dist/roster-contract.js.map +1 -0
- package/clinkx-workflows/dist/rosters.d.ts +14 -0
- package/clinkx-workflows/dist/rosters.js +169 -0
- package/clinkx-workflows/dist/rosters.js.map +1 -0
- package/clinkx-workflows/dist/run-health.d.ts +7 -0
- package/clinkx-workflows/dist/run-health.js +25 -0
- package/clinkx-workflows/dist/run-health.js.map +1 -0
- package/clinkx-workflows/dist/schema.d.ts +64 -0
- package/clinkx-workflows/dist/schema.js +24 -0
- package/clinkx-workflows/dist/schema.js.map +1 -1
- package/clinkx-workflows/dist/server.js +2 -0
- package/clinkx-workflows/dist/server.js.map +1 -1
- package/clinkx-workflows/dist/shutdown.d.ts +15 -2
- package/clinkx-workflows/dist/shutdown.js +60 -16
- package/clinkx-workflows/dist/shutdown.js.map +1 -1
- package/clinkx-workflows/dist/state-schema.d.ts +23 -0
- package/clinkx-workflows/dist/state.d.ts +5 -0
- package/clinkx-workflows/dist/state.js +128 -21
- package/clinkx-workflows/dist/state.js.map +1 -1
- package/clinkx-workflows/dist/stdio-watchdog.d.ts +52 -0
- package/clinkx-workflows/dist/stdio-watchdog.js +212 -0
- package/clinkx-workflows/dist/stdio-watchdog.js.map +1 -0
- package/clinkx-workflows/dist/types.d.ts +6 -0
- package/clinkx-workflows/dist/validators/council.d.ts +50 -50
- package/clinkx-workflows/dist/validators/plan-review.d.ts +3 -3
- package/clinkx-workflows/dist/workflow-tools.d.ts +70 -0
- package/clinkx-workflows/dist/workflow-tools.js +760 -168
- package/clinkx-workflows/dist/workflow-tools.js.map +1 -1
- package/clinkx-workflows/templates/council/answer-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/answer-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/answer-specialist.txt +3 -0
- package/clinkx-workflows/templates/council/chairman.txt +3 -0
- package/clinkx-workflows/templates/council/code-review-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/code-review-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/code-review-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/debug-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/debug-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/debug-debugger.txt +3 -0
- package/clinkx-workflows/templates/council/discover-analyst.txt +3 -0
- package/clinkx-workflows/templates/council/discover-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/discover-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/member.txt +3 -0
- package/clinkx-workflows/templates/council/plan-review-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/plan-review-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/plan-review-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/reviewer.txt +3 -0
- package/clinkx-workflows/workflows/council-answer.yaml +3 -0
- package/clinkx-workflows/workflows/council-code-review.yaml +3 -0
- package/clinkx-workflows/workflows/council-debug.yaml +3 -0
- package/clinkx-workflows/workflows/council-default.yaml +7 -0
- package/clinkx-workflows/workflows/council-discover.yaml +3 -0
- package/clinkx-workflows/workflows/council-plan-review.yaml +3 -0
- package/conf/adapters/agy.json +9 -2
- package/conf/adapters/claude.json +7 -0
- package/conf/adapters/codex.json +7 -0
- package/conf/adapters/glm.json +19 -3
- package/conf/adapters/grok.json +9 -2
- package/conf/adapters/hapi/agy.json +9 -2
- package/conf/adapters/hapi/claude.json +7 -0
- package/conf/adapters/hapi/codex.json +7 -0
- package/conf/adapters/hapi/glm.json +20 -4
- package/conf/rosters/default-council.json +21 -0
- package/dist/activity-journal.d.ts +17 -3
- package/dist/activity-journal.js +404 -79
- package/dist/activity-journal.js.map +1 -1
- package/dist/codex/agent-tools.js +36 -0
- package/dist/codex/agent-tools.js.map +1 -1
- package/dist/codex/app-server-client.d.ts +3 -0
- package/dist/codex/app-server-client.js +11 -0
- package/dist/codex/app-server-client.js.map +1 -1
- package/dist/codex/app-server-registry.d.ts +18 -0
- package/dist/codex/app-server-registry.js +88 -2
- package/dist/codex/app-server-registry.js.map +1 -1
- package/dist/codex/client-types.d.ts +7 -1
- package/dist/codex/protocol.d.ts +4 -4
- package/dist/config.d.ts +220 -23
- package/dist/config.js +104 -1
- package/dist/config.js.map +1 -1
- package/dist/context-builder/bundle.d.ts +13 -0
- package/dist/context-builder/bundle.js +46 -0
- package/dist/context-builder/bundle.js.map +1 -1
- package/dist/context-builder/delegate-finalizer-effective.d.ts +33 -0
- package/dist/context-builder/delegate-finalizer-effective.js +82 -0
- package/dist/context-builder/delegate-finalizer-effective.js.map +1 -0
- package/dist/context-builder/delegate-packet.d.ts +18 -0
- package/dist/context-builder/delegate-packet.js +73 -9
- package/dist/context-builder/delegate-packet.js.map +1 -1
- package/dist/context-builder/delegate-reconstruction.d.ts +29 -0
- package/dist/context-builder/delegate-reconstruction.js +110 -41
- package/dist/context-builder/delegate-reconstruction.js.map +1 -1
- package/dist/context-builder/delegate-validation.d.ts +31 -0
- package/dist/context-builder/delegate-validation.js +87 -10
- package/dist/context-builder/delegate-validation.js.map +1 -1
- package/dist/context-builder/delegate.d.ts +9 -0
- package/dist/context-builder/delegate.js +210 -59
- package/dist/context-builder/delegate.js.map +1 -1
- package/dist/context-builder/diagnostics.d.ts +1 -1
- package/dist/context-builder/diagnostics.js.map +1 -1
- package/dist/context-builder/discovery-progress.d.ts +25 -0
- package/dist/context-builder/discovery-progress.js +64 -0
- package/dist/context-builder/discovery-progress.js.map +1 -0
- package/dist/context-builder/discovery-watchdog.d.ts +15 -0
- package/dist/context-builder/discovery-watchdog.js +39 -0
- package/dist/context-builder/discovery-watchdog.js.map +1 -0
- package/dist/context-builder/discovery.d.ts +7 -0
- package/dist/context-builder/discovery.js +119 -7
- package/dist/context-builder/discovery.js.map +1 -1
- package/dist/context-builder/external-gaps.d.ts +73 -0
- package/dist/context-builder/external-gaps.js +248 -0
- package/dist/context-builder/external-gaps.js.map +1 -0
- package/dist/context-builder/globs.d.ts +1 -0
- package/dist/context-builder/globs.js +15 -0
- package/dist/context-builder/globs.js.map +1 -1
- package/dist/context-builder/handler.d.ts +42 -1
- package/dist/context-builder/handler.js +690 -62
- package/dist/context-builder/handler.js.map +1 -1
- package/dist/context-builder/invocation-sidecar.d.ts +41 -0
- package/dist/context-builder/invocation-sidecar.js +189 -0
- package/dist/context-builder/invocation-sidecar.js.map +1 -0
- package/dist/context-builder/lifecycle-contract.d.ts +51 -51
- package/dist/context-builder/mutation-lock.d.ts +32 -0
- package/dist/context-builder/mutation-lock.js +321 -0
- package/dist/context-builder/mutation-lock.js.map +1 -0
- package/dist/context-builder/review-coverage.d.ts +32 -0
- package/dist/context-builder/review-coverage.js +130 -23
- package/dist/context-builder/review-coverage.js.map +1 -1
- package/dist/context-builder/schema.d.ts +76 -1
- package/dist/context-builder/schema.js +21 -1
- package/dist/context-builder/schema.js.map +1 -1
- package/dist/context-builder/secrets.d.ts +31 -0
- package/dist/context-builder/secrets.js +871 -84
- package/dist/context-builder/secrets.js.map +1 -1
- package/dist/context-builder/status.d.ts +1 -1
- package/dist/context-builder/status.js +1 -0
- package/dist/context-builder/status.js.map +1 -1
- package/dist/context-builder/storage.d.ts +29 -5
- package/dist/context-builder/storage.js +311 -236
- package/dist/context-builder/storage.js.map +1 -1
- package/dist/context-builder/versions.d.ts +19 -4
- package/dist/context-builder/versions.js +19 -4
- package/dist/context-builder/versions.js.map +1 -1
- package/dist/context-builder/workflow-runner.d.ts +6 -0
- package/dist/context-builder/workflow-runner.js +363 -173
- package/dist/context-builder/workflow-runner.js.map +1 -1
- package/dist/dashboard-adapter-catalog.js +7 -0
- package/dist/dashboard-adapter-catalog.js.map +1 -1
- package/dist/dashboard-cli.d.ts +2 -0
- package/dist/dashboard-cli.js +40 -2
- package/dist/dashboard-cli.js.map +1 -1
- package/dist/dashboard-companion/client.d.ts +1 -0
- package/dist/dashboard-companion/client.js +22 -3
- package/dist/dashboard-companion/client.js.map +1 -1
- package/dist/dashboard-companion/protocol.js +4 -1
- package/dist/dashboard-companion/protocol.js.map +1 -1
- package/dist/dashboard-gateway/index.d.ts +1 -0
- package/dist/dashboard-gateway/index.js +33 -2
- package/dist/dashboard-gateway/index.js.map +1 -1
- package/dist/handler.js +5 -1
- package/dist/handler.js.map +1 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +145 -7
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +18 -3
- package/dist/logger.js.map +1 -1
- package/dist/parsers/agy-stream-json.d.ts +14 -0
- package/dist/parsers/agy-stream-json.js +172 -0
- package/dist/parsers/agy-stream-json.js.map +1 -0
- package/dist/parsers/extract.js +5 -1
- package/dist/parsers/extract.js.map +1 -1
- package/dist/parsers/observed-invocation.d.ts +20 -0
- package/dist/parsers/observed-invocation.js +42 -0
- package/dist/parsers/observed-invocation.js.map +1 -0
- package/dist/pipeline.d.ts +13 -0
- package/dist/pipeline.js +60 -10
- package/dist/pipeline.js.map +1 -1
- package/dist/progress-report/lock.d.ts +74 -0
- package/dist/progress-report/lock.js +343 -0
- package/dist/progress-report/lock.js.map +1 -0
- package/dist/progress-report/schema.d.ts +808 -0
- package/dist/progress-report/schema.js +119 -0
- package/dist/progress-report/schema.js.map +1 -0
- package/dist/progress-report/store.d.ts +66 -0
- package/dist/progress-report/store.js +766 -0
- package/dist/progress-report/store.js.map +1 -0
- package/dist/progress-report/tools.d.ts +20 -0
- package/dist/progress-report/tools.js +141 -0
- package/dist/progress-report/tools.js.map +1 -0
- package/dist/prompt-mode.d.ts +1 -1
- package/dist/prompt-mode.js +7 -2
- package/dist/prompt-mode.js.map +1 -1
- package/dist/runner.d.ts +7 -0
- package/dist/runner.js +10 -3
- package/dist/runner.js.map +1 -1
- package/dist/safety.d.ts +50 -0
- package/dist/safety.js +182 -1
- package/dist/safety.js.map +1 -1
- package/dist/schema.d.ts +8 -0
- package/dist/schema.js +20 -0
- package/dist/schema.js.map +1 -1
- package/dist/server.d.ts +6 -1
- package/dist/server.js +94 -8
- package/dist/server.js.map +1 -1
- package/dist/session-log-stream.d.ts +1 -1
- package/dist/session-log-stream.js +280 -33
- package/dist/session-log-stream.js.map +1 -1
- package/dist/stdio-activity.d.ts +28 -0
- package/dist/stdio-activity.js +72 -0
- package/dist/stdio-activity.js.map +1 -0
- package/docs/configuration.md +426 -0
- package/docs/security.md +293 -0
- package/package.json +5 -5
- package/clinkx-workflows/dist/dashboard-ui/assets/index-DOkMXTfB.js +0 -25
- package/clinkx-workflows/dist/dashboard-ui/assets/style-ChJsn0KD.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/context-builder/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qCAAqC,GAEtC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,cAAc,GACf,MAAM,cAAc,CAAC;AAetB,MAAM,CAAC,MAAM,kDAAkD,GAC7D,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/context-builder/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qCAAqC,GAEtC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,cAAc,GACf,MAAM,cAAc,CAAC;AAetB,MAAM,CAAC,MAAM,kDAAkD,GAC7D,6BAA6B,CAAC;AAUhC,MAAM,UAAU,yBAAyB,CAAC,KAKzC;IACC,OAAO;QACL,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC;QACrE,MAAM,EAAE,kDAAkD;QAC1D,OAAO,EAAE,qCAAqC,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;QAC7E,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;KACvD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,QAAgD;IAEhD,OAAO,QAAQ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rC,CAAC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;IAE1D,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ContextBuilderDiscoveryMetrics } from "./discovery.js";
|
|
2
|
+
import type { ContextBuilderLifecycleController } from "./lifecycle-observer.js";
|
|
3
|
+
/** Discovery invokes the progress sink at most once per this many file boundaries. */
|
|
4
|
+
export declare const CONTEXT_BUILDER_SCAN_PROGRESS_EVERY_FILES = 250;
|
|
5
|
+
/** Minimum wall-clock gap between two published mid-scan transitions. */
|
|
6
|
+
export declare const CONTEXT_BUILDER_SCAN_PROGRESS_MIN_INTERVAL_MS = 2000;
|
|
7
|
+
export type ContextBuilderScanProgressPublisher = (metrics: Readonly<ContextBuilderDiscoveryMetrics>) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Throttled mid-scan lifecycle publisher for the discovery walk: turns
|
|
10
|
+
* sampled discovery metrics into `scanning → scanning` count transitions so a
|
|
11
|
+
* long scan stays observable in `state.json` and `workflow_run_status`.
|
|
12
|
+
*
|
|
13
|
+
* Emits at most once per {@link CONTEXT_BUILDER_SCAN_PROGRESS_EVERY_FILES}
|
|
14
|
+
* newly seen files AND {@link CONTEXT_BUILDER_SCAN_PROGRESS_MIN_INTERVAL_MS}
|
|
15
|
+
* apart. No final emission: the handler's `searching` transition publishes the
|
|
16
|
+
* authoritative end-of-scan counts.
|
|
17
|
+
*
|
|
18
|
+
* Fire-and-forget: the walk never awaits publication, and a rejected
|
|
19
|
+
* transition is swallowed here so it never becomes an unhandled rejection. The
|
|
20
|
+
* controller's own fail-closed contract still applies — an observer rejection
|
|
21
|
+
* poisons the controller, so the next awaited transition fails the run.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createScanProgressPublisher(lifecycle: Pick<ContextBuilderLifecycleController, "transition"> | undefined, options?: {
|
|
24
|
+
readonly now?: () => number;
|
|
25
|
+
}): ContextBuilderScanProgressPublisher;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Discovery invokes the progress sink at most once per this many file boundaries. */
|
|
2
|
+
export const CONTEXT_BUILDER_SCAN_PROGRESS_EVERY_FILES = 250;
|
|
3
|
+
/** Minimum wall-clock gap between two published mid-scan transitions. */
|
|
4
|
+
export const CONTEXT_BUILDER_SCAN_PROGRESS_MIN_INTERVAL_MS = 2_000;
|
|
5
|
+
/**
|
|
6
|
+
* Throttled mid-scan lifecycle publisher for the discovery walk: turns
|
|
7
|
+
* sampled discovery metrics into `scanning → scanning` count transitions so a
|
|
8
|
+
* long scan stays observable in `state.json` and `workflow_run_status`.
|
|
9
|
+
*
|
|
10
|
+
* Emits at most once per {@link CONTEXT_BUILDER_SCAN_PROGRESS_EVERY_FILES}
|
|
11
|
+
* newly seen files AND {@link CONTEXT_BUILDER_SCAN_PROGRESS_MIN_INTERVAL_MS}
|
|
12
|
+
* apart. No final emission: the handler's `searching` transition publishes the
|
|
13
|
+
* authoritative end-of-scan counts.
|
|
14
|
+
*
|
|
15
|
+
* Fire-and-forget: the walk never awaits publication, and a rejected
|
|
16
|
+
* transition is swallowed here so it never becomes an unhandled rejection. The
|
|
17
|
+
* controller's own fail-closed contract still applies — an observer rejection
|
|
18
|
+
* poisons the controller, so the next awaited transition fails the run.
|
|
19
|
+
*/
|
|
20
|
+
export function createScanProgressPublisher(lifecycle, options = {}) {
|
|
21
|
+
if (lifecycle == null) {
|
|
22
|
+
return () => { };
|
|
23
|
+
}
|
|
24
|
+
const now = options.now ?? (() => performance.now());
|
|
25
|
+
let lastFilesSeen = 0;
|
|
26
|
+
let lastEmittedAt;
|
|
27
|
+
return (metrics) => {
|
|
28
|
+
if (metrics.files_seen - lastFilesSeen < CONTEXT_BUILDER_SCAN_PROGRESS_EVERY_FILES) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const at = now();
|
|
32
|
+
if (lastEmittedAt != null &&
|
|
33
|
+
at - lastEmittedAt < CONTEXT_BUILDER_SCAN_PROGRESS_MIN_INTERVAL_MS) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
lastFilesSeen = metrics.files_seen;
|
|
37
|
+
lastEmittedAt = at;
|
|
38
|
+
try {
|
|
39
|
+
lifecycle
|
|
40
|
+
.transition("scanning", { counts: scanCountsFromMetrics(metrics) })
|
|
41
|
+
.catch(() => { });
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// A synchronously throwing controller is equally non-fatal to discovery.
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Mid-scan projection of the counts shape `lifecycleCountsFromDiscovery`
|
|
50
|
+
* publishes at `searching`. Omissions, search results, selection, and writes
|
|
51
|
+
* are not known until the walk ends, so they stay zero here.
|
|
52
|
+
*/
|
|
53
|
+
function scanCountsFromMetrics(metrics) {
|
|
54
|
+
return {
|
|
55
|
+
files_seen: metrics.files_seen,
|
|
56
|
+
files_considered: metrics.files_considered,
|
|
57
|
+
files_selected: 0,
|
|
58
|
+
files_omitted: 0,
|
|
59
|
+
search_results: 0,
|
|
60
|
+
bytes_read: metrics.bytes_read,
|
|
61
|
+
bytes_written: 0,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=discovery-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-progress.js","sourceRoot":"","sources":["../../src/context-builder/discovery-progress.ts"],"names":[],"mappings":"AAMA,sFAAsF;AACtF,MAAM,CAAC,MAAM,yCAAyC,GAAG,GAAG,CAAC;AAE7D,yEAAyE;AACzE,MAAM,CAAC,MAAM,6CAA6C,GAAG,KAAK,CAAC;AAMnE;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,2BAA2B,CACzC,SAA4E,EAC5E,UAA2C,EAAE;IAE7C,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACtB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IACrD,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,aAAiC,CAAC;IACtC,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,IAAI,OAAO,CAAC,UAAU,GAAG,aAAa,GAAG,yCAAyC,EAAE,CAAC;YACnF,OAAO;QACT,CAAC;QACD,MAAM,EAAE,GAAG,GAAG,EAAE,CAAC;QACjB,IACE,aAAa,IAAI,IAAI;YACrB,EAAE,GAAG,aAAa,GAAG,6CAA6C,EAClE,CAAC;YACD,OAAO;QACT,CAAC;QACD,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC;QACnC,aAAa,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC;YACH,SAAS;iBACN,UAAU,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAC;iBAClE,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,yEAAyE;QAC3E,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,qBAAqB,CAC5B,OAAiD;IAEjD,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,cAAc,EAAE,CAAC;QACjB,aAAa,EAAE,CAAC;QAChB,cAAc,EAAE,CAAC;QACjB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,aAAa,EAAE,CAAC;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Same window as the write watchdog and the dashboard write-phase stale overlay. */
|
|
2
|
+
export declare const CONTEXT_BUILDER_DISCOVERY_WATCHDOG_MS: number;
|
|
3
|
+
/**
|
|
4
|
+
* Bound the discovery/scanning phase wall clock. MCP cancel still wins when
|
|
5
|
+
* the caller signal aborts first; a watchdog-only abort becomes
|
|
6
|
+
* ExecutionError so the lifecycle records a failure, not a cancellation.
|
|
7
|
+
*
|
|
8
|
+
* The abort is observed at the walk's file-boundary checks and event-loop
|
|
9
|
+
* yields, so a single synchronous stretch (one sanitize call) runs to
|
|
10
|
+
* completion before the timer can take effect.
|
|
11
|
+
*/
|
|
12
|
+
export declare function withContextBuilderDiscoveryWatchdog<T>(work: (signal: AbortSignal) => Promise<T>, options?: {
|
|
13
|
+
readonly signal?: AbortSignal | undefined;
|
|
14
|
+
readonly timeoutMs?: number;
|
|
15
|
+
}): Promise<T>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ExecutionError } from "../errors.js";
|
|
2
|
+
/** Same window as the write watchdog and the dashboard write-phase stale overlay. */
|
|
3
|
+
export const CONTEXT_BUILDER_DISCOVERY_WATCHDOG_MS = 10 * 60 * 1_000;
|
|
4
|
+
/**
|
|
5
|
+
* Bound the discovery/scanning phase wall clock. MCP cancel still wins when
|
|
6
|
+
* the caller signal aborts first; a watchdog-only abort becomes
|
|
7
|
+
* ExecutionError so the lifecycle records a failure, not a cancellation.
|
|
8
|
+
*
|
|
9
|
+
* The abort is observed at the walk's file-boundary checks and event-loop
|
|
10
|
+
* yields, so a single synchronous stretch (one sanitize call) runs to
|
|
11
|
+
* completion before the timer can take effect.
|
|
12
|
+
*/
|
|
13
|
+
export async function withContextBuilderDiscoveryWatchdog(work, options = {}) {
|
|
14
|
+
const timeoutMs = options.timeoutMs ?? CONTEXT_BUILDER_DISCOVERY_WATCHDOG_MS;
|
|
15
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1) {
|
|
16
|
+
throw new ExecutionError("context_builder discovery watchdog timeout is invalid");
|
|
17
|
+
}
|
|
18
|
+
const watchdog = new AbortController();
|
|
19
|
+
const timer = setTimeout(() => {
|
|
20
|
+
watchdog.abort();
|
|
21
|
+
}, timeoutMs);
|
|
22
|
+
timer.unref();
|
|
23
|
+
const signal = options.signal == null
|
|
24
|
+
? watchdog.signal
|
|
25
|
+
: AbortSignal.any([options.signal, watchdog.signal]);
|
|
26
|
+
try {
|
|
27
|
+
return await work(signal);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (watchdog.signal.aborted && options.signal?.aborted !== true) {
|
|
31
|
+
throw new ExecutionError(`context_builder discovery phase exceeded ${String(timeoutMs)}ms`);
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=discovery-watchdog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-watchdog.js","sourceRoot":"","sources":["../../src/context-builder/discovery-watchdog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,qFAAqF;AACrF,MAAM,CAAC,MAAM,qCAAqC,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACvD,IAAyC,EACzC,UAGI,EAAE;IAEN,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,qCAAqC,CAAC;IAC7E,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,cAAc,CAAC,uDAAuD,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACvC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;QAC5B,QAAQ,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC,EAAE,SAAS,CAAC,CAAC;IACd,KAAK,CAAC,KAAK,EAAE,CAAC;IACd,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI;QACnC,CAAC,CAAC,QAAQ,CAAC,MAAM;QACjB,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,QAAQ,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;YAChE,MAAM,IAAI,cAAc,CACtB,4CAA4C,MAAM,CAAC,SAAS,CAAC,IAAI,CAClE,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -91,6 +91,13 @@ export type ContextBuilderDiscoveryOptions = {
|
|
|
91
91
|
budget: ContextBuilderPublicBudget;
|
|
92
92
|
internal_caps?: ContextBuilderInternalCaps;
|
|
93
93
|
signal?: AbortSignal;
|
|
94
|
+
/**
|
|
95
|
+
* Sampled mid-scan progress sink, invoked at file boundaries (throttled by
|
|
96
|
+
* the walk) with a snapshot of the running discovery metrics, so a long
|
|
97
|
+
* scanning phase stays observable before the `searching` transition
|
|
98
|
+
* publishes the first counts.
|
|
99
|
+
*/
|
|
100
|
+
onProgress?: (metrics: Readonly<ContextBuilderDiscoveryMetrics>) => void;
|
|
94
101
|
fs?: {
|
|
95
102
|
readdir?: typeof fsReaddir;
|
|
96
103
|
lstat?: typeof fsLstat;
|
|
@@ -5,10 +5,11 @@ import { isSamePathOrDescendant } from "../allowed-roots.js";
|
|
|
5
5
|
import { CancellationError } from "../errors.js";
|
|
6
6
|
import { CONTEXT_BUILDER_INTERNAL_CAP_DEFAULTS, } from "./config.js";
|
|
7
7
|
import { CONTEXT_BUILDER_REQUESTED_EVIDENCE_OMISSION_REASON, requestedEvidenceOmission, } from "./diagnostics.js";
|
|
8
|
+
import { CONTEXT_BUILDER_SCAN_PROGRESS_EVERY_FILES } from "./discovery-progress.js";
|
|
8
9
|
import { compileContextBuilderGlobs, CONTEXT_BUILDER_DEFAULT_EXCLUDE_GLOBS, } from "./globs.js";
|
|
9
10
|
import { normalizeContextBuilderRootRelativePath, rootRelativePathForAbsolutePath, } from "./paths.js";
|
|
10
11
|
import { directoryDistance, genericPathKind, isTestPath, normalizedPathStem, } from "./path-signals.js";
|
|
11
|
-
import { buildContextReviewObligations, } from "./review-coverage.js";
|
|
12
|
+
import { buildContextReviewObligations, planRegressionHeadSliceCandidates, } from "./review-coverage.js";
|
|
12
13
|
import { sanitizeHighConfidenceSecretContent, scanSecretPath, } from "./secrets.js";
|
|
13
14
|
import { CONTEXT_BUILDER_PUBLIC_BUDGET_HARD_LIMITS, } from "./schema.js";
|
|
14
15
|
const SEARCH_WINDOW_LINES_BEFORE = 19;
|
|
@@ -28,6 +29,10 @@ const CONTEXT_BUILDER_FOCUS_SLICED_REASON = "focus_sliced";
|
|
|
28
29
|
// We omit the file with this explicit material reason instead — honoring both
|
|
29
30
|
// the byte bound and "never silently drop an explicitly-focused file".
|
|
30
31
|
const CONTEXT_BUILDER_FOCUS_OVER_CAP_REASON = "focus_over_cap";
|
|
32
|
+
// Secret sanitization can run multi-second synchronous stretches. The walk
|
|
33
|
+
// yields a macrotask at least this often (and after every sanitize) so timers,
|
|
34
|
+
// cancellation notifications, and lock heartbeats keep running mid-scan.
|
|
35
|
+
const DISCOVERY_YIELD_EVERY_FILES = 32;
|
|
31
36
|
const IMPORT_EXPANSION_PASSES = 3;
|
|
32
37
|
const MAX_EXPANDED_SEARCH_TERMS = 128;
|
|
33
38
|
const MAX_EXPANDED_SEARCH_TERM_BYTES = 16_384;
|
|
@@ -66,6 +71,9 @@ export async function discoverContextBuilderCandidates(options) {
|
|
|
66
71
|
bytes_read: 0,
|
|
67
72
|
},
|
|
68
73
|
stopped: false,
|
|
74
|
+
onProgress: options.onProgress,
|
|
75
|
+
filesSinceYield: 0,
|
|
76
|
+
filesSinceProgress: 0,
|
|
69
77
|
};
|
|
70
78
|
for (const root of options.roots) {
|
|
71
79
|
if (state.stopped) {
|
|
@@ -175,17 +183,43 @@ export async function discoverContextBuilderCandidates(options) {
|
|
|
175
183
|
if (slices.capHit) {
|
|
176
184
|
state.metrics.candidate_cap_hit = true;
|
|
177
185
|
}
|
|
178
|
-
const
|
|
186
|
+
const reviewFocusPaths = (options.focus_paths ?? []).map((focus) => ({
|
|
187
|
+
root_index: focus.root_index,
|
|
188
|
+
path: focus.root_relative_path,
|
|
189
|
+
kind: focus.kind,
|
|
190
|
+
}));
|
|
191
|
+
let reviewObligations = buildContextReviewObligations({
|
|
179
192
|
candidates: state.contentCandidates,
|
|
180
|
-
focusPaths:
|
|
181
|
-
root_index: focus.root_index,
|
|
182
|
-
path: focus.root_relative_path,
|
|
183
|
-
kind: focus.kind,
|
|
184
|
-
})),
|
|
193
|
+
focusPaths: reviewFocusPaths,
|
|
185
194
|
searchRecords: search.records,
|
|
186
195
|
slices: slices.records,
|
|
187
196
|
policy: options.coverage_policy,
|
|
188
197
|
});
|
|
198
|
+
if (reviewObligations != null) {
|
|
199
|
+
const headSlices = buildRegressionHeadSliceRecords({
|
|
200
|
+
candidates: state.contentCandidates,
|
|
201
|
+
planned: planRegressionHeadSliceCandidates({
|
|
202
|
+
candidates: state.contentCandidates,
|
|
203
|
+
searchRecords: search.records,
|
|
204
|
+
slices: slices.records,
|
|
205
|
+
obligations: reviewObligations,
|
|
206
|
+
}),
|
|
207
|
+
existingRecords: slices.records,
|
|
208
|
+
maxCandidateSlices: internalCaps.max_candidate_slices,
|
|
209
|
+
maxCandidateBytes: Math.max(0, internalCaps.max_candidate_bytes - search.candidateBytes),
|
|
210
|
+
maxBytesPerFile: options.budget.max_bytes_per_file,
|
|
211
|
+
});
|
|
212
|
+
if (headSlices.length > 0) {
|
|
213
|
+
slices.records.push(...headSlices);
|
|
214
|
+
reviewObligations = buildContextReviewObligations({
|
|
215
|
+
candidates: state.contentCandidates,
|
|
216
|
+
focusPaths: reviewFocusPaths,
|
|
217
|
+
searchRecords: search.records,
|
|
218
|
+
slices: slices.records,
|
|
219
|
+
policy: options.coverage_policy,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
189
223
|
classifyContextEvidenceCandidates({
|
|
190
224
|
candidates: state.contentCandidates,
|
|
191
225
|
focusPaths: options.focus_paths ?? [],
|
|
@@ -1099,6 +1133,51 @@ export function buildCandidateSliceRecords(input) {
|
|
|
1099
1133
|
}
|
|
1100
1134
|
return { records, capHit, omissions };
|
|
1101
1135
|
}
|
|
1136
|
+
// Head-slice line bound for synthesized regression evidence: enough to show a
|
|
1137
|
+
// test's imports and first cases without competing with real search windows.
|
|
1138
|
+
const REGRESSION_HEAD_SLICE_MAX_LINES = 60;
|
|
1139
|
+
/**
|
|
1140
|
+
* Materializes the tests chosen by `planRegressionHeadSliceCandidates` as real
|
|
1141
|
+
* slice records so selection, reconstruction, and rendering can carry them.
|
|
1142
|
+
* Source is `search` WITHOUT `search_term_index`: every slice consumer already
|
|
1143
|
+
* defaults a missing index to the lowest rank, and `focus` would wrongly mark
|
|
1144
|
+
* the test as caller-requested evidence. Content comes from the already
|
|
1145
|
+
* sanitized content candidate, so `allow_secrets:false` redaction applies
|
|
1146
|
+
* exactly as for other slices. Candidate slice/byte caps still bound the
|
|
1147
|
+
* total; a slice that does not fit is simply not synthesized.
|
|
1148
|
+
*/
|
|
1149
|
+
function buildRegressionHeadSliceRecords(input) {
|
|
1150
|
+
const candidateByIdentity = new Map(input.candidates.map((candidate) => [candidateKey(candidate), candidate]));
|
|
1151
|
+
let count = input.existingRecords.length;
|
|
1152
|
+
let bytes = input.existingRecords.reduce((total, record) => total + Buffer.byteLength(`${JSON.stringify(record)}\n`, "utf8"), 0);
|
|
1153
|
+
const records = [];
|
|
1154
|
+
for (const planned of input.planned) {
|
|
1155
|
+
const candidate = candidateByIdentity.get(candidateKey(planned));
|
|
1156
|
+
if (candidate == null ||
|
|
1157
|
+
candidate.line_count === 0 ||
|
|
1158
|
+
firstLineExceedsCap(candidate.content, input.maxBytesPerFile)) {
|
|
1159
|
+
continue;
|
|
1160
|
+
}
|
|
1161
|
+
const endLine = Math.min(candidate.line_count, REGRESSION_HEAD_SLICE_MAX_LINES, headSliceEndLine(candidate.content, input.maxBytesPerFile));
|
|
1162
|
+
const record = {
|
|
1163
|
+
root_index: candidate.root_index,
|
|
1164
|
+
path: candidate.path,
|
|
1165
|
+
start_line: 1,
|
|
1166
|
+
end_line: endLine,
|
|
1167
|
+
source: "search",
|
|
1168
|
+
content: sliceContent(candidate.content, 1, endLine),
|
|
1169
|
+
};
|
|
1170
|
+
const recordBytes = Buffer.byteLength(`${JSON.stringify(record)}\n`, "utf8");
|
|
1171
|
+
if (count >= input.maxCandidateSlices ||
|
|
1172
|
+
bytes + recordBytes > input.maxCandidateBytes) {
|
|
1173
|
+
continue;
|
|
1174
|
+
}
|
|
1175
|
+
records.push(record);
|
|
1176
|
+
count++;
|
|
1177
|
+
bytes += recordBytes;
|
|
1178
|
+
}
|
|
1179
|
+
return records;
|
|
1180
|
+
}
|
|
1102
1181
|
export function splitTextLines(text) {
|
|
1103
1182
|
if (text.length === 0) {
|
|
1104
1183
|
return [];
|
|
@@ -1367,6 +1446,35 @@ function pushDirectoryOmission(input, omission) {
|
|
|
1367
1446
|
});
|
|
1368
1447
|
}
|
|
1369
1448
|
async function processFile(input) {
|
|
1449
|
+
await processFileEntry(input);
|
|
1450
|
+
await settleDiscoveryFileBoundary(input.state, input.signal);
|
|
1451
|
+
}
|
|
1452
|
+
async function settleDiscoveryFileBoundary(state, signal) {
|
|
1453
|
+
state.filesSinceProgress++;
|
|
1454
|
+
if (state.onProgress != null &&
|
|
1455
|
+
state.filesSinceProgress >= CONTEXT_BUILDER_SCAN_PROGRESS_EVERY_FILES) {
|
|
1456
|
+
state.filesSinceProgress = 0;
|
|
1457
|
+
try {
|
|
1458
|
+
state.onProgress(Object.freeze({ ...state.metrics }));
|
|
1459
|
+
}
|
|
1460
|
+
catch {
|
|
1461
|
+
// Progress is observability only; a failing sink must never stop the walk.
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
assertNotAborted(signal);
|
|
1465
|
+
state.filesSinceYield++;
|
|
1466
|
+
if (state.filesSinceYield >= DISCOVERY_YIELD_EVERY_FILES) {
|
|
1467
|
+
await yieldDiscoveryToEventLoop(state, signal);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
async function yieldDiscoveryToEventLoop(state, signal) {
|
|
1471
|
+
state.filesSinceYield = 0;
|
|
1472
|
+
await new Promise((resolve) => {
|
|
1473
|
+
setImmediate(resolve);
|
|
1474
|
+
});
|
|
1475
|
+
assertNotAborted(signal);
|
|
1476
|
+
}
|
|
1477
|
+
async function processFileEntry(input) {
|
|
1370
1478
|
const fileKey = candidateKey({
|
|
1371
1479
|
root_index: input.root.root_index,
|
|
1372
1480
|
path: input.relativePath,
|
|
@@ -1588,6 +1696,10 @@ async function processFile(input) {
|
|
|
1588
1696
|
const sanitized = input.allowSecrets
|
|
1589
1697
|
? { status: "unchanged", content: rawContent, findings: [] }
|
|
1590
1698
|
: sanitizeHighConfidenceSecretContent(rawContent);
|
|
1699
|
+
if (!input.allowSecrets) {
|
|
1700
|
+
assertNotAborted(input.signal);
|
|
1701
|
+
await yieldDiscoveryToEventLoop(input.state, input.signal);
|
|
1702
|
+
}
|
|
1591
1703
|
if (sanitized.status === "blocked") {
|
|
1592
1704
|
omitted("content_secret", `Content omitted due to high-confidence secret (${summarizeSecretFindings(sanitized.findings)})`, sanitized.findings);
|
|
1593
1705
|
pushTree({
|