@opengsd/gsd-core 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +2 -3
- package/.opencode/plugins/gsd-core.js +8 -1
- package/agents/gsd-code-fixer.md +131 -34
- package/agents/gsd-debugger.md +12 -246
- package/agents/gsd-executor.md +7 -5
- package/agents/gsd-integration-checker.md +3 -0
- package/agents/gsd-plan-checker.md +9 -0
- package/agents/gsd-planner.md +5 -8
- package/agents/gsd-roadmapper.md +21 -3
- package/agents/gsd-verifier.md +14 -70
- package/bin/install.js +503 -341
- package/commands/gsd/mempalace-capture.md +1 -1
- package/commands/gsd/new-milestone.md +1 -1
- package/commands/gsd/plan-phase.md +1 -1
- package/gsd-core/bin/gsd-tools.cjs +607 -63
- package/gsd-core/bin/lib/active-workstream-store.cjs +25 -0
- package/gsd-core/bin/lib/agent-install-check.cjs +38 -6
- package/gsd-core/bin/lib/api-coverage.cjs +120 -0
- package/gsd-core/bin/lib/audit.cjs +89 -1
- package/gsd-core/bin/lib/broken-windows.cjs +36 -6
- package/gsd-core/bin/lib/capability-registry.cjs +96 -110
- package/gsd-core/bin/lib/capability-validator.cjs +12 -2
- package/gsd-core/bin/lib/check-command-router.cjs +43 -1
- package/gsd-core/bin/lib/command-aliases.cjs +72 -0
- package/gsd-core/bin/lib/commands.cjs +26 -25
- package/gsd-core/bin/lib/commonjs-marker.cjs +136 -0
- package/gsd-core/bin/lib/config-loader.cjs +1 -0
- package/gsd-core/bin/lib/config.cjs +12 -1
- package/gsd-core/bin/lib/context-composer.cjs +278 -0
- package/gsd-core/bin/lib/context-predicates.cjs +506 -0
- package/gsd-core/bin/lib/core-utils.cjs +91 -12
- package/gsd-core/bin/lib/docs.cjs +3 -2
- package/gsd-core/bin/lib/external-job.cjs +19 -4
- package/gsd-core/bin/lib/frontmatter.cjs +84 -12
- package/gsd-core/bin/lib/gate-predicate-evaluator.cjs +57 -6
- package/gsd-core/bin/lib/git-base-branch.cjs +58 -15
- package/gsd-core/bin/lib/graphify.cjs +142 -27
- package/gsd-core/bin/lib/gsd2-import.cjs +27 -4
- package/gsd-core/bin/lib/host-integration.cjs +13 -1
- package/gsd-core/bin/lib/init-command-router.cjs +83 -8
- package/gsd-core/bin/lib/init.cjs +1021 -57
- package/gsd-core/bin/lib/install-engine.cjs +64 -10
- package/gsd-core/bin/lib/install-profiles.cjs +27 -1
- package/gsd-core/bin/lib/installer-migration-authoring.cjs +3 -1
- package/gsd-core/bin/lib/installer-migration-report.cjs +4 -0
- package/gsd-core/bin/lib/installer-migrations/007-retire-config-root-commonjs-marker.cjs +149 -0
- package/gsd-core/bin/lib/installer-migrations/008-cursor-retire-commands-surface.cjs +55 -0
- package/gsd-core/bin/lib/installer-migrations/009-pi-retire-reserved-hooks-dir.cjs +199 -0
- package/gsd-core/bin/lib/installer-migrations.cjs +87 -1
- package/gsd-core/bin/lib/io.cjs +28 -3
- package/gsd-core/bin/lib/markdown-sectionizer.cjs +6 -0
- package/gsd-core/bin/lib/mcp-catalog.cjs +518 -0
- package/gsd-core/bin/lib/mcp-server.cjs +135 -3
- package/gsd-core/bin/lib/milestone.cjs +106 -51
- package/gsd-core/bin/lib/phase-id.cjs +63 -0
- package/gsd-core/bin/lib/phase-locator.cjs +138 -45
- package/gsd-core/bin/lib/phase.cjs +260 -25
- package/gsd-core/bin/lib/plan-dependency-graph.cjs +232 -0
- package/gsd-core/bin/lib/planning-workspace.cjs +4 -0
- package/gsd-core/bin/lib/project-root.cjs +48 -0
- package/gsd-core/bin/lib/prompt-budget.cjs +128 -165
- package/gsd-core/bin/lib/retired-artifact-cleanup.cjs +80 -0
- package/gsd-core/bin/lib/review-lane-descriptor.cjs +99 -0
- package/gsd-core/bin/lib/review-lane-runner.cjs +30 -6
- package/gsd-core/bin/lib/roadmap-command-router.cjs +42 -9
- package/gsd-core/bin/lib/roadmap-parser.cjs +100 -18
- package/gsd-core/bin/lib/roadmap.cjs +37 -7
- package/gsd-core/bin/lib/runtime-artifact-conversion.cjs +195 -62
- package/gsd-core/bin/lib/runtime-artifact-layout.cjs +15 -3
- package/gsd-core/bin/lib/runtime-homes.cjs +154 -41
- package/gsd-core/bin/lib/runtime-hooks-surface.cjs +105 -41
- package/gsd-core/bin/lib/section-manifest.cjs +209 -0
- package/gsd-core/bin/lib/shell-command-projection.cjs +113 -27
- package/gsd-core/bin/lib/smart-entry.cjs +12 -0
- package/gsd-core/bin/lib/state-transition.cjs +73 -8
- package/gsd-core/bin/lib/state.cjs +151 -62
- package/gsd-core/bin/lib/surface.cjs +12 -1
- package/gsd-core/bin/lib/uat-predicate.cjs +11 -1
- package/gsd-core/bin/lib/uat.cjs +320 -21
- package/gsd-core/bin/lib/unusable-input.cjs +9 -0
- package/gsd-core/bin/lib/verification.cjs +29 -12
- package/gsd-core/bin/lib/verify.cjs +29 -5
- package/gsd-core/bin/lib/workflow-fragments.cjs +557 -0
- package/gsd-core/bin/lib/workstream-inventory-builder.cjs +181 -18
- package/gsd-core/bin/lib/workstream-inventory.cjs +519 -27
- package/gsd-core/bin/lib/workstream.cjs +6 -0
- package/gsd-core/bin/lib/worktree-base-ref.cjs +50 -6
- package/gsd-core/bin/lib/worktree-safety.cjs +276 -118
- package/gsd-core/bin/shared/config-schema.manifest.json +2 -0
- package/gsd-core/references/artifact-types.md +10 -3
- package/gsd-core/references/autonomous-ui-design-contract.md +42 -0
- package/gsd-core/references/debugger-techniques.md +255 -0
- package/gsd-core/references/research-documentation-lookup.md +5 -3
- package/gsd-core/references/specless-probe-fallback.md +7 -6
- package/gsd-core/references/verifier-wiring-patterns.md +100 -0
- package/gsd-core/references/worktree-branch-check.md +2 -2
- package/gsd-core/templates/summary-complex.md +2 -0
- package/gsd-core/templates/summary-minimal.md +2 -0
- package/gsd-core/templates/summary-standard.md +2 -0
- package/gsd-core/templates/summary.md +2 -0
- package/gsd-core/workflows/audit-milestone.md +3 -0
- package/gsd-core/workflows/autonomous/steps/converge-banner.md +1 -0
- package/gsd-core/workflows/autonomous/steps/converge-dispatch-bg.md +11 -0
- package/gsd-core/workflows/autonomous/steps/converge-dispatch-inline.md +7 -0
- package/gsd-core/workflows/autonomous/steps/converge-fail-fast.md +21 -0
- package/gsd-core/workflows/autonomous/steps/converge-loop.md +7 -0
- package/gsd-core/workflows/autonomous.md +32 -69
- package/gsd-core/workflows/code-review/steps/dispatch-fix.md +39 -0
- package/gsd-core/workflows/code-review/steps/structural-pre-pass.md +83 -0
- package/gsd-core/workflows/code-review.md +42 -145
- package/gsd-core/workflows/complete-milestone/steps/git-tag.md +29 -0
- package/gsd-core/workflows/complete-milestone.md +23 -81
- package/gsd-core/workflows/debug.md +9 -12
- package/gsd-core/workflows/diagnose-issues.md +22 -0
- package/gsd-core/workflows/discovery-phase.md +4 -4
- package/gsd-core/workflows/discuss-phase-assumptions/steps/auto-advance-dispatch.md +15 -0
- package/gsd-core/workflows/discuss-phase-assumptions.md +5 -16
- package/gsd-core/workflows/docs-update/steps/dispatch-monorepo-packages.md +51 -0
- package/gsd-core/workflows/docs-update.md +8 -51
- package/gsd-core/workflows/execute-phase/steps/executor-isolation-dispatch.md +34 -2
- package/gsd-core/workflows/execute-phase/steps/gap-closure-artifacts.md +50 -0
- package/gsd-core/workflows/execute-phase/steps/partial-wave.md +31 -0
- package/gsd-core/workflows/execute-phase/steps/per-plan-worktree-gate.md +19 -0
- package/gsd-core/workflows/execute-phase/steps/regression-gate-run.md +42 -0
- package/gsd-core/workflows/execute-phase/steps/regression-gate.md +43 -37
- package/gsd-core/workflows/execute-phase.md +65 -137
- package/gsd-core/workflows/execute-plan.md +1 -1
- package/gsd-core/workflows/help/modes/full.md +6 -1
- package/gsd-core/workflows/ingest-docs.md +2 -1
- package/gsd-core/workflows/new-milestone/steps/project-md-milestone-write.md +16 -0
- package/gsd-core/workflows/new-milestone/steps/reset-phase-safety.md +19 -0
- package/gsd-core/workflows/new-milestone.md +21 -38
- package/gsd-core/workflows/new-project/steps/auto-mode-config.md +176 -0
- package/gsd-core/workflows/new-project/steps/auto-mode-detection.md +32 -0
- package/gsd-core/workflows/new-project/steps/codebase-map-offer.md +18 -0
- package/gsd-core/workflows/new-project.md +13 -226
- package/gsd-core/workflows/plan-phase/steps/adr-ingest-express-path.md +15 -0
- package/gsd-core/workflows/plan-phase/steps/chunked-planning-mode.md +110 -0
- package/gsd-core/workflows/plan-phase/steps/prd-express-gate.md +8 -0
- package/gsd-core/workflows/plan-phase/steps/research-only-early-exit.md +17 -0
- package/gsd-core/workflows/plan-phase/steps/research-only-modifiers.md +16 -0
- package/gsd-core/workflows/plan-phase/steps/reviews-prerequisite.md +17 -0
- package/gsd-core/workflows/plan-phase/steps/stall-detection-helpers.md +149 -0
- package/gsd-core/workflows/plan-phase.md +49 -193
- package/gsd-core/workflows/progress/steps/forensic-audit.md +125 -0
- package/gsd-core/workflows/progress/steps/mvp-display.md +18 -0
- package/gsd-core/workflows/progress.md +11 -153
- package/gsd-core/workflows/quick/steps/discussion-phase.md +124 -0
- package/gsd-core/workflows/quick/steps/plan-checker-loop.md +111 -0
- package/gsd-core/workflows/quick/steps/quick-verification.md +46 -0
- package/gsd-core/workflows/quick/steps/research-phase.md +72 -0
- package/gsd-core/workflows/quick/steps/worktree-pre-dispatch-commit.md +37 -0
- package/gsd-core/workflows/quick.md +20 -390
- package/gsd-core/workflows/resume-project.md +3 -0
- package/gsd-core/workflows/review/steps/reviewer-instances-note-1.md +4 -0
- package/gsd-core/workflows/review/steps/reviewer-instances-note-2.md +3 -0
- package/gsd-core/workflows/review.md +15 -8
- package/gsd-core/workflows/section-manifest.json +219 -0
- package/gsd-core/workflows/sketch.md +1 -1
- package/gsd-core/workflows/spec-phase.md +17 -14
- package/gsd-core/workflows/spike-wrap-up.md +20 -5
- package/gsd-core/workflows/spike.md +50 -16
- package/gsd-core/workflows/sync-skills.md +49 -11
- package/gsd-core/workflows/transition/steps/workstream-collision-check.md +17 -0
- package/gsd-core/workflows/transition.md +8 -21
- package/gsd-core/workflows/ui-phase.md +8 -7
- package/gsd-core/workflows/update/steps/channel-banner.md +7 -0
- package/gsd-core/workflows/update.md +18 -7
- package/gsd-core/workflows/verify-phase.md +4 -7
- package/gsd-core/workflows/verify-work/steps/automated-ui-verification.md +36 -0
- package/gsd-core/workflows/verify-work/steps/mvp-uat-framing.md +21 -0
- package/gsd-core/workflows/verify-work.md +8 -58
- package/hooks/dist/gsd-agent-isolation-guard.js +428 -0
- package/hooks/dist/gsd-check-update-worker.js +14 -5
- package/hooks/dist/gsd-cursor-subagent-start.js +532 -26
- package/hooks/dist/gsd-read-injection-scanner.js +7 -0
- package/hooks/dist/gsd-statusline.js +72 -6
- package/hooks/dist/gsd-worktree-path-guard.js +2 -1
- package/hooks/dist/gsd-write-guard.js +359 -0
- package/hooks/dist/lib/isolation-sentinel.js +268 -0
- package/hooks/dist/managed-hooks-registry.cjs +2 -0
- package/hooks/gsd-agent-isolation-guard.js +428 -0
- package/hooks/gsd-check-update-worker.js +14 -5
- package/hooks/gsd-cursor-subagent-start.js +532 -26
- package/hooks/gsd-read-injection-scanner.js +7 -0
- package/hooks/gsd-statusline.js +72 -6
- package/hooks/gsd-worktree-path-guard.js +2 -1
- package/hooks/gsd-write-guard.js +359 -0
- package/hooks/hooks.json +12 -0
- package/hooks/lib/isolation-sentinel.js +268 -0
- package/hooks/managed-hooks-registry.cjs +2 -0
- package/package.json +14 -5
- package/pi/gsd.cjs +57 -12
- package/scripts/build-hooks.js +9 -0
- package/scripts/changeset/lint.cjs +9 -2
- package/scripts/changeset/serialize.cjs +5 -1
- package/scripts/gen-capability-matrix.cjs +1 -1
- package/scripts/gen-context-index.cjs +448 -0
- package/scripts/gen-inventory-manifest.cjs +101 -1
- package/scripts/gen-prompt-budget-parity-corpus.cjs +645 -0
- package/scripts/gen-registry.cjs +39 -15
- package/scripts/gen-section-manifest.cjs +638 -0
- package/scripts/generate-package-identity.cjs +4 -2
- package/scripts/lint-allow-test-rule-refs.allowlist.json +17 -31
- package/scripts/lint-compiled-artifact-sync.cjs +6 -1
- package/scripts/lint-docs-command-form.cjs +195 -0
- package/scripts/lint-docs-required.cjs +9 -1
- package/scripts/lint-emitted-drift-ack.cjs +215 -20
- package/scripts/lint-example-parser-parity.cjs +395 -0
- package/scripts/lint-test-file-count.allowlist.json +27 -1
- package/scripts/mutation-matrix.cjs +13 -0
- package/scripts/prompt-injection-scan.sh +27 -6
- package/scripts/registry-schema.cjs +323 -94
- package/scripts/run-tests.cjs +3 -2
- package/scripts/validate-registry.cjs +10 -6
- package/skills/gsd-autonomous/SKILL.md +1 -1
- package/skills/gsd-execute-phase/SKILL.md +1 -1
- package/skills/gsd-mempalace-capture/SKILL.md +1 -1
- package/skills/gsd-new-milestone/SKILL.md +1 -1
- package/skills/gsd-plan-phase/SKILL.md +2 -2
- package/vscode/package.json +1 -1
- package/scripts/gen-emitted-baseline.cjs +0 -145
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* lint-example-parser-parity.cjs — asserts examples/dynamic-context-management/
|
|
6
|
+
* context-predicates.cjs (reference prototype, ADR-1671) and production's
|
|
7
|
+
* src/context-predicates.cts (compiled to gsd-core/bin/lib/context-predicates.cjs)
|
|
8
|
+
* agree on parsing behavior, and that the example's own committed
|
|
9
|
+
* CONTEXT-INDEX.json has not silently drifted from a fresh parse.
|
|
10
|
+
*
|
|
11
|
+
* Lives OUTSIDE tests/ deliberately. ADR-1671
|
|
12
|
+
* (docs/adr/1671-dynamic-context-management-platform.md:102) places
|
|
13
|
+
* examples/dynamic-context-management/ outside FOUR surfaces: the build
|
|
14
|
+
* (src/ -> bin/lib/), the npm package files[], the installer, and the CI test
|
|
15
|
+
* suite (tests/). A lint script wired into `npm run lint:ci` is none of
|
|
16
|
+
* those four — it does not compile, package, install, or test-suite-import
|
|
17
|
+
* the example; it only READS both modules from a repo-root script and
|
|
18
|
+
* asserts they agree, the same shape as every other scripts/lint-*.cjs in
|
|
19
|
+
* this repo that reads source it does not own (see e.g.
|
|
20
|
+
* lint-compiled-artifact-sync.cjs).
|
|
21
|
+
*
|
|
22
|
+
* Two parity surfaces:
|
|
23
|
+
* 1. production vs. example, parsed against the real repo-root CONTEXT.md:
|
|
24
|
+
* predicate count, class map, duplicate-id set, the full set of
|
|
25
|
+
* (id, value) pairs, and a representative accept/reject id-shape table
|
|
26
|
+
* (including the embedded-CR-in-value case production already rejected
|
|
27
|
+
* and the example silently accepted before this fix).
|
|
28
|
+
* 2. the example's OWN committed CONTEXT-INDEX.json vs. a fresh parse by
|
|
29
|
+
* the example's own parser of the real CONTEXT.md — LINE-NUMBER-
|
|
30
|
+
* INDEPENDENT (see below). This guards the same #2944 merge-race
|
|
31
|
+
* staleness class this PR fixed for docs/CONTEXT-INDEX.json, but for the
|
|
32
|
+
* example's own copy, which nothing previously guarded at all.
|
|
33
|
+
*
|
|
34
|
+
* Why `line` is excluded from surface 2 (ADR-1671 open question 4): the
|
|
35
|
+
* example's CONTEXT-INDEX.json bakes source line numbers into every
|
|
36
|
+
* predicate entry. Any unrelated CONTEXT.md line-shift (e.g. inserting a
|
|
37
|
+
* sentence above the predicates) re-drifts that artifact even though every
|
|
38
|
+
* predicate id/value/class is byte-identical. Wiring the example's own
|
|
39
|
+
* `gen-context-index.cjs --check` into lint:ci — which DOES compare line
|
|
40
|
+
* numbers — would make CI routinely red for reasons unrelated to predicate
|
|
41
|
+
* integrity. This lint instead derives the LINE-INDEPENDENT facts from the
|
|
42
|
+
* committed index (count, class map, duplicate-id set, (id,value) pairs) and
|
|
43
|
+
* compares those to a fresh parse: genuine content drift (the #2944
|
|
44
|
+
* merge-race defect class) is still caught; a pure line-shift is not.
|
|
45
|
+
*
|
|
46
|
+
* `--context-path` / `--example-index-path` override the two hardcoded paths
|
|
47
|
+
* (mirrors scripts/gen-context-index.cjs) so this script's non-vacuousness
|
|
48
|
+
* can be proven against a throwaway temp fixture without ever touching the
|
|
49
|
+
* real committed artifacts.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
const fs = require('node:fs');
|
|
53
|
+
const path = require('node:path');
|
|
54
|
+
|
|
55
|
+
const { ExitError, runMain } = require('./lib/cli-exit.cjs');
|
|
56
|
+
|
|
57
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
58
|
+
const PROD_PREDICATES_PATH = path.join(ROOT, 'gsd-core', 'bin', 'lib', 'context-predicates.cjs');
|
|
59
|
+
const EXAMPLE_DIR = path.join(ROOT, 'examples', 'dynamic-context-management');
|
|
60
|
+
const EXAMPLE_PREDICATES_PATH = path.join(EXAMPLE_DIR, 'context-predicates.cjs');
|
|
61
|
+
const DEFAULT_EXAMPLE_INDEX_PATH = path.join(EXAMPLE_DIR, 'CONTEXT-INDEX.json');
|
|
62
|
+
const DEFAULT_CONTEXT_PATH = path.join(ROOT, 'CONTEXT.md');
|
|
63
|
+
|
|
64
|
+
// ─── Loaders ──────────────────────────────────────────────────────────────────
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Load the compiled production predicates library. Throws a clean ExitError
|
|
68
|
+
* (never a bare MODULE_NOT_FOUND stack) naming the remedy when it is missing.
|
|
69
|
+
*/
|
|
70
|
+
function loadProdPredicates() {
|
|
71
|
+
try {
|
|
72
|
+
delete require.cache[require.resolve(PROD_PREDICATES_PATH)];
|
|
73
|
+
return require(PROD_PREDICATES_PATH);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
throw new ExitError(
|
|
76
|
+
1,
|
|
77
|
+
`Cannot load ${path.relative(ROOT, PROD_PREDICATES_PATH)}: ${err && err.message}\n` +
|
|
78
|
+
'Run:\n npm run build:lib\n',
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Load the example's self-contained predicates module (no build step). */
|
|
84
|
+
function loadExamplePredicates() {
|
|
85
|
+
delete require.cache[require.resolve(EXAMPLE_PREDICATES_PATH)];
|
|
86
|
+
return require(EXAMPLE_PREDICATES_PATH);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Read a CONTEXT.md-shaped markdown file. Throws a clean ExitError naming the
|
|
91
|
+
* path when it is missing or unreadable.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} contextPath
|
|
94
|
+
* @returns {string}
|
|
95
|
+
*/
|
|
96
|
+
function readContextMarkdown(contextPath) {
|
|
97
|
+
try {
|
|
98
|
+
return fs.readFileSync(contextPath, 'utf8');
|
|
99
|
+
} catch (err) {
|
|
100
|
+
throw new ExitError(1, `Cannot read ${path.relative(ROOT, contextPath)}: ${err && err.message}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ─── Diffing helpers ────────────────────────────────────────────────────────
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Diff two predicate-shaped arrays by id, comparing ONLY `klass`/`value`
|
|
108
|
+
* (never `line`/`section` — see the module doc comment's "Why `line` is
|
|
109
|
+
* excluded"). Returns human-readable divergence strings naming the exact
|
|
110
|
+
* predicate id(s), so a failure reads as an actionable list, never "objects
|
|
111
|
+
* differ".
|
|
112
|
+
*
|
|
113
|
+
* @param {Array<{id:string,klass:string,value:string}>} leftPredicates
|
|
114
|
+
* @param {Array<{id:string,klass:string,value:string}>} rightPredicates
|
|
115
|
+
* @param {string} leftLabel
|
|
116
|
+
* @param {string} rightLabel
|
|
117
|
+
* @returns {string[]}
|
|
118
|
+
*/
|
|
119
|
+
function diffPredicatesById(leftPredicates, rightPredicates, leftLabel, rightLabel) {
|
|
120
|
+
const leftMap = new Map(leftPredicates.map((p) => [p.id, p]));
|
|
121
|
+
const rightMap = new Map(rightPredicates.map((p) => [p.id, p]));
|
|
122
|
+
const allIds = new Set([...leftMap.keys(), ...rightMap.keys()]);
|
|
123
|
+
const diffs = [];
|
|
124
|
+
for (const id of Array.from(allIds).sort()) {
|
|
125
|
+
const l = leftMap.get(id);
|
|
126
|
+
const r = rightMap.get(id);
|
|
127
|
+
if (l && !r) {
|
|
128
|
+
diffs.push(`${id}: present in ${leftLabel} but absent from ${rightLabel}`);
|
|
129
|
+
} else if (!l && r) {
|
|
130
|
+
diffs.push(`${id}: present in ${rightLabel} but absent from ${leftLabel}`);
|
|
131
|
+
} else if (l.value !== r.value) {
|
|
132
|
+
diffs.push(
|
|
133
|
+
`${id}: value diverged (${leftLabel}=${JSON.stringify(l.value)}, ${rightLabel}=${JSON.stringify(r.value)})`,
|
|
134
|
+
);
|
|
135
|
+
} else if (l.klass !== r.klass) {
|
|
136
|
+
diffs.push(
|
|
137
|
+
`${id}: klass diverged (${leftLabel}=${JSON.stringify(l.klass)}, ${rightLabel}=${JSON.stringify(r.klass)})`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return diffs;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Sorted, deduplicated id list from a `duplicates` array (either `{id,count}` or `{id,lines}` shape). */
|
|
145
|
+
function duplicateIds(duplicates) {
|
|
146
|
+
return duplicates.map((d) => d.id).sort();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Build a single-line `` `id=value` `` markdown fixture wrapping one candidate id=value pair. */
|
|
150
|
+
function backtickLine(idEqualsValue) {
|
|
151
|
+
return '`' + idEqualsValue + '`';
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Representative accept/reject id-shape table both parsers must agree on —
|
|
155
|
+
// this is what PROVES the parity claim rather than merely asserting it.
|
|
156
|
+
// FINDING 4 (ADR-1671 PR review): the embedded-CR-in-value case below was the
|
|
157
|
+
// one real divergence the earlier parity claim missed — production rejected
|
|
158
|
+
// it, the example silently accepted it. Both now reject it (ported fix).
|
|
159
|
+
const ID_SHAPE_CASES = [
|
|
160
|
+
{ idEqualsValue: 'A=1', expectAccept: true },
|
|
161
|
+
{ idEqualsValue: 'FOO=x', expectAccept: true },
|
|
162
|
+
{ idEqualsValue: 'PRED.k320.rule=x', expectAccept: true },
|
|
163
|
+
{ idEqualsValue: 'RELEASE-NOTES.x=y', expectAccept: true },
|
|
164
|
+
{ idEqualsValue: 'A..b=1', expectAccept: false },
|
|
165
|
+
{ idEqualsValue: 'foo.bar=x', expectAccept: false },
|
|
166
|
+
{ idEqualsValue: 'FOO BAR=x', expectAccept: false },
|
|
167
|
+
{ idEqualsValue: '=v', expectAccept: false },
|
|
168
|
+
{ idEqualsValue: 'ID', expectAccept: false },
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The embedded-CR case needs its own fixture, not the plain
|
|
173
|
+
* `` `ID=value` `` shape backtickLine() builds: a lone CR with no following
|
|
174
|
+
* LF never reaches a closing backtick at all (a separate, documented parser
|
|
175
|
+
* limit — see src/context-predicates.cts's module doc comment), so the CR
|
|
176
|
+
* must sit INSIDE an otherwise well-formed, LF-terminated backtick line.
|
|
177
|
+
*/
|
|
178
|
+
const CR_VALUE_MARKDOWN = '`ID=ab\rcd`\n';
|
|
179
|
+
|
|
180
|
+
// ─── Parity checks (surface 1: production vs. example) ────────────────────────
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @param {object} prodPredicates
|
|
184
|
+
* @param {object} examplePredicates
|
|
185
|
+
* @param {string} markdown
|
|
186
|
+
* @returns {string[]} diagnostics; empty when the two parsers fully agree
|
|
187
|
+
*/
|
|
188
|
+
function checkProdExampleParity(prodPredicates, examplePredicates, markdown) {
|
|
189
|
+
const diagnostics = [];
|
|
190
|
+
|
|
191
|
+
const prodParsed = prodPredicates.parsePredicates(markdown);
|
|
192
|
+
const exampleParsed = examplePredicates.parsePredicates(markdown);
|
|
193
|
+
const prodIndex = prodPredicates.buildIndex(prodParsed.predicates);
|
|
194
|
+
const exampleIndex = examplePredicates.buildIndex(exampleParsed.predicates);
|
|
195
|
+
|
|
196
|
+
if (exampleIndex.count !== prodIndex.count) {
|
|
197
|
+
diagnostics.push(`predicate count diverged: example=${exampleIndex.count} production=${prodIndex.count}`);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const prodClassKeys = Object.keys(prodIndex.classes).sort();
|
|
201
|
+
const exampleClassKeys = Object.keys(exampleIndex.classes).sort();
|
|
202
|
+
if (JSON.stringify(exampleClassKeys) !== JSON.stringify(prodClassKeys)) {
|
|
203
|
+
diagnostics.push(
|
|
204
|
+
`class set diverged: example=${JSON.stringify(exampleClassKeys)} production=${JSON.stringify(prodClassKeys)}`,
|
|
205
|
+
);
|
|
206
|
+
} else if (JSON.stringify(exampleIndex.classes) !== JSON.stringify(prodIndex.classes)) {
|
|
207
|
+
diagnostics.push(
|
|
208
|
+
`per-class predicate counts diverged: example=${JSON.stringify(exampleIndex.classes)} ` +
|
|
209
|
+
`production=${JSON.stringify(prodIndex.classes)}`,
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const prodDupIds = duplicateIds(prodIndex.duplicates);
|
|
214
|
+
const exampleDupIds = duplicateIds(exampleIndex.duplicates);
|
|
215
|
+
if (JSON.stringify(exampleDupIds) !== JSON.stringify(prodDupIds)) {
|
|
216
|
+
diagnostics.push(
|
|
217
|
+
`duplicate-id set diverged: example=${JSON.stringify(exampleDupIds)} production=${JSON.stringify(prodDupIds)}`,
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
diagnostics.push(...diffPredicatesById(exampleIndex.predicates, prodIndex.predicates, 'example', 'production'));
|
|
222
|
+
|
|
223
|
+
for (const { idEqualsValue, expectAccept } of ID_SHAPE_CASES) {
|
|
224
|
+
const line = backtickLine(idEqualsValue);
|
|
225
|
+
const exampleCount = examplePredicates.parsePredicates(line).predicates.length;
|
|
226
|
+
const prodCount = prodPredicates.parsePredicates(line).predicates.length;
|
|
227
|
+
if (exampleCount !== prodCount) {
|
|
228
|
+
diagnostics.push(
|
|
229
|
+
`id-shape verdict diverged for ${JSON.stringify(idEqualsValue)}: ` +
|
|
230
|
+
`example found ${exampleCount} predicate(s), production found ${prodCount}`,
|
|
231
|
+
);
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
const actualAccept = prodCount === 1;
|
|
235
|
+
if (actualAccept !== expectAccept) {
|
|
236
|
+
diagnostics.push(
|
|
237
|
+
`id-shape verdict wrong for ${JSON.stringify(idEqualsValue)}: expected ` +
|
|
238
|
+
`${expectAccept ? 'ACCEPT' : 'REJECT'}, both modules agreed on ${actualAccept ? 'ACCEPT' : 'REJECT'} instead`,
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const exampleCrCount = examplePredicates.parsePredicates(CR_VALUE_MARKDOWN).predicates.length;
|
|
244
|
+
const prodCrCount = prodPredicates.parsePredicates(CR_VALUE_MARKDOWN).predicates.length;
|
|
245
|
+
if (exampleCrCount !== prodCrCount) {
|
|
246
|
+
diagnostics.push(
|
|
247
|
+
`id-shape verdict diverged for embedded-CR-in-value: example found ${exampleCrCount} predicate(s), ` +
|
|
248
|
+
`production found ${prodCrCount}`,
|
|
249
|
+
);
|
|
250
|
+
} else if (prodCrCount !== 0) {
|
|
251
|
+
diagnostics.push(
|
|
252
|
+
`embedded-CR-in-value must be REJECTED by both parsers; both instead ACCEPTED it (${prodCrCount} predicate(s))`,
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return diagnostics;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// ─── Parity check (surface 2: example's committed index vs. fresh parse) ──────
|
|
260
|
+
|
|
261
|
+
/** Strip a predicate down to the line-number-independent fields used for comparison. */
|
|
262
|
+
function toLineIndependent(p) {
|
|
263
|
+
return { id: p.id, klass: p.klass, value: p.value };
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @param {object} examplePredicates
|
|
268
|
+
* @param {string} markdown
|
|
269
|
+
* @param {string} exampleIndexPath
|
|
270
|
+
* @returns {string[]} diagnostics; empty when the committed index and a fresh
|
|
271
|
+
* parse agree on every LINE-NUMBER-INDEPENDENT fact
|
|
272
|
+
*/
|
|
273
|
+
function checkExampleIndexParity(examplePredicates, markdown, exampleIndexPath) {
|
|
274
|
+
const diagnostics = [];
|
|
275
|
+
|
|
276
|
+
let committed;
|
|
277
|
+
try {
|
|
278
|
+
committed = JSON.parse(fs.readFileSync(exampleIndexPath, 'utf8'));
|
|
279
|
+
} catch (err) {
|
|
280
|
+
diagnostics.push(`cannot read/parse ${exampleIndexPath}: ${err && err.message}`);
|
|
281
|
+
return diagnostics;
|
|
282
|
+
}
|
|
283
|
+
if (!committed || !Array.isArray(committed.predicates)) {
|
|
284
|
+
diagnostics.push(`${exampleIndexPath} does not have the expected ContextIndex shape`);
|
|
285
|
+
return diagnostics;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const { predicates } = examplePredicates.parsePredicates(markdown);
|
|
289
|
+
const fresh = examplePredicates.buildIndex(predicates);
|
|
290
|
+
|
|
291
|
+
if (committed.count !== fresh.count) {
|
|
292
|
+
diagnostics.push(`example index predicate count diverged: committed=${committed.count} fresh=${fresh.count}`);
|
|
293
|
+
}
|
|
294
|
+
if (JSON.stringify(committed.classes) !== JSON.stringify(fresh.classes)) {
|
|
295
|
+
diagnostics.push(
|
|
296
|
+
`example index class-count map diverged: committed=${JSON.stringify(committed.classes)} ` +
|
|
297
|
+
`fresh=${JSON.stringify(fresh.classes)}`,
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const committedDupIds = duplicateIds(committed.duplicates || []);
|
|
302
|
+
const freshDupIds = duplicateIds(fresh.duplicates);
|
|
303
|
+
if (JSON.stringify(committedDupIds) !== JSON.stringify(freshDupIds)) {
|
|
304
|
+
diagnostics.push(
|
|
305
|
+
`example index duplicate-id set diverged: committed=${JSON.stringify(committedDupIds)} ` +
|
|
306
|
+
`fresh=${JSON.stringify(freshDupIds)}`,
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const committedIndependent = committed.predicates.map(toLineIndependent);
|
|
311
|
+
const freshIndependent = fresh.predicates.map(toLineIndependent);
|
|
312
|
+
const diffs = diffPredicatesById(committedIndependent, freshIndependent, 'committed example index', 'fresh parse');
|
|
313
|
+
diagnostics.push(...diffs.map((d) => `example index: ${d}`));
|
|
314
|
+
|
|
315
|
+
return diagnostics;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// ─── Argument parsing ─────────────────────────────────────────────────────────
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* @param {string[]} argv - process.argv.slice(2)
|
|
322
|
+
* @returns {{ contextPath: string, exampleIndexPath: string }}
|
|
323
|
+
*/
|
|
324
|
+
function parseArgs(argv) {
|
|
325
|
+
const opts = { contextPath: DEFAULT_CONTEXT_PATH, exampleIndexPath: DEFAULT_EXAMPLE_INDEX_PATH };
|
|
326
|
+
for (let i = 0; i < argv.length; i++) {
|
|
327
|
+
const arg = argv[i];
|
|
328
|
+
if (arg === '--context-path') {
|
|
329
|
+
opts.contextPath = path.resolve(argv[++i] ?? '');
|
|
330
|
+
} else if (arg === '--example-index-path') {
|
|
331
|
+
opts.exampleIndexPath = path.resolve(argv[++i] ?? '');
|
|
332
|
+
} else {
|
|
333
|
+
throw new ExitError(
|
|
334
|
+
1,
|
|
335
|
+
`Unknown argument: ${arg}\n` +
|
|
336
|
+
'Usage: lint-example-parser-parity.cjs [--context-path <path>] [--example-index-path <path>]\n',
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return opts;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// ─── Main ─────────────────────────────────────────────────────────────────────
|
|
344
|
+
|
|
345
|
+
function main() {
|
|
346
|
+
const opts = parseArgs(process.argv.slice(2));
|
|
347
|
+
|
|
348
|
+
const prodPredicates = loadProdPredicates();
|
|
349
|
+
const examplePredicates = loadExamplePredicates();
|
|
350
|
+
const markdown = readContextMarkdown(opts.contextPath);
|
|
351
|
+
|
|
352
|
+
const diagnostics = [
|
|
353
|
+
...checkProdExampleParity(prodPredicates, examplePredicates, markdown),
|
|
354
|
+
...checkExampleIndexParity(examplePredicates, markdown, opts.exampleIndexPath),
|
|
355
|
+
];
|
|
356
|
+
|
|
357
|
+
if (diagnostics.length > 0) {
|
|
358
|
+
process.stderr.write(
|
|
359
|
+
`\nERROR lint-example-parser-parity: ${diagnostics.length} divergence(s) found\n\n`,
|
|
360
|
+
);
|
|
361
|
+
for (const d of diagnostics) process.stderr.write(` - ${d}\n`);
|
|
362
|
+
process.stderr.write(
|
|
363
|
+
'\nexamples/dynamic-context-management/context-predicates.cjs and ' +
|
|
364
|
+
'src/context-predicates.cts (gsd-core/bin/lib/context-predicates.cjs) must agree; ' +
|
|
365
|
+
'the committed examples/dynamic-context-management/CONTEXT-INDEX.json must match a ' +
|
|
366
|
+
'fresh parse of CONTEXT.md on every line-number-independent fact (run:\n' +
|
|
367
|
+
' node examples/dynamic-context-management/gen-context-index.cjs --write\n' +
|
|
368
|
+
').\n',
|
|
369
|
+
);
|
|
370
|
+
throw new ExitError(1);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
process.stdout.write(
|
|
374
|
+
'ok lint-example-parser-parity: production and example parsers agree on the real CONTEXT.md ' +
|
|
375
|
+
`(count/classes/duplicates/(id,value) pairs), on ${ID_SHAPE_CASES.length + 1} representative ` +
|
|
376
|
+
'accept/reject id-shape cases, and the committed example index matches a fresh parse ' +
|
|
377
|
+
'(line-number-independent)\n',
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
module.exports = {
|
|
382
|
+
loadProdPredicates,
|
|
383
|
+
loadExamplePredicates,
|
|
384
|
+
readContextMarkdown,
|
|
385
|
+
diffPredicatesById,
|
|
386
|
+
checkProdExampleParity,
|
|
387
|
+
checkExampleIndexParity,
|
|
388
|
+
parseArgs,
|
|
389
|
+
ID_SHAPE_CASES,
|
|
390
|
+
CR_VALUE_MARKDOWN,
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
if (require.main === module) {
|
|
394
|
+
runMain(main);
|
|
395
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_doc": "Baseline of modules currently exceeding the 2-test-file limit. Each entry locks in TODAY's exact test filenames as the allowlisted set (identity ratchet). Adding a NEW test file to a capped module fails (novel). Removing one requires pruning this list (stale, ratchet-down). When a cluster drops to
|
|
2
|
+
"_doc": "Baseline of modules currently exceeding the 2-test-file limit. Each entry locks in TODAY's exact test filenames as the allowlisted set (identity ratchet). Adding a NEW test file to a capped module fails (novel). Removing one requires pruning this list (stale, ratchet-down). When a cluster drops to \u2264 2, remove its entry entirely. New entries require justification in PR description.",
|
|
3
3
|
"modules": {
|
|
4
4
|
"config": {
|
|
5
5
|
"files": [
|
|
6
|
+
"config-defaults-runtime-exclusion.test.cjs",
|
|
6
7
|
"config-field-docs.test.cjs",
|
|
7
8
|
"config-get-default.test.cjs",
|
|
8
9
|
"config-schema.property.test.cjs",
|
|
@@ -21,6 +22,15 @@
|
|
|
21
22
|
],
|
|
22
23
|
"issue": "622"
|
|
23
24
|
},
|
|
25
|
+
"init": {
|
|
26
|
+
"files": [
|
|
27
|
+
"init-debug-workflow-contract.test.cjs",
|
|
28
|
+
"init-debug.test.cjs",
|
|
29
|
+
"init-manager.test.cjs",
|
|
30
|
+
"init.test.cjs"
|
|
31
|
+
],
|
|
32
|
+
"issue": "3149"
|
|
33
|
+
},
|
|
24
34
|
"milestone": {
|
|
25
35
|
"files": [
|
|
26
36
|
"milestone-archive.test.cjs",
|
|
@@ -116,6 +126,22 @@
|
|
|
116
126
|
"host-integration-descriptors.test.cjs"
|
|
117
127
|
],
|
|
118
128
|
"issue": "1684"
|
|
129
|
+
},
|
|
130
|
+
"prompt-budget": {
|
|
131
|
+
"files": [
|
|
132
|
+
"prompt-budget-cli.test.cjs",
|
|
133
|
+
"prompt-budget-parity.test.cjs",
|
|
134
|
+
"prompt-budget.test.cjs"
|
|
135
|
+
],
|
|
136
|
+
"issue": "2929"
|
|
137
|
+
},
|
|
138
|
+
"audit": {
|
|
139
|
+
"files": [
|
|
140
|
+
"audit-command-cutover.test.cjs",
|
|
141
|
+
"audit-fix-command.test.cjs",
|
|
142
|
+
"fix-2766-audit-uat-archived-and-table-shapes.test.cjs"
|
|
143
|
+
],
|
|
144
|
+
"issue": "2766"
|
|
119
145
|
}
|
|
120
146
|
}
|
|
121
147
|
}
|
|
@@ -130,6 +130,19 @@ const COVERED = {
|
|
|
130
130
|
// minScore raised to TARGET (80) — module now meets ADR-456 goal.
|
|
131
131
|
minScore: 80,
|
|
132
132
|
},
|
|
133
|
+
// context-composer: extracted from prompt-budget by #2929. Needs its own entry because
|
|
134
|
+
// mutation coverage does not migrate with relocated code — scoring only prompt-budget.cjs
|
|
135
|
+
// would leave the extracted ladder unmeasured.
|
|
136
|
+
'context-composer': {
|
|
137
|
+
cjs: 'gsd-core/bin/lib/context-composer.cjs',
|
|
138
|
+
tests: [
|
|
139
|
+
'tests/prompt-budget-parity.test.cjs',
|
|
140
|
+
'tests/prompt-budget.unit.test.cjs',
|
|
141
|
+
'tests/context-composer.test.cjs',
|
|
142
|
+
'tests/context-composer.property.test.cjs',
|
|
143
|
+
],
|
|
144
|
+
minScore: 66,
|
|
145
|
+
},
|
|
133
146
|
'prompt-budget': {
|
|
134
147
|
cjs: 'gsd-core/bin/lib/prompt-budget.cjs',
|
|
135
148
|
tests: [
|
|
@@ -14,6 +14,19 @@ set -euo pipefail
|
|
|
14
14
|
|
|
15
15
|
# ─── Patterns ────────────────────────────────────────────────────────────────
|
|
16
16
|
# Each pattern is a POSIX extended regex. Keep alphabetized by category.
|
|
17
|
+
#
|
|
18
|
+
# Left-boundary prefix `(^|[^[:alnum:]])`: several trigger words are also
|
|
19
|
+
# suffixes of ordinary English words or camelCase identifiers (fact/impact/
|
|
20
|
+
# contract/artifact/interact all end in "act"; retrieval/medieval end in
|
|
21
|
+
# "eval"; blueprint/reprint/fingerprint end in "print"; describeFunction/
|
|
22
|
+
# wrapFunction end in "Function"; Jordan/Sudan end in "dan"), so an
|
|
23
|
+
# unanchored keyword matches as a false-positive substring. `\b` is a GNU
|
|
24
|
+
# grep extension and this script must also run under BSD/macOS grep, so the
|
|
25
|
+
# boundary is spelled out as `(^|[^[:alnum:]])` instead. This never narrows
|
|
26
|
+
# real detections: a genuine attack phrase is always preceded by start-of-
|
|
27
|
+
# line, whitespace, or punctuation, never by another alnum character glued
|
|
28
|
+
# directly onto the keyword. Only patterns whose leading keyword is provably
|
|
29
|
+
# not a real-word suffix are left unanchored (#3175 audit).
|
|
17
30
|
|
|
18
31
|
PATTERNS=(
|
|
19
32
|
# Instruction override
|
|
@@ -27,7 +40,7 @@ PATTERNS=(
|
|
|
27
40
|
'you[[:space:]]+are[[:space:]]+now[[:space:]]+(a|an|my)[[:space:]]'
|
|
28
41
|
'from[[:space:]]+now[[:space:]]+on[[:space:]]+(you|pretend|act|behave)'
|
|
29
42
|
'pretend[[:space:]]+(you[[:space:]]+are|to[[:space:]]+be)[[:space:]]'
|
|
30
|
-
'act[[:space:]]+as[[:space:]]+(a|an|if|my)[[:space:]]'
|
|
43
|
+
'(^|[^[:alnum:]])act[[:space:]]+as[[:space:]]+(a|an|if|my)[[:space:]]'
|
|
31
44
|
'roleplay[[:space:]]+as[[:space:]]'
|
|
32
45
|
'assume[[:space:]]+the[[:space:]]+role[[:space:]]+of[[:space:]]'
|
|
33
46
|
|
|
@@ -35,7 +48,7 @@ PATTERNS=(
|
|
|
35
48
|
'output[[:space:]]+(your|the)[[:space:]]+(system[[:space:]]+)?(prompt|instructions)'
|
|
36
49
|
'reveal[[:space:]]+(your|the)[[:space:]]+(system[[:space:]]+)?(prompt|instructions)'
|
|
37
50
|
'show[[:space:]]+me[[:space:]]+(your|the)[[:space:]]+(system[[:space:]]+)?(prompt|instructions)'
|
|
38
|
-
'print[[:space:]]+(your|the)[[:space:]]+(system[[:space:]]+)?(prompt|instructions)'
|
|
51
|
+
'(^|[^[:alnum:]])print[[:space:]]+(your|the)[[:space:]]+(system[[:space:]]+)?(prompt|instructions)'
|
|
39
52
|
'what[[:space:]]+(is|are)[[:space:]]+(your|the)[[:space:]]+(system[[:space:]]+)?(prompt|instructions)'
|
|
40
53
|
'repeat[[:space:]]+(your|the|all)[[:space:]]+(system[[:space:]]+)?(prompt|instructions|rules)'
|
|
41
54
|
|
|
@@ -51,13 +64,21 @@ PATTERNS=(
|
|
|
51
64
|
'<</SYS>>'
|
|
52
65
|
|
|
53
66
|
# Tool call injection / code execution in markdown
|
|
54
|
-
|
|
55
|
-
'
|
|
56
|
-
'
|
|
67
|
+
#
|
|
68
|
+
# The quote-or-apostrophe class below is spelled ["'"'"'"] (a literal `'`
|
|
69
|
+
# via bash's close-quote/escape/reopen idiom), not `["\x27]` — `\x27` is a
|
|
70
|
+
# GNU-grep-only hex escape; BSD/macOS grep treats it as four literal
|
|
71
|
+
# characters (", \, x, 2, 7) and never matches an actual apostrophe, so
|
|
72
|
+
# `eval('...')` (single-quoted) silently went undetected on macOS while
|
|
73
|
+
# passing on GNU-grep CI runners. Found auditing #3175; fixed here since it
|
|
74
|
+
# is the same unanchored/portability defect class as the boundary fix.
|
|
75
|
+
'(^|[^[:alnum:]])eval[[:space:]]*\([[:space:]]*["'"'"']'
|
|
76
|
+
'exec[[:space:]]*\([[:space:]]*["'"'"']'
|
|
77
|
+
'(^|[^[:alnum:]])Function[[:space:]]*\([[:space:]]*["'"'"'].*return'
|
|
57
78
|
|
|
58
79
|
# Jailbreak / DAN patterns
|
|
59
80
|
'do[[:space:]]+anything[[:space:]]+now'
|
|
60
|
-
'DAN[[:space:]]+mode'
|
|
81
|
+
'(^|[^[:alnum:]])DAN[[:space:]]+mode'
|
|
61
82
|
'developer[[:space:]]+mode[[:space:]]+(enabled|output|activated)'
|
|
62
83
|
'jailbreak'
|
|
63
84
|
'bypass[[:space:]]+(safety|content|security)[[:space:]]+(filter|check|rule|guard)'
|