sneakoscope 10.3.8 → 10.3.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/README.md +6 -3
- package/crates/sks-core/Cargo.lock +1 -1
- package/crates/sks-core/Cargo.toml +1 -1
- package/dist/bin/sks-dispatch.js +1 -1
- package/dist/cli/command-registry.js +0 -9
- package/dist/cli/feature-commands.js +18 -52
- package/dist/cli/global-mode-router.js +0 -1
- package/dist/cli/install-helpers-codex-lb-shared.js +0 -3
- package/dist/cli/install-helpers-install-support.js +1 -20
- package/dist/cli/install-helpers.js +3 -3
- package/dist/cli/install-tool-helpers.js +0 -76
- package/dist/cli/router.js +0 -3
- package/dist/commands/decision.js +1 -1
- package/dist/commands/doctor-helpers.js +1 -20
- package/dist/commands/doctor.js +9 -21
- package/dist/commands/hook.js +3 -2
- package/dist/config/skills-manifest.json +1 -1
- package/dist/core/agent-bridge/host-capability-runtime.js +0 -3
- package/dist/core/agents/agent-codex-cockpit.js +0 -1
- package/dist/core/agents/agent-orchestrator.js +1 -1
- package/dist/core/agents/agent-patch-transaction-journal.js +1 -16
- package/dist/core/agents/agent-plan.js +0 -4
- package/dist/core/agents/agent-recursion-guard.js +0 -369
- package/dist/core/agents/agent-role-config.js +1 -15
- package/dist/core/agents/agent-runner-fake.js +0 -53
- package/dist/core/agents/agent-schema.js +0 -4
- package/dist/core/agents/agent-work-queue.js +1 -11
- package/dist/core/agents/agent-worker-pipeline.js +1 -19
- package/dist/core/agents/agent-worker-slot.js +1 -10
- package/dist/core/agents/runtime-proof-summary.js +0 -1
- package/dist/core/align/align-route.js +0 -3
- package/dist/core/align/code-navigation-align.js +1 -1
- package/dist/core/architecture-hardening/contracts/contracts.js +0 -4
- package/dist/core/architecture-map-pipeline.js +0 -25
- package/dist/core/architecture-map-review.js +2 -18
- package/dist/core/artifact-schemas.js +0 -1
- package/dist/core/auto-review.js +0 -22
- package/dist/core/code-structure.js +0 -5
- package/dist/core/codex/agent-config-file-repair.js +0 -3
- package/dist/core/codex/codex-config-guard.js +0 -40
- package/dist/core/codex-app/codex-app-fast-ui-preservation.js +1 -7
- package/dist/core/codex-app/codex-app-types.js +0 -3
- package/dist/core/codex-app/codex-desktop-routing-ownership.js +0 -1
- package/dist/core/codex-app/codex-hook-lifecycle.js +2 -2
- package/dist/core/codex-app/codex-model-catalog.js +0 -11
- package/dist/core/codex-app/codex-models-cache.js +0 -8
- package/dist/core/codex-app/mcp-manager.js +1 -2
- package/dist/core/codex-app/multi-provider-router-support.js +1 -178
- package/dist/core/codex-app.js +0 -4
- package/dist/core/codex-compat/codex-hook-semantic-validator.js +0 -15
- package/dist/core/codex-control/codex-current-feature-capability.js +2 -14
- package/dist/core/codex-control/codex-current-feature-probes.js +0 -4
- package/dist/core/codex-control/codex-output-schemas.js +0 -10
- package/dist/core/codex-control/codex-reliability-shield.js +0 -3
- package/dist/core/codex-control/codex-sdk-env-policy.js +0 -3
- package/dist/core/codex-control/gpt-final-arbiter.js +1 -1
- package/dist/core/codex-control/model-call-concurrency.js +0 -1
- package/dist/core/codex-hooks/codex-dead-managed-hooks.js +116 -0
- package/dist/core/codex-hooks/codex-global-hooks.js +387 -0
- package/dist/core/codex-hooks/codex-hook-actual-discovery.js +36 -106
- package/dist/core/codex-hooks/codex-hook-hash.js +4 -7
- package/dist/core/codex-hooks/codex-hook-official-parity.js +32 -125
- package/dist/core/codex-hooks/codex-hook-state-writer.js +0 -139
- package/dist/core/codex-hooks/codex-hook-trust-doctor.js +16 -30
- package/dist/core/codex-hooks/codex-hook-trust-state.js +8 -7
- package/dist/core/codex-hooks/codex-hooks-list.js +106 -0
- package/dist/core/codex-hooks/codex-project-hooks.js +108 -0
- package/dist/core/codex-hooks/sks-hook-entries.js +104 -0
- package/dist/core/codex-lb/codex-lb-env.js +0 -2
- package/dist/core/codex-lb/desktop-auth-invariant.js +1 -44
- package/dist/core/codex-lb/desktop-bridge-migration.js +0 -1
- package/dist/core/codex-lb/desktop-controller-v3/openrouter-only-status.js +0 -7
- package/dist/core/codex-lb/route-index.js +0 -3
- package/dist/core/codex-lb/trusted-deep-evidence.js +0 -3
- package/dist/core/codex-lb-circuit.js +0 -20
- package/dist/core/codex-native/codex-native-feature-matrix.js +0 -3
- package/dist/core/codex-native/core-skill-integrity.js +1 -4
- package/dist/core/codex-native/core-skill-manifest.js +0 -4
- package/dist/core/commands/basic-cli.js +16 -4
- package/dist/core/commands/mad-sks-command.js +0 -22
- package/dist/core/commands/naruto-command.js +4 -4
- package/dist/core/commands/ppt-command.js +1 -1
- package/dist/core/commands/seo-command.js +0 -3
- package/dist/core/commands/triwiki-atlas-command.js +1 -1
- package/dist/core/commands/uninstall-command.js +10 -0
- package/dist/core/commands/wiki-command.js +1 -1
- package/dist/core/config/config-migration-journal.js +1 -27
- package/dist/core/config/managed-config-merge.js +1 -1
- package/dist/core/config/secret-preservation.js +0 -5
- package/dist/core/config-adopt/config-adopt.js +0 -1
- package/dist/core/context7-client.js +0 -3
- package/dist/core/daemon/sksd-client.js +1 -2
- package/dist/core/daemon/sksd-hook-dispatch.js +26 -9
- package/dist/core/daemon/sksd-ipc.js +0 -6
- package/dist/core/daemon/sksd.js +0 -28
- package/dist/core/db-review.js +0 -10
- package/dist/core/db-safety.js +0 -36
- package/dist/core/decisions/integration.js +1 -25
- package/dist/core/decisions/openrouter.js +1 -4
- package/dist/core/decisions/policy.js +1 -2
- package/dist/core/decisions/questions.js +1 -2
- package/dist/core/decisions/receipt.js +0 -11
- package/dist/core/decisions/types.js +0 -1
- package/dist/core/dfix.js +0 -12
- package/dist/core/doctor/doctor-codex-startup-repair.js +0 -1
- package/dist/core/doctor/doctor-native-capability-repair.js +14 -15
- package/dist/core/doctor/doctor-readiness-matrix.js +12 -11
- package/dist/core/doctor/global-sks-install-cleanup.js +1 -15
- package/dist/core/evidence/evidence-router.js +1 -1
- package/dist/core/feature-fixture-runner.js +0 -12
- package/dist/core/feature-registry.js +1 -25
- package/dist/core/fsx.js +0 -19
- package/dist/core/git/git-worktree-cleanup.js +0 -27
- package/dist/core/git-hygiene/git-status.js +1 -7
- package/dist/core/git-hygiene/shared-memory-publish.js +2 -23
- package/dist/core/git-simple.js +2 -7
- package/dist/core/harness-conflicts.js +0 -1
- package/dist/core/hooks-runtime/context-graph-freshness-preflight.js +0 -22
- package/dist/core/hooks-runtime/hook-layer.js +101 -0
- package/dist/core/hooks-runtime/official-subagent-lifecycle.js +2 -2
- package/dist/core/hooks-runtime.js +19 -33
- package/dist/core/hproof.js +0 -18
- package/dist/core/image-ux-review/callout-extraction.js +0 -9
- package/dist/core/image-ux-review/imagegen-adapter.js +1 -1
- package/dist/core/image-ux-review/recapture.js +0 -14
- package/dist/core/image-ux-review.js +0 -1
- package/dist/core/imagegen/imagegen-model-policy.js +0 -1
- package/dist/core/imagegen/imagegen-request-validator.js +1 -6
- package/dist/core/init/skills.js +2 -5
- package/dist/core/init.js +35 -120
- package/dist/core/loop-blocker.js +0 -20
- package/dist/core/loops/loop-artifacts.js +0 -6
- package/dist/core/loops/loop-checkpoint.js +1 -4
- package/dist/core/loops/loop-gate-ladder.js +0 -4
- package/dist/core/loops/loop-lease.js +0 -3
- package/dist/core/loops/loop-owner-inference.js +0 -22
- package/dist/core/loops/loop-owner-ledger.js +1 -1
- package/dist/core/loops/loop-risk-classifier.js +0 -8
- package/dist/core/loops/loop-side-effect-scanner.js +1 -4
- package/dist/core/mad-sks/executors/executor-base.js +0 -20
- package/dist/core/mad-sks/executors/index.js +0 -3
- package/dist/core/mad-sks/sql-plane/capability.js +0 -45
- package/dist/core/mad-sks/sql-plane/coordinator.js +3 -30
- package/dist/core/mad-sks/sql-plane/ledger.js +0 -14
- package/dist/core/mad-sks/sql-plane/mcp-executor.js +0 -3
- package/dist/core/mad-sks/sql-plane/policy.js +0 -3
- package/dist/core/mad-sks/sql-plane/result-lifecycle.js +0 -10
- package/dist/core/mad-sks/sql-plane/target.js +0 -3
- package/dist/core/managed-assets/managed-assets-manifest.js +0 -32
- package/dist/core/managed-path-safety.js +0 -3
- package/dist/core/mcp/mcp-config-preservation.js +0 -3
- package/dist/core/mcp/modern-protocol.js +0 -11
- package/dist/core/mcp-config/guarded-patch.js +0 -4
- package/dist/core/mcp-config/health-check.js +1 -1
- package/dist/core/memory-governor.js +0 -4
- package/dist/core/mistake-memory.js +1 -49
- package/dist/core/naruto/naruto-active-pool.js +0 -240
- package/dist/core/naruto/naruto-parallel-patch-apply.js +0 -16
- package/dist/core/naruto/naruto-real-write-proof.js +0 -29
- package/dist/core/naruto/naruto-role-policy.js +0 -76
- package/dist/core/naruto/naruto-task-hints.js +0 -57
- package/dist/core/naruto/naruto-work-graph.js +0 -20
- package/dist/core/naruto/naruto-work-item.js +0 -25
- package/dist/core/naruto/solution-tournament.js +0 -26
- package/dist/core/ops/ops-maturity-scorecard.js +1 -5
- package/dist/core/perf/release-latency-slo.js +4 -1
- package/dist/core/pipeline-internals/runtime-core.js +6 -80
- package/dist/core/policy/latest-version-guidance.js +0 -1
- package/dist/core/ppt/style-tokens.js +1 -1
- package/dist/core/ppt-imagegen-review.js +1 -2
- package/dist/core/ppt-review/slide-issue-extraction.js +0 -1
- package/dist/core/ppt.js +3 -3
- package/dist/core/probes/probe-memoization.js +0 -31
- package/dist/core/proof/proof-writer.js +0 -18
- package/dist/core/proof-field.js +0 -27
- package/dist/core/provider/provider-badge.js +0 -11
- package/dist/core/provider/provider-context.js +1 -7
- package/dist/core/providers/openrouter/openrouter-request-cache.js +0 -2
- package/dist/core/providers/openrouter/openrouter-secret-store.js +0 -32
- package/dist/core/python-tools/python-tool-runner.js +1 -6
- package/dist/core/qa-loop/qa-types.js +0 -3
- package/dist/core/qa-loop.js +0 -24
- package/dist/core/questions.js +0 -5
- package/dist/core/recallpulse.js +1 -18
- package/dist/core/release/content-digest-cache.js +0 -3
- package/dist/core/release/gate-manifest.js +0 -7
- package/dist/core/release/gate-pack-assertion.js +0 -19
- package/dist/core/release/gate-pack-runner.js +0 -4
- package/dist/core/release/release-gate-cache-v2.js +0 -3
- package/dist/core/remote/index.js +0 -1
- package/dist/core/remote/owner-proof.js +1 -7
- package/dist/core/remote/protocol.js +0 -12
- package/dist/core/remote/session-index.js +0 -13
- package/dist/core/research/claim-evidence-matrix.js +1 -1
- package/dist/core/research/implementation-blueprint-densifier.js +0 -1
- package/dist/core/research/mock-result.js +2 -2
- package/dist/core/research/research-realistic-report.js +0 -4
- package/dist/core/research/research-source-evidence.js +0 -8
- package/dist/core/research/research-source-ledger-merge.js +0 -1
- package/dist/core/research/research-synthesis-writer.js +0 -4
- package/dist/core/research.js +0 -5
- package/dist/core/responses-stream.js +0 -13
- package/dist/core/retention.js +0 -6
- package/dist/core/routes/constants.js +0 -1
- package/dist/core/routes/design-policy.js +0 -3
- package/dist/core/routes/evidence.js +1 -13
- package/dist/core/routes/model-mode-router.js +0 -4
- package/dist/core/routes.js +2 -83
- package/dist/core/safety/mutation-guard.js +0 -1
- package/dist/core/search/cache.js +0 -3
- package/dist/core/search/context-graph-seeds.js +0 -7
- package/dist/core/search/index.js +0 -1
- package/dist/core/search/rust-bridge.js +1 -5
- package/dist/core/search-visibility/adapter-registry.js +0 -3
- package/dist/core/search-visibility/analyzers.js +0 -2
- package/dist/core/search-visibility/artifacts.js +0 -1
- package/dist/core/search-visibility/index.js +1 -2
- package/dist/core/search-visibility/marketing.js +0 -3
- package/dist/core/search-visibility/mission.js +1 -4
- package/dist/core/search-visibility/verifier.js +1 -6
- package/dist/core/security/private-credential-file.js +0 -61
- package/dist/core/skill-forge.js +0 -35
- package/dist/core/skills/core-rollout-trace.js +1 -11
- package/dist/core/skills/core-skill-card.js +0 -0
- package/dist/core/skills/core-skill-deployment.js +0 -6
- package/dist/core/stop-gate/stop-gate-resolver.js +1 -1
- package/dist/core/strategy/adhd-orchestrating-gate.js +1 -1
- package/dist/core/subagents/child-model-allowlist.js +0 -3
- package/dist/core/subagents/model-policy.js +0 -4
- package/dist/core/subagents/model-tiers.js +0 -9
- package/dist/core/subagents/official-subagent-config.js +1 -2
- package/dist/core/subagents/subagent-evidence.js +0 -2
- package/dist/core/super-search/runtime-helpers.js +1 -19
- package/dist/core/super-search/types.js +0 -1
- package/dist/core/triwiki/agents-md-projector.js +0 -3
- package/dist/core/triwiki/code-navigation-context-pack.js +1 -11
- package/dist/core/triwiki/code-pack.js +0 -17
- package/dist/core/triwiki/context-graph/architecture/fingerprint.js +0 -7
- package/dist/core/triwiki/context-graph/architecture/input-bundle.js +0 -14
- package/dist/core/triwiki/context-graph/architecture/policy.js +0 -7
- package/dist/core/triwiki/context-graph/architecture/slice.js +0 -90
- package/dist/core/triwiki/context-graph/architecture/validation.js +1 -73
- package/dist/core/triwiki/context-graph/architecture/voxel-context.js +0 -22
- package/dist/core/triwiki/context-graph/compiler/fragment-manifest-store.js +0 -6
- package/dist/core/triwiki/context-graph/compiler/fragment-manifest.js +0 -12
- package/dist/core/triwiki/context-graph/compiler/serialize.js +0 -3
- package/dist/core/triwiki/context-graph/graph-index.js +0 -10
- package/dist/core/triwiki/context-graph/paths.js +0 -3
- package/dist/core/triwiki/context-graph/projections/mermaid/index.js +0 -3
- package/dist/core/triwiki/context-graph/projections/mermaid/serializer.js +0 -12
- package/dist/core/triwiki/context-graph/projections/mermaid/view-specs.js +0 -15
- package/dist/core/triwiki/context-graph/query/changed-path-seeds.js +0 -8
- package/dist/core/triwiki/context-graph/query/index.js +1 -1
- package/dist/core/triwiki/context-graph/query/kernel-types.js +0 -3
- package/dist/core/triwiki/context-graph/runtime-index/writer-contract.js +0 -1
- package/dist/core/triwiki/context-graph/runtime-index/writer-tables.js +0 -1
- package/dist/core/triwiki/triwiki-proof-bank-index.js +1 -10
- package/dist/core/triwiki/triwiki-sla-certificate.js +0 -8
- package/dist/core/triwiki-attention.js +0 -7
- package/dist/core/triwiki-wrongness/avoidance-rules.js +0 -5
- package/dist/core/triwiki-wrongness/wrongness-cli.js +1 -1
- package/dist/core/triwiki-wrongness/wrongness-ledger.js +2 -32
- package/dist/core/triwiki-wrongness/wrongness-proof-linker.js +0 -12
- package/dist/core/triwiki-wrongness/wrongness-retrieval.js +0 -21
- package/dist/core/triwiki-wrongness/wrongness-schema.js +0 -3
- package/dist/core/trust-kernel/route-contract.js +0 -1
- package/dist/core/trust-kernel/trust-kernel-schema.js +0 -1
- package/dist/core/trust-kernel/trust-report.js +1 -1
- package/dist/core/trust-kernel/trust-status.js +0 -7
- package/dist/core/update/update-migration-state/simple-stages.js +17 -23
- package/dist/core/update/update-migration-state.js +1 -24
- package/dist/core/update-check.js +5 -27
- package/dist/core/verification/diff-quality.js +0 -1
- package/dist/core/verification/impact-scan.js +0 -3
- package/dist/core/verification-profile.js +0 -1
- package/dist/core/version-manager.js +0 -98
- package/dist/core/version.js +1 -1
- package/dist/scripts/canonical-test-runner.js +2 -1
- package/dist/scripts/codex-native-gate-lib.js +0 -43
- package/dist/scripts/gate-lib.js +0 -17
- package/dist/scripts/lib/codex-sdk-gate-lib.js +0 -17
- package/dist/scripts/lib/git-worktree-fixture.js +0 -5
- package/dist/scripts/lib/valid-png-fixture.js +0 -7
- package/dist/scripts/official-subagent-workflow-check.js +1 -1
- package/dist/scripts/real-execution-check-lib.js +0 -5
- package/dist/scripts/skill-surface-modernization-check.js +0 -7
- package/dist/scripts/sks-cli-gate-lib.js +0 -30
- package/package.json +1 -2
- package/release-gates.v2.json +0 -1
- package/runtime-required-scripts.json +0 -10
- package/dist/core/agents/agent-task-slicer.js +0 -1
- package/dist/core/codex-app/provider-operation-stages.js +0 -20
- package/dist/core/codex-control/codex-current-core-probe-summary.js +0 -40
- package/dist/core/codex-control/codex-current-feature-real-probes.js +0 -68
- package/dist/core/codex-hooks/codex-hook-managed-install.js +0 -162
- package/dist/core/codex-hooks/codex-hook-official-hash-oracle.js +0 -95
- package/dist/core/codex-lb/probes/catalog-probe.js +0 -39
- package/dist/core/doctor/codex-current-core-probe-doctor.js +0 -16
- package/dist/core/doctor/confirm-repair.js +0 -26
- package/dist/core/doctor/legacy-global-hook-cleanup.js +0 -176
- package/dist/core/features/feature-completion.js +0 -1
- package/dist/core/features/feature-fixtures.js +0 -9
- package/dist/core/features/feature-registry.js +0 -2
- package/dist/core/hooks-runtime/codex-commit-hooks-selftest.js +0 -82
- package/dist/core/mad-sks/sql-plane/recovery.js +0 -27
- package/dist/core/naruto/naruto-verification-dag.js +0 -52
- package/dist/core/official-subagent-review-policy.js +0 -17
- package/dist/core/perf/performance-profiler.js +0 -108
- package/dist/core/ppt-review/deck-issue-ledger.js +0 -49
- package/dist/core/ppt-review/reexport-rereview.js +0 -84
- package/dist/core/prompt-context-builder.js +0 -36
- package/dist/core/proof/claim-ledger.js +0 -9
- package/dist/core/proof/command-ledger.js +0 -20
- package/dist/core/proof/file-change-ledger.js +0 -5
- package/dist/core/providers/openrouter/openrouter-client.js +0 -63
- package/dist/core/providers/openrouter/openrouter-provider-health.js +0 -46
- package/dist/core/qa-loop/qa-app-server-driver.js +0 -133
- package/dist/core/remote/local-worker-client.js +0 -35
- package/dist/core/reporting/markdown-table.js +0 -12
- package/dist/core/search-visibility/adapters/next-app.js +0 -5
- package/dist/core/search-visibility/adapters/next-pages.js +0 -5
- package/dist/core/search-visibility/adapters/static-site.js +0 -5
- package/dist/core/stop-gate/stop-gate-diagnostics.js +0 -3
- package/dist/core/triwiki/context-graph/projections/mermaid/architecture-delta.js +0 -68
- package/dist/core/triwiki/context-graph/projections/mermaid/change-impact.js +0 -43
- package/dist/core/triwiki/context-graph/projections/mermaid/ownership-workstream.js +0 -21
- package/dist/core/triwiki/triwiki-invalidation.js +0 -80
- package/dist/core/validators/feature-fixture-validator.js +0 -7
- package/dist/core/validators/route-contract-validator.js +0 -15
- package/dist/core/validators/trust-report-validator.js +0 -15
- package/dist/core/verification/verification-proof.js +0 -26
- package/dist/core/wiki-image/before-after-relation.js +0 -1
- package/dist/core/wiki-image/callout-parser.js +0 -16
- package/dist/core/wiki-image/computer-use-ledger.js +0 -38
- package/dist/core/wiki-image/generated-review-parser.js +0 -1
- package/dist/core/wiki-image/image-relation.js +0 -2
- package/dist/core/wiki-image/image-ux-evidence.js +0 -1
- package/dist/core/wiki-image/ppt-image-evidence.js +0 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { writeJsonAtomic } from '../fsx.js';
|
|
3
3
|
export const AGENT_RECURSION_GUARD_REPORT_SCHEMA = 'sks.agent-recursion-guard.v1';
|
|
4
|
-
export const NON_RECURSIVE_PIPELINE_REPORT_SCHEMA = 'sks.non-recursive-pipeline-report.v1';
|
|
5
|
-
export const NON_RECURSIVE_PIPELINE_PERFORMANCE_BUDGET_MS = 1500;
|
|
6
4
|
export const AGENT_RECURSIVE_COMMAND_DENYLIST = Object.freeze([
|
|
7
5
|
'sks naruto run',
|
|
8
6
|
'sks research run',
|
|
@@ -18,53 +16,9 @@ export const AGENT_RECURSIVE_COMMAND_DENYLIST = Object.freeze([
|
|
|
18
16
|
'node dist/bin/sks.js naruto',
|
|
19
17
|
'node dist/bin/sks.js research run'
|
|
20
18
|
]);
|
|
21
|
-
export const AGENT_WORKER_ENV_GUARD_TOKENS = Object.freeze([
|
|
22
|
-
'AGENT_WORKER_PIPELINE',
|
|
23
|
-
'SKS_AGENT_WORKER',
|
|
24
|
-
'SKS_PIPELINE_MODE',
|
|
25
|
-
'SKS_DISABLE_ROUTE_RECURSION',
|
|
26
|
-
'SKS_AGENT_SESSION_ID',
|
|
27
|
-
'SKS_AGENT_ID',
|
|
28
|
-
'SKS_AGENT_ALLOWED_COMMANDS_FILE'
|
|
29
|
-
]);
|
|
30
|
-
const COMMAND_DENYLIST = AGENT_RECURSIVE_COMMAND_DENYLIST.filter((entry) => !entry.startsWith('$'));
|
|
31
|
-
const ROUTE_DENYLIST = AGENT_RECURSIVE_COMMAND_DENYLIST.filter((entry) => entry.startsWith('$'));
|
|
32
19
|
const DENY_PATTERNS = AGENT_RECURSIVE_COMMAND_DENYLIST.map((entry) => entry.startsWith('$')
|
|
33
20
|
? new RegExp('(^|\\s)\\' + entry + '(\\s|$)', 'i')
|
|
34
21
|
: new RegExp('(^|\\s)' + escapeRe(entry).replace(/\\ /g, '\\s+') + '(\\s|$)', 'i'));
|
|
35
|
-
const SECRET_PATTERNS = [
|
|
36
|
-
{ id: 'openai_api_key', pattern: /\bsk-[A-Za-z0-9_-]{12,}\b/g },
|
|
37
|
-
{ id: 'github_token', pattern: /\bgh[pousr]_[A-Za-z0-9_]{12,}\b/g },
|
|
38
|
-
{ id: 'slack_token', pattern: /\bxox[baprs]-[A-Za-z0-9-]{12,}\b/g },
|
|
39
|
-
{ id: 'jwt_like_token', pattern: /\beyJ[A-Za-z0-9_-]{16,}\.[A-Za-z0-9_-]{16,}\.[A-Za-z0-9_-]{8,}\b/g }
|
|
40
|
-
];
|
|
41
|
-
const WORKER_MISSION_CREATION_PATTERNS = [
|
|
42
|
-
{ id: 'createMission', pattern: /\bcreateMission\s*\(/g },
|
|
43
|
-
{ id: 'missionDir', pattern: /\bmissionDir\s*\(/g }
|
|
44
|
-
];
|
|
45
|
-
const CURRENT_JSON_WRITE_PATTERNS = [
|
|
46
|
-
{ id: 'setCurrent', pattern: /\bsetCurrent\s*\(/g },
|
|
47
|
-
{ id: 'stateFile', pattern: /\bstateFile\s*\(/g },
|
|
48
|
-
{ id: 'current_json_path', pattern: /\.sneakoscope\/state\/current\.json/g }
|
|
49
|
-
];
|
|
50
|
-
export const NON_RECURSIVE_PIPELINE_SCAN_CONTRACT = Object.freeze({
|
|
51
|
-
schema: NON_RECURSIVE_PIPELINE_REPORT_SCHEMA,
|
|
52
|
-
local_only: true,
|
|
53
|
-
scan_groups: [
|
|
54
|
-
'env guard',
|
|
55
|
-
'command denylist',
|
|
56
|
-
'route denylist',
|
|
57
|
-
'worker mission creation block',
|
|
58
|
-
'current.json write block',
|
|
59
|
-
'top-level command block',
|
|
60
|
-
'stdout transcript scan',
|
|
61
|
-
'stderr transcript scan',
|
|
62
|
-
'agent result scan',
|
|
63
|
-
'wrongness record'
|
|
64
|
-
],
|
|
65
|
-
artifacts: ['non-recursive-pipeline-report.json', 'non-recursive-pipeline-report.md'],
|
|
66
|
-
performance_budget_ms: NON_RECURSIVE_PIPELINE_PERFORMANCE_BUDGET_MS
|
|
67
|
-
});
|
|
68
22
|
export function scanAgentTextForRecursion(text) {
|
|
69
23
|
const body = String(text || '');
|
|
70
24
|
const violations = AGENT_RECURSIVE_COMMAND_DENYLIST.filter((entry, index) => DENY_PATTERNS[index]?.test(body));
|
|
@@ -114,188 +68,6 @@ export function nextAgentGenerationEnv(env = process.env) {
|
|
|
114
68
|
export function agentGenerationDepthExceeded(env = process.env) {
|
|
115
69
|
return agentGenerationDepth(env) > MAX_AGENT_GENERATION_DEPTH;
|
|
116
70
|
}
|
|
117
|
-
export function assertNoAgentRecursion(text) {
|
|
118
|
-
const result = scanAgentTextForRecursion(text);
|
|
119
|
-
if (!result.ok)
|
|
120
|
-
throw new Error('Agent recursion blocked: ' + result.violations.join(', '));
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
export function scanNonRecursivePipelinePolicy(records, opts = {}) {
|
|
124
|
-
const started = Date.now();
|
|
125
|
-
const performanceBudgetMs = opts.performanceBudgetMs || NON_RECURSIVE_PIPELINE_PERFORMANCE_BUDGET_MS;
|
|
126
|
-
const violations = [];
|
|
127
|
-
const scannedRecords = [];
|
|
128
|
-
const redactionSamples = [];
|
|
129
|
-
const envCorpus = [];
|
|
130
|
-
const guardCorpus = [];
|
|
131
|
-
const workerCorpus = [];
|
|
132
|
-
const channelCoverage = {
|
|
133
|
-
stdout: false,
|
|
134
|
-
stderr: false,
|
|
135
|
-
agent_result: false
|
|
136
|
-
};
|
|
137
|
-
for (const record of records) {
|
|
138
|
-
const rel = normalizePath(record.path);
|
|
139
|
-
const text = String(record.text || '');
|
|
140
|
-
const channel = record.channel || classifyNonRecursivePipelinePath(rel);
|
|
141
|
-
scannedRecords.push({ path: rel, channel, bytes: Buffer.byteLength(text, 'utf8') });
|
|
142
|
-
redactionSamples.push(...collectSecretRedactionSamples(text));
|
|
143
|
-
if (channel === 'env' || rel.includes('agent-worker-pipeline'))
|
|
144
|
-
envCorpus.push(text);
|
|
145
|
-
if (rel.includes('agent-recursion-guard'))
|
|
146
|
-
guardCorpus.push(text);
|
|
147
|
-
if (isWorkerExecutionSurface(rel, channel)) {
|
|
148
|
-
workerCorpus.push(text);
|
|
149
|
-
scanWorkerExecutionSurface({ rel, text, channel, violations });
|
|
150
|
-
}
|
|
151
|
-
if (channel === 'stdout')
|
|
152
|
-
channelCoverage.stdout = true;
|
|
153
|
-
if (channel === 'stderr')
|
|
154
|
-
channelCoverage.stderr = true;
|
|
155
|
-
if (channel === 'agent_result')
|
|
156
|
-
channelCoverage.agent_result = true;
|
|
157
|
-
}
|
|
158
|
-
const envText = envCorpus.join('\n');
|
|
159
|
-
for (const token of AGENT_WORKER_ENV_GUARD_TOKENS) {
|
|
160
|
-
if (!envText.includes(token)) {
|
|
161
|
-
violations.push(nonRecursivePipelineViolation({
|
|
162
|
-
file: 'src/core/agents/agent-worker-pipeline.ts',
|
|
163
|
-
channel: 'env',
|
|
164
|
-
group: 'env guard',
|
|
165
|
-
rule_id: `missing_env_guard:${token}`,
|
|
166
|
-
snippet: token,
|
|
167
|
-
index: null
|
|
168
|
-
}));
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
const guardText = guardCorpus.join('\n');
|
|
172
|
-
for (const token of COMMAND_DENYLIST) {
|
|
173
|
-
if (!guardText.includes(token)) {
|
|
174
|
-
violations.push(nonRecursivePipelineViolation({
|
|
175
|
-
file: 'src/core/agents/agent-recursion-guard.ts',
|
|
176
|
-
channel: 'source',
|
|
177
|
-
group: 'command denylist',
|
|
178
|
-
rule_id: `missing_command_denylist:${token}`,
|
|
179
|
-
snippet: token,
|
|
180
|
-
index: null
|
|
181
|
-
}));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
for (const token of ROUTE_DENYLIST) {
|
|
185
|
-
if (!guardText.includes(token)) {
|
|
186
|
-
violations.push(nonRecursivePipelineViolation({
|
|
187
|
-
file: 'src/core/agents/agent-recursion-guard.ts',
|
|
188
|
-
channel: 'source',
|
|
189
|
-
group: 'route denylist',
|
|
190
|
-
rule_id: `missing_route_denylist:${token}`,
|
|
191
|
-
snippet: token,
|
|
192
|
-
index: null
|
|
193
|
-
}));
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const elapsedMs = Date.now() - started;
|
|
197
|
-
const ok = violations.length === 0;
|
|
198
|
-
const secretRedactionOk = violations.every((row) => !containsSecret(row.snippet));
|
|
199
|
-
const groupsWithViolations = new Set(violations.map((row) => row.group));
|
|
200
|
-
return {
|
|
201
|
-
schema: NON_RECURSIVE_PIPELINE_REPORT_SCHEMA,
|
|
202
|
-
ok,
|
|
203
|
-
generated_at: new Date().toISOString(),
|
|
204
|
-
local_only: true,
|
|
205
|
-
secret_redaction_ok: secretRedactionOk,
|
|
206
|
-
performance_budget_ms: performanceBudgetMs,
|
|
207
|
-
elapsed_ms: elapsedMs,
|
|
208
|
-
performance_ok: elapsedMs <= performanceBudgetMs,
|
|
209
|
-
scan_contract: NON_RECURSIVE_PIPELINE_SCAN_CONTRACT,
|
|
210
|
-
env_policy: {
|
|
211
|
-
schema: 'sks.agent-worker-env-policy.v1',
|
|
212
|
-
required_tokens: [...AGENT_WORKER_ENV_GUARD_TOKENS],
|
|
213
|
-
present: AGENT_WORKER_ENV_GUARD_TOKENS.filter((token) => envText.includes(token)),
|
|
214
|
-
missing: AGENT_WORKER_ENV_GUARD_TOKENS.filter((token) => !envText.includes(token))
|
|
215
|
-
},
|
|
216
|
-
denylist: {
|
|
217
|
-
schema: 'sks.agent-worker-recursion-denylist.v1',
|
|
218
|
-
commands: [...COMMAND_DENYLIST],
|
|
219
|
-
routes: [...ROUTE_DENYLIST]
|
|
220
|
-
},
|
|
221
|
-
scanned_records: scannedRecords,
|
|
222
|
-
channel_coverage: channelCoverage,
|
|
223
|
-
worker_surface_records: workerCorpus.length,
|
|
224
|
-
violations,
|
|
225
|
-
redaction_samples: [...new Set(redactionSamples)].slice(0, 20),
|
|
226
|
-
wrongness_records: violations.map((row) => ({
|
|
227
|
-
schema: 'sks.non-recursive-pipeline-wrongness.v1',
|
|
228
|
-
kind: 'agent_recursive_pipeline_attempt',
|
|
229
|
-
file: row.file,
|
|
230
|
-
channel: row.channel,
|
|
231
|
-
group: row.group,
|
|
232
|
-
rule_id: row.rule_id,
|
|
233
|
-
next_action: row.next_action
|
|
234
|
-
})),
|
|
235
|
-
proof: {
|
|
236
|
-
schema: 'sks.non-recursive-pipeline-proof.v1',
|
|
237
|
-
ok,
|
|
238
|
-
env_guard_configured: !groupsWithViolations.has('env guard'),
|
|
239
|
-
command_denylist_enforced: !groupsWithViolations.has('command denylist'),
|
|
240
|
-
route_denylist_enforced: !groupsWithViolations.has('route denylist'),
|
|
241
|
-
worker_mission_creation_blocked: !groupsWithViolations.has('worker mission creation block'),
|
|
242
|
-
current_json_write_blocked: !groupsWithViolations.has('current.json write block'),
|
|
243
|
-
top_level_command_blocked: !groupsWithViolations.has('top-level command block'),
|
|
244
|
-
stdout_transcript_scan: channelCoverage.stdout && !groupsWithViolations.has('stdout transcript scan'),
|
|
245
|
-
stderr_transcript_scan: channelCoverage.stderr && !groupsWithViolations.has('stderr transcript scan'),
|
|
246
|
-
agent_result_scan: channelCoverage.agent_result && !groupsWithViolations.has('agent result scan'),
|
|
247
|
-
wrongness_records_written: violations.length === 0 || violations.length === violations.map((row) => row.rule_id).length
|
|
248
|
-
},
|
|
249
|
-
trust_report: {
|
|
250
|
-
schema: 'sks.non-recursive-pipeline-trust.v1',
|
|
251
|
-
ok,
|
|
252
|
-
trust: ok ? 'high' : 'blocked',
|
|
253
|
-
evidence_count: scannedRecords.length,
|
|
254
|
-
local_only: true
|
|
255
|
-
},
|
|
256
|
-
evidence_router: {
|
|
257
|
-
schema: 'sks.non-recursive-pipeline-evidence-router.v1',
|
|
258
|
-
records: scannedRecords.map((row) => ({ file: row.path, channel: row.channel, source: 'local_scan', redacted: true })),
|
|
259
|
-
blocked_records: violations.length
|
|
260
|
-
},
|
|
261
|
-
next_action: ok
|
|
262
|
-
? 'keep agent workers non-recursive and continue writing proof through the parent orchestrator'
|
|
263
|
-
: 'remove nested route launches or state writes from worker surfaces before accepting agent proof'
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
export function nonRecursivePipelineMarkdown(report) {
|
|
267
|
-
const proof = report.proof || {};
|
|
268
|
-
const lines = [
|
|
269
|
-
'# Non-Recursive Agent Pipeline Report',
|
|
270
|
-
'',
|
|
271
|
-
`Status: ${report.ok ? 'passed' : 'blocked'}`,
|
|
272
|
-
`Generated: ${report.generated_at}`,
|
|
273
|
-
`Local only: ${report.local_only ? 'yes' : 'no'}`,
|
|
274
|
-
`Records scanned: ${report.scanned_records?.length || 0}`,
|
|
275
|
-
`Performance: ${report.elapsed_ms}ms / ${report.performance_budget_ms}ms`,
|
|
276
|
-
'',
|
|
277
|
-
'## Proof',
|
|
278
|
-
'',
|
|
279
|
-
`- env_guard_configured: ${Boolean(proof.env_guard_configured)}`,
|
|
280
|
-
`- command_denylist_enforced: ${Boolean(proof.command_denylist_enforced)}`,
|
|
281
|
-
`- route_denylist_enforced: ${Boolean(proof.route_denylist_enforced)}`,
|
|
282
|
-
`- worker_mission_creation_blocked: ${Boolean(proof.worker_mission_creation_blocked)}`,
|
|
283
|
-
`- current_json_write_blocked: ${Boolean(proof.current_json_write_blocked)}`,
|
|
284
|
-
`- top_level_command_blocked: ${Boolean(proof.top_level_command_blocked)}`,
|
|
285
|
-
`- stdout_transcript_scan: ${Boolean(proof.stdout_transcript_scan)}`,
|
|
286
|
-
`- stderr_transcript_scan: ${Boolean(proof.stderr_transcript_scan)}`,
|
|
287
|
-
`- agent_result_scan: ${Boolean(proof.agent_result_scan)}`,
|
|
288
|
-
`- wrongness_records_written: ${Boolean(proof.wrongness_records_written)}`,
|
|
289
|
-
'',
|
|
290
|
-
'## Violations',
|
|
291
|
-
''
|
|
292
|
-
];
|
|
293
|
-
if (!report.violations?.length)
|
|
294
|
-
lines.push('- none');
|
|
295
|
-
for (const violation of report.violations || [])
|
|
296
|
-
lines.push(`- ${violation.file}: ${violation.group}/${violation.rule_id} -> ${violation.next_action}`);
|
|
297
|
-
return `${lines.join('\n')}\n`;
|
|
298
|
-
}
|
|
299
71
|
export async function writeAgentRecursionGuardReport(dir, input) {
|
|
300
72
|
const result = scanAgentTextForRecursion(input);
|
|
301
73
|
const report = {
|
|
@@ -307,147 +79,6 @@ export async function writeAgentRecursionGuardReport(dir, input) {
|
|
|
307
79
|
await writeJsonAtomic(path.join(dir, 'agent-recursion-guard.json'), report);
|
|
308
80
|
return report;
|
|
309
81
|
}
|
|
310
|
-
function scanWorkerExecutionSurface(input) {
|
|
311
|
-
const transcriptGroup = transcriptGroupForChannel(input.channel);
|
|
312
|
-
scanPatterns(input.text, commandRules(COMMAND_DENYLIST), (rule, match) => {
|
|
313
|
-
input.violations.push(nonRecursivePipelineViolation({
|
|
314
|
-
file: input.rel,
|
|
315
|
-
channel: input.channel,
|
|
316
|
-
group: transcriptGroup || 'command denylist',
|
|
317
|
-
rule_id: rule.id,
|
|
318
|
-
snippet: match[0] || rule.id,
|
|
319
|
-
index: match.index ?? null
|
|
320
|
-
}));
|
|
321
|
-
input.violations.push(nonRecursivePipelineViolation({
|
|
322
|
-
file: input.rel,
|
|
323
|
-
channel: input.channel,
|
|
324
|
-
group: 'top-level command block',
|
|
325
|
-
rule_id: rule.id,
|
|
326
|
-
snippet: match[0] || rule.id,
|
|
327
|
-
index: match.index ?? null
|
|
328
|
-
}));
|
|
329
|
-
});
|
|
330
|
-
scanPatterns(input.text, commandRules(ROUTE_DENYLIST), (rule, match) => {
|
|
331
|
-
input.violations.push(nonRecursivePipelineViolation({
|
|
332
|
-
file: input.rel,
|
|
333
|
-
channel: input.channel,
|
|
334
|
-
group: transcriptGroup || 'route denylist',
|
|
335
|
-
rule_id: rule.id,
|
|
336
|
-
snippet: match[0] || rule.id,
|
|
337
|
-
index: match.index ?? null
|
|
338
|
-
}));
|
|
339
|
-
});
|
|
340
|
-
scanPatterns(input.text, WORKER_MISSION_CREATION_PATTERNS, (rule, match) => {
|
|
341
|
-
input.violations.push(nonRecursivePipelineViolation({
|
|
342
|
-
file: input.rel,
|
|
343
|
-
channel: input.channel,
|
|
344
|
-
group: 'worker mission creation block',
|
|
345
|
-
rule_id: rule.id,
|
|
346
|
-
snippet: match[0] || rule.id,
|
|
347
|
-
index: match.index ?? null
|
|
348
|
-
}));
|
|
349
|
-
});
|
|
350
|
-
scanPatterns(input.text, CURRENT_JSON_WRITE_PATTERNS, (rule, match) => {
|
|
351
|
-
input.violations.push(nonRecursivePipelineViolation({
|
|
352
|
-
file: input.rel,
|
|
353
|
-
channel: input.channel,
|
|
354
|
-
group: 'current.json write block',
|
|
355
|
-
rule_id: rule.id,
|
|
356
|
-
snippet: match[0] || rule.id,
|
|
357
|
-
index: match.index ?? null
|
|
358
|
-
}));
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
function scanPatterns(text, rules, onMatch) {
|
|
362
|
-
for (const rule of rules) {
|
|
363
|
-
const flags = rule.pattern.flags.includes('g') ? rule.pattern.flags : `${rule.pattern.flags}g`;
|
|
364
|
-
const pattern = new RegExp(rule.pattern.source, flags);
|
|
365
|
-
for (const match of text.matchAll(pattern))
|
|
366
|
-
onMatch(rule, match);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
function commandRules(entries) {
|
|
370
|
-
return entries.map((entry) => ({
|
|
371
|
-
id: entry,
|
|
372
|
-
pattern: entry.startsWith('$')
|
|
373
|
-
? new RegExp('(^|\\s)\\' + entry + '(\\s|$)', 'gi')
|
|
374
|
-
: new RegExp('(^|\\s)' + escapeRe(entry).replace(/\\ /g, '\\s+') + '(\\s|$)', 'gi')
|
|
375
|
-
}));
|
|
376
|
-
}
|
|
377
|
-
function nonRecursivePipelineViolation(input) {
|
|
378
|
-
return {
|
|
379
|
-
schema: 'sks.non-recursive-pipeline-violation.v1',
|
|
380
|
-
file: input.file,
|
|
381
|
-
channel: input.channel,
|
|
382
|
-
group: input.group,
|
|
383
|
-
rule_id: input.rule_id,
|
|
384
|
-
index: input.index,
|
|
385
|
-
snippet: redactPolicyText(input.snippet),
|
|
386
|
-
next_action: nextActionForNonRecursiveRule(input.group, input.rule_id)
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
function nextActionForNonRecursiveRule(group, ruleId) {
|
|
390
|
-
if (group === 'env guard')
|
|
391
|
-
return 'restore SKS_AGENT_WORKER and SKS_DISABLE_ROUTE_RECURSION in agentWorkerEnv';
|
|
392
|
-
if (group === 'worker mission creation block')
|
|
393
|
-
return 'move mission creation to the parent orchestrator and keep workers route-local';
|
|
394
|
-
if (group === 'current.json write block')
|
|
395
|
-
return 'remove global current.json writes from worker code and record state in agent ledgers';
|
|
396
|
-
if (group === 'top-level command block')
|
|
397
|
-
return `replace ${ruleId} with parent-owned orchestration or a read-only local check`;
|
|
398
|
-
if (group.endsWith('transcript scan') || group === 'agent result scan')
|
|
399
|
-
return 'block the worker result and convert the finding into an agent wrongness record';
|
|
400
|
-
if (group === 'route denylist')
|
|
401
|
-
return 'remove nested SKS dollar-route launch from the worker prompt or result';
|
|
402
|
-
return 'remove nested SKS route command from worker execution surfaces';
|
|
403
|
-
}
|
|
404
|
-
function transcriptGroupForChannel(channel) {
|
|
405
|
-
if (channel === 'stdout')
|
|
406
|
-
return 'stdout transcript scan';
|
|
407
|
-
if (channel === 'stderr')
|
|
408
|
-
return 'stderr transcript scan';
|
|
409
|
-
if (channel === 'agent_result')
|
|
410
|
-
return 'agent result scan';
|
|
411
|
-
return null;
|
|
412
|
-
}
|
|
413
|
-
function isWorkerExecutionSurface(rel, channel) {
|
|
414
|
-
if (channel === 'stdout' || channel === 'stderr' || channel === 'agent_result')
|
|
415
|
-
return true;
|
|
416
|
-
return /(?:^|\/)agent-worker-pipeline\.(?:ts|mjs|js)$/.test(rel) || /(?:^|\/)agent-runner-process\.(?:ts|mjs|js)$/.test(rel);
|
|
417
|
-
}
|
|
418
|
-
function classifyNonRecursivePipelinePath(file) {
|
|
419
|
-
const normalized = normalizePath(file);
|
|
420
|
-
if (normalized.endsWith('.json'))
|
|
421
|
-
return 'agent_result';
|
|
422
|
-
if (normalized.includes('/docs/') || normalized.startsWith('docs/'))
|
|
423
|
-
return 'docs';
|
|
424
|
-
return 'source';
|
|
425
|
-
}
|
|
426
|
-
function redactPolicyText(text) {
|
|
427
|
-
let out = String(text || '');
|
|
428
|
-
for (const rule of SECRET_PATTERNS)
|
|
429
|
-
out = out.replace(rule.pattern, `[REDACTED:${rule.id}]`);
|
|
430
|
-
return out;
|
|
431
|
-
}
|
|
432
|
-
function collectSecretRedactionSamples(text) {
|
|
433
|
-
const samples = [];
|
|
434
|
-
for (const rule of SECRET_PATTERNS) {
|
|
435
|
-
rule.pattern.lastIndex = 0;
|
|
436
|
-
const matches = [...String(text || '').matchAll(rule.pattern)];
|
|
437
|
-
for (const match of matches)
|
|
438
|
-
samples.push(redactPolicyText(match[0]));
|
|
439
|
-
}
|
|
440
|
-
return samples;
|
|
441
|
-
}
|
|
442
|
-
function containsSecret(text) {
|
|
443
|
-
return SECRET_PATTERNS.some((rule) => {
|
|
444
|
-
rule.pattern.lastIndex = 0;
|
|
445
|
-
return rule.pattern.test(String(text || ''));
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
function normalizePath(file) {
|
|
449
|
-
return String(file || '').replace(/\\/g, '/');
|
|
450
|
-
}
|
|
451
82
|
function escapeRe(value) {
|
|
452
83
|
return value.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
453
84
|
}
|
|
@@ -3,23 +3,9 @@ import os from 'node:os';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { nowIso, readText, writeJsonAtomic } from '../fsx.js';
|
|
5
5
|
import { inspectConfinedPath, moveConfinedPath, removeConfinedDirectoryIfEmpty, removeManagedPathVerified, uniqueConfinedPath, walkConfinedEntries } from '../managed-path-safety.js';
|
|
6
|
-
import { MANAGED_OFFICIAL_SUBAGENT_ROLES, RETIRED_MANAGED_AGENT_ROLE_TOMBSTONES, managedAgentRoleOwnsText
|
|
6
|
+
import { MANAGED_OFFICIAL_SUBAGENT_ROLES, RETIRED_MANAGED_AGENT_ROLE_TOMBSTONES, managedAgentRoleOwnsText } from '../managed-assets/managed-assets-manifest.js';
|
|
7
7
|
import { installOfficialSubagentAgentConfigs, refreshGlobalOfficialSubagentAgentConfigs } from '../subagents/official-subagent-config.js';
|
|
8
8
|
export const AGENT_ROLE_CONFIG_REPAIR_SCHEMA = 'sks.agent-role-config-repair.v1';
|
|
9
|
-
export const SKS_OWNED_AGENT_CONFIGS = new Map([
|
|
10
|
-
...MANAGED_OFFICIAL_SUBAGENT_ROLES.map((role) => [
|
|
11
|
-
role.filename,
|
|
12
|
-
{ name: role.codex_name, sandbox: role.sandbox ?? null, content: managedOfficialSubagentRoleContent(role), id: role.id }
|
|
13
|
-
]),
|
|
14
|
-
]);
|
|
15
|
-
export function managedAgentRoleConfigForFile(file) {
|
|
16
|
-
const official = managedOfficialSubagentRoleByFile(file);
|
|
17
|
-
return official ? managedOfficialSubagentRoleContent(official) : null;
|
|
18
|
-
}
|
|
19
|
-
export function managedAgentRoleConfigForRole(role) {
|
|
20
|
-
const official = managedOfficialSubagentRoleByName(role);
|
|
21
|
-
return official ? { file: official.filename, content: managedOfficialSubagentRoleContent(official) } : null;
|
|
22
|
-
}
|
|
23
9
|
export async function repairAgentRoleConfigs(input) {
|
|
24
10
|
const root = path.resolve(input.root);
|
|
25
11
|
const defaultHome = path.resolve(input.home || process.env.HOME || os.homedir());
|
|
@@ -1,56 +1,3 @@
|
|
|
1
|
-
import { validateAgentWorkerResult } from './agent-worker-pipeline.js';
|
|
2
|
-
export async function runFakeAgent(agent, slice, opts = {}) {
|
|
3
|
-
if (Number(slice?.delay_ms || 0) > 0)
|
|
4
|
-
await delay(Number(slice.delay_ms));
|
|
5
|
-
const patchEnvelopes = buildFixturePatchEnvelopes(agent, slice, opts);
|
|
6
|
-
return validateAgentWorkerResult({
|
|
7
|
-
mission_id: opts.missionId || opts.mission_id || '',
|
|
8
|
-
agent_id: agent.id,
|
|
9
|
-
session_id: agent.session_id,
|
|
10
|
-
persona_id: agent.persona_id || agent.id,
|
|
11
|
-
task_slice_id: slice?.id || '',
|
|
12
|
-
status: 'done',
|
|
13
|
-
backend: 'fake',
|
|
14
|
-
summary: 'Fixture agent ' + agent.id + ' completed ' + (slice?.id || 'slice') + ' for ' + (opts.route || 'agent-run') + '.',
|
|
15
|
-
findings: ['fixture agent completed assigned slice'],
|
|
16
|
-
proposed_changes: [],
|
|
17
|
-
changed_files: [],
|
|
18
|
-
lease_compliance: { ok: true, violations: [] },
|
|
19
|
-
artifacts: ['agent-events.jsonl', 'agent-task-board.json'],
|
|
20
|
-
blockers: [],
|
|
21
|
-
confidence: 'fixture',
|
|
22
|
-
handoff_notes: 'No handoff required for fake backend fixture.',
|
|
23
|
-
unverified: ['fake backend does not prove real parallel execution'],
|
|
24
|
-
writes: [],
|
|
25
|
-
...(patchEnvelopes.length ? { patch_envelopes: patchEnvelopes } : {}),
|
|
26
|
-
...(isBugfixSlice(slice) && patchEnvelopes.length ? { regression_proof: fixtureRegressionProof(slice) } : {}),
|
|
27
|
-
...(isRepairSlice(slice) && patchEnvelopes.length ? { repair_hypothesis: fixtureRepairHypothesis(slice) } : {}),
|
|
28
|
-
...(slice?.work_item_kind ? { work_item_kind: String(slice.work_item_kind) } : {}),
|
|
29
|
-
...(slice?.tournament_group_id ? { tournament: fixtureTournament(slice) } : {}),
|
|
30
|
-
source_intelligence_refs: agent.source_intelligence_refs || null,
|
|
31
|
-
goal_mode_ref: agent.goal_mode_ref || null,
|
|
32
|
-
...(opts.emitFollowUpWorkItems ? { follow_up_work_items: [buildFixtureFollowUp(agent, slice)] } : {}),
|
|
33
|
-
verification: { status: 'fixture', checks: ['schema-normalized-result'] },
|
|
34
|
-
recursion_guard: { ok: true, violations: [] }
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function delay(ms) {
|
|
38
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
39
|
-
}
|
|
40
|
-
function buildFixtureFollowUp(agent, slice) {
|
|
41
|
-
return {
|
|
42
|
-
id: `${String(slice?.id || agent.id)}-follow-up-001`,
|
|
43
|
-
title: 'Fixture follow-up work item',
|
|
44
|
-
description: 'Schema-valid follow-up generated by the fake backend fixture.',
|
|
45
|
-
required_persona_category: 'verifier',
|
|
46
|
-
priority: 100,
|
|
47
|
-
dependencies: [],
|
|
48
|
-
lease_requirements: [],
|
|
49
|
-
max_attempts: 1,
|
|
50
|
-
reason: 'exercise follow_up_work_items scheduler enqueue path',
|
|
51
|
-
source_agent_session_id: agent.session_id
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
1
|
export function buildFixturePatchEnvelopes(agent, slice, opts = {}) {
|
|
55
2
|
const writePaths = Array.isArray(slice?.write_paths) ? slice.write_paths.map(String).filter(Boolean) : [];
|
|
56
3
|
if (!writePaths.length)
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { DEFAULT_NARUTO_MAX_THREADS, HARD_NARUTO_MAX_THREADS } from '../subagents/thread-budget.js';
|
|
2
2
|
export { DEFAULT_NARUTO_MAX_THREADS, DEFAULT_NARUTO_REQUESTED_SUBAGENTS, HARD_NARUTO_MAX_THREADS } from '../subagents/thread-budget.js';
|
|
3
|
-
export const AGENT_KERNEL_SCHEMA = 'sks.native-agent-kernel.v1';
|
|
4
3
|
export const AGENT_RESULT_SCHEMA = 'sks.agent-result.v1';
|
|
5
4
|
export const AGENT_LEDGER_EVENT_SCHEMA = 'sks.agent-ledger-event.v1';
|
|
6
5
|
export const AGENT_PROOF_EVIDENCE_SCHEMA = 'sks.agent-proof-evidence.v1';
|
|
7
|
-
export const AGENT_WORKER_PIPELINE = 'AGENT_WORKER_PIPELINE';
|
|
8
|
-
export const AGENT_ORCHESTRATOR_PIPELINE = 'AGENT_ORCHESTRATOR_PIPELINE';
|
|
9
6
|
export const DEFAULT_AGENT_COUNT = 5;
|
|
10
|
-
export const AGENT_COUNT = DEFAULT_AGENT_COUNT;
|
|
11
7
|
export const OFFICIAL_SUBAGENT_EXECUTION_STAGE_ID = 'official_subagent_execution';
|
|
12
8
|
export const MAX_AGENT_COUNT = 20;
|
|
13
9
|
export const DEFAULT_AGENT_CONCURRENCY = DEFAULT_NARUTO_MAX_THREADS;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { appendJsonl, nowIso,
|
|
2
|
+
import { appendJsonl, nowIso, writeJsonAtomic } from '../fsx.js';
|
|
3
3
|
import { normalizeAgentFollowUpWorkItems } from './agent-follow-up-work-items.js';
|
|
4
4
|
export const AGENT_WORK_QUEUE_SCHEMA = 'sks.agent-work-queue.v1';
|
|
5
5
|
export const AGENT_WORK_QUEUE_EVENT_SCHEMA = 'sks.agent-work-queue-event.v1';
|
|
@@ -145,13 +145,3 @@ export async function appendAgentWorkQueueEvent(root, eventType, payload = {}) {
|
|
|
145
145
|
payload
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
-
export async function readAgentWorkQueue(root) {
|
|
149
|
-
return readJson(path.join(root, 'agent-work-queue.json'), {
|
|
150
|
-
schema: AGENT_WORK_QUEUE_SCHEMA,
|
|
151
|
-
updated_at: nowIso(),
|
|
152
|
-
total_work_items: 0,
|
|
153
|
-
generated_work_item_count: 0,
|
|
154
|
-
max_queue_expansion: 10,
|
|
155
|
-
items: []
|
|
156
|
-
});
|
|
157
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AGENT_RESULT_SCHEMA
|
|
1
|
+
import { AGENT_RESULT_SCHEMA } from './agent-schema.js';
|
|
2
2
|
import { normalizeAgentPatchEnvelope, validateAgentPatchEnvelope } from './agent-patch-schema.js';
|
|
3
3
|
import { scanAgentTextForRecursion } from './agent-recursion-guard.js';
|
|
4
4
|
import { validateAgentResultSchema, validateAndNormalizeAgentFollowUps } from './agent-output-validator.js';
|
|
@@ -117,24 +117,6 @@ function validWriteVerification(verification) {
|
|
|
117
117
|
return checks.length > 0;
|
|
118
118
|
return status === 'not_applicable' && Boolean(String(verification?.reason || '').trim());
|
|
119
119
|
}
|
|
120
|
-
export function agentWorkerPipelineContract() {
|
|
121
|
-
return {
|
|
122
|
-
schema: 'sks.agent-worker-pipeline.v1',
|
|
123
|
-
pipeline_id: AGENT_WORKER_PIPELINE,
|
|
124
|
-
creates_mission: false,
|
|
125
|
-
route_classifier_allowed: false,
|
|
126
|
-
writes_global_current_json: false,
|
|
127
|
-
route_finalizer_allowed: false,
|
|
128
|
-
writes_only_agent_session_and_central_ledger: true,
|
|
129
|
-
patch_envelope_result_fields: {
|
|
130
|
-
result_field: 'patch_envelopes',
|
|
131
|
-
required_for_write_tasks: true,
|
|
132
|
-
envelope_schema: 'sks.agent-patch-envelope.v1',
|
|
133
|
-
metadata: ['agent_id', 'session_id', 'slot_id', 'generation_index', 'lease_id_or_lease_proof'],
|
|
134
|
-
optional_hints: ['rationale', 'verification_hint', 'rollback_hint', 'cochange_acknowledged_reason', 'regression_proof', 'repair_hypothesis']
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
120
|
function normalizePatchEnvelopes(value) {
|
|
139
121
|
const envelopes = Array.isArray(value) ? value.map((raw) => ({
|
|
140
122
|
...normalizeAgentPatchEnvelope(raw),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { nowIso,
|
|
2
|
+
import { nowIso, writeJsonAtomic } from '../fsx.js';
|
|
3
3
|
export const AGENT_WORKER_SLOT_SCHEMA = 'sks.agent-worker-slot.v1';
|
|
4
4
|
export const AGENT_WORKER_SLOTS_SCHEMA = 'sks.agent-worker-slots.v1';
|
|
5
5
|
export function workerSlotId(index) {
|
|
@@ -84,12 +84,3 @@ export async function writeAgentWorkerSlots(root, slots) {
|
|
|
84
84
|
await writeJsonAtomic(path.join(root, 'agent-worker-slots.json'), artifact);
|
|
85
85
|
return artifact;
|
|
86
86
|
}
|
|
87
|
-
export async function readAgentWorkerSlots(root) {
|
|
88
|
-
return readJson(path.join(root, 'agent-worker-slots.json'), {
|
|
89
|
-
schema: AGENT_WORKER_SLOTS_SCHEMA,
|
|
90
|
-
updated_at: nowIso(),
|
|
91
|
-
slot_count: 0,
|
|
92
|
-
slots: [],
|
|
93
|
-
all_slots_closed_after_drain: false
|
|
94
|
-
});
|
|
95
|
-
}
|
|
@@ -14,7 +14,6 @@ export async function buildRuntimeProofSummary(root, missionIdInput = 'latest',
|
|
|
14
14
|
const scheduler = await readJson(path.join(agentsDir, 'agent-scheduler-state.json'), null);
|
|
15
15
|
const runtime = await readJson(path.join(agentsDir, 'native-cli-worker-runtime.json'), null);
|
|
16
16
|
const stopGate = await readJson(path.join(dir, 'stop-gate.json'), null);
|
|
17
|
-
const governor = await readJson(path.join(agentsDir, 'naruto-concurrency-governor.json'), null);
|
|
18
17
|
const messagesAll = await readAgentMessageBus(root, missionId, { max: 500 });
|
|
19
18
|
const recentMessages = await readAgentMessageBus(root, missionId, { max: opts.maxMessages || 8 });
|
|
20
19
|
const loopSummary = summarizeLoopGraphProof(await readLoopGraphProof(root, missionId).catch(() => null));
|
|
@@ -257,9 +257,6 @@ export async function refreshAlignGate(dir, missionId, rootInput) {
|
|
|
257
257
|
await writeJsonAtomic(path.join(dir, ALIGN_GATE_ARTIFACT), gate);
|
|
258
258
|
return { plan, ledger, gate };
|
|
259
259
|
}
|
|
260
|
-
export async function readAlignGate(dir) {
|
|
261
|
-
return readJson(path.join(dir, ALIGN_GATE_ARTIFACT), null);
|
|
262
|
-
}
|
|
263
260
|
export function alignNextActionText(missionId) {
|
|
264
261
|
return `Run sks align run ${missionId}; Align accepts an absent or existing TriWiki, rebuilds the code-only index from current repository bytes, replaces the active generation, and retains no previous generation.`;
|
|
265
262
|
}
|
|
@@ -19,7 +19,7 @@ import { clearContextGraphSnapshotCache, clearWorkspaceContextIndex } from '../t
|
|
|
19
19
|
import { withTriWikiStateLock } from '../triwiki/triwiki-cleanup.js';
|
|
20
20
|
import { publishArchitectureMapToStage } from '../triwiki/context-graph/store/architecture-map-store.js';
|
|
21
21
|
import { alignPendingRoot, alignPendingWiki, alignSourceFingerprint, projectAlignCodePack, publishAlignContextIndex } from './align-context-index.js';
|
|
22
|
-
import {
|
|
22
|
+
import { ALIGN_LEDGER_ARTIFACT, ALIGN_OUTPUT_ARTIFACTS, ALIGN_PLAN_ARTIFACT, ALIGN_STAGING_ROOT_REL, buildInitialAlignLedger, refreshAlignGate } from './align-route.js';
|
|
23
23
|
const WIKI_PREFIX = '.sneakoscope/wiki/';
|
|
24
24
|
function isArchitectureMapOptionalSkip(skip) {
|
|
25
25
|
const rel = skip.path.replace(/\\/g, '/');
|
|
@@ -2,7 +2,6 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { BRIDGE_PROVIDER_IDS } from '../../codex-lb/bridge-contracts.js';
|
|
3
3
|
import { canonicalizeBridgeModelId, normalizeBridgeUpstreamModelId } from '../../codex-lb/route-index.js';
|
|
4
4
|
import { canonicalJson } from '../../json/canonical.js';
|
|
5
|
-
export const ARCHITECTURE_HARDENING_CONTRACT_VERSION = 'sks.architecture-hardening.contracts.v2';
|
|
6
5
|
export const MAX_AUDIT_PROJECTION_DEPTH = 32;
|
|
7
6
|
export class ArchitectureContractError extends Error {
|
|
8
7
|
code;
|
|
@@ -125,9 +124,6 @@ export function stableArchitectureHash(value) {
|
|
|
125
124
|
const projection = createSafeAuditProjection(value);
|
|
126
125
|
return createHash('sha256').update(canonicalJson(projection)).digest('hex');
|
|
127
126
|
}
|
|
128
|
-
export function jsonRoundTrip(value) {
|
|
129
|
-
return JSON.parse(JSON.stringify(createSafeAuditProjection(value)));
|
|
130
|
-
}
|
|
131
127
|
function projectAuditValue(value, depth, ancestors) {
|
|
132
128
|
if (depth > MAX_AUDIT_PROJECTION_DEPTH)
|
|
133
129
|
fail('audit_projection_depth_exceeded');
|
|
@@ -5,24 +5,6 @@ import { ARCHITECTURE_CAPSULE_ARTIFACT, ARCHITECTURE_MAP_BASELINE_ARTIFACT, ARCH
|
|
|
5
5
|
import { readContextGraphSnapshot } from './triwiki/context-graph/store/snapshot-store.js';
|
|
6
6
|
export { ARCHITECTURE_MAP_REVIEW_ARTIFACT };
|
|
7
7
|
export const ARCHITECTURE_MAP_BASELINE_STAGE = 'architecture_map_baseline';
|
|
8
|
-
export const ARCHITECTURE_MAP_REVIEW_STAGE = 'architecture_map_review';
|
|
9
|
-
const ARCHITECTURE_MAP_EXEMPT_ROUTES = new Set([
|
|
10
|
-
'Answer',
|
|
11
|
-
'DFix',
|
|
12
|
-
'Help',
|
|
13
|
-
'Wiki',
|
|
14
|
-
'Goal',
|
|
15
|
-
'GX',
|
|
16
|
-
'DB'
|
|
17
|
-
]);
|
|
18
|
-
export function routeNeedsArchitectureMap(route) {
|
|
19
|
-
const id = String(route?.id || '');
|
|
20
|
-
if (!id)
|
|
21
|
-
return false;
|
|
22
|
-
if (ARCHITECTURE_MAP_EXEMPT_ROUTES.has(id))
|
|
23
|
-
return false;
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
8
|
export function createArchitectureMapPlanBinding() {
|
|
27
9
|
return Object.freeze({
|
|
28
10
|
baseline_artifact: ARCHITECTURE_MAP_BASELINE_ARTIFACT,
|
|
@@ -38,13 +20,6 @@ export function planStagesArchitectureMap(plan) {
|
|
|
38
20
|
&& plan.stages.some((stage) => String(stage?.id || '') === ARCHITECTURE_MAP_BASELINE_STAGE
|
|
39
21
|
&& !['skipped', 'not_applicable'].includes(String(stage?.status || '')));
|
|
40
22
|
}
|
|
41
|
-
export async function seedArchitectureMapPlanBinding(dir, plan) {
|
|
42
|
-
if (!planStagesArchitectureMap(plan))
|
|
43
|
-
return plan;
|
|
44
|
-
plan.architecture_map = createArchitectureMapPlanBinding();
|
|
45
|
-
await writeJsonAtomic(path.join(dir, 'pipeline-plan.json'), plan);
|
|
46
|
-
return plan;
|
|
47
|
-
}
|
|
48
23
|
export async function maybeSeedArchitectureMapForPlan(input) {
|
|
49
24
|
if (!input.plan?.architecture_map || !input.missionId) {
|
|
50
25
|
return { ok: false, reason: 'architecture_map_not_planned' };
|