harness-everything 1.3.0 → 1.3.2
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 +1 -1
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +14 -0
- package/behavioral-evals/ledger-pairs/README.md +53 -0
- package/behavioral-evals/ledger-pairs/arm.js +359 -0
- package/behavioral-evals/ledger-pairs/fixture.js +138 -0
- package/behavioral-evals/ledger-pairs/preflight.js +96 -0
- package/behavioral-evals/ledger-pairs/score.js +155 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/README.md +108 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-baseline/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-baseline/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-baseline/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-baseline/arm-result.json +28 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-baseline/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-treatment/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-baseline/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-treatment/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-baseline/arm-result.json +49 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-treatment/arm-result.json +49 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-baseline/arm-result.json +49 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-treatment/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/receipt.jsonl +17 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/arm-result.json +41 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/receipt.jsonl +58 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/arm-result.json +50 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/receipt.jsonl +101 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/receipt.jsonl +29 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/receipt.jsonl +23 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/arm-result.json +34 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/receipt.jsonl +24 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/arm-result.json +47 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/receipt.jsonl +69 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/receipt.jsonl +65 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/run-order.sh +18 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/score.json +1032 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/README.md +50 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/collect-rerun.txt +3 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/export-report.json +22 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/host-version.txt +1 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/import-report-1.json +18 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/import-report-2.json +18 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/labels-observed-excerpt.jsonl +2 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/observations-index-excerpt.json +26 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/plugin-load-lines.txt +1 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/README.md +46 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/observations-index-excerpt.json +16 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/plugin-load-lines.txt +2 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/run-marks.txt +6 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/steering-probe.js +16 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/steering-trace.jsonl +167 -0
- package/ci/archive/325-prep/README.md +9 -2
- package/ci/archive/325-prep/doc-reconciliation-red.js +34 -8
- package/ci/fixtures/553-t2a/body-edit/base/.agents/harness-everything/project-docs.json +11 -0
- package/ci/fixtures/553-t2a/body-edit/base/docs/a.md +6 -0
- package/ci/fixtures/553-t2a/body-edit/base/docs/b.md +1 -0
- package/ci/fixtures/553-t2a/body-edit/candidate/docs/a.md +6 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/adr/EVID-001-verify-all-evidence.md +11 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/governed-index.md +19 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/adr/EVID-001-verify-all-evidence.md +11 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/governed-index.md +19 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/config.json +17 -0
- package/ci/fixtures/doc-obligations/derive/regression-pins.json +153 -0
- package/ci/fixtures/state-persist-post-tool-use/harness.js +206 -0
- package/ci/fixtures/state-persist-post-tool-use/off-handoff-golden.json +16 -0
- package/ci/fixtures/state-persist-post-tool-use/payload-post-tool-use-success.json +13 -0
- package/ci/fixtures/stop/fail-session-writes.js +109 -0
- package/ci/fixtures/workflow-contract/cases.json +3355 -0
- package/ci/fixtures/workflow-contract/wiring-cases.json +560 -0
- package/ci/lib/doc-reconciliation-prep-fixtures.js +4 -9
- package/ci/mechanism-2an-workflow-replay.test.js +324 -0
- package/ci/mechanism-2ax-doc-lifecycle.test.js +132 -0
- package/ci/mechanism-325-3a-doc-evidence.test.js +73 -0
- package/ci/mechanism-325-3a-doc-obligations.test.js +61 -0
- package/ci/mechanism-325-3b-preparation.test.js +208 -49
- package/ci/mechanism-325-3b-s1-review.test.js +20 -828
- package/ci/mechanism-325-3b-s3-providers.test.js +59 -0
- package/ci/mechanism-325-f3-derived-views.test.js +140 -0
- package/ci/mechanism-332-fable-directive.test.js +180 -0
- package/ci/mechanism-341-opencode-lane.test.js +164 -284
- package/ci/mechanism-35-verification-contract.test.js +246 -0
- package/ci/mechanism-365-step-edit-accounting.test.js +5 -6
- package/ci/mechanism-383-doc-glob-line-terminators.test.js +0 -30
- package/ci/mechanism-397-opencode-observations.test.js +151 -18
- package/ci/mechanism-552-ledger-pairs.test.js +159 -0
- package/ci/mechanism-553-e1-unhook-credit.test.js +328 -0
- package/ci/mechanism-553-p2a-claude-hooks.test.js +98 -0
- package/ci/mechanism-553-p3-plan-start.test.js +212 -0
- package/ci/mechanism-553-state-persist-post-tool-use.test.js +307 -0
- package/ci/mechanism-553-stop.test.js +427 -0
- package/ci/mechanism-553-t2a-derive.test.js +110 -0
- package/ci/mechanism-553-t2c-derive.test.js +94 -0
- package/ci/mechanism-e1-derived-regenerate.test.js +45 -206
- package/ci/mechanism-outline-sanitizer.test.js +0 -8
- package/ci/mechanism-pr-a-conflict-check.test.js +38 -305
- package/ci/mechanism-prb-outline-review.test.js +101 -3283
- package/ci/router-workflow-plan.test.js +61 -21
- package/docs/adr/DOCS-006-reconciliation-pilot.md +4 -2
- package/docs/adr/DOCS-008-obligation-abstraction-bounded-consumer.md +3 -3
- package/docs/doc-workflow-reconciliation.md +17 -2
- package/docs/document-lifecycle.md +6 -2
- package/docs/platform-capabilities.md +63 -16
- package/docs/platform-compatibility.json +5 -5
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/scripts/routing-keywords.json +0 -2
- package/harness-everything/scripts/tier-router.js +105 -11
- package/hooks/hooks.json +0 -46
- package/hooks/scripts/lib/workflow-obligations.js +0 -55
- package/hooks/scripts/state-persist.js +7 -95
- package/hooks/scripts/workflow-disposition.js +0 -2
- package/hooks/scripts/workflow-stop-gate.js +17 -30
- package/opencode-plugin/index.mjs +6 -70
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js +0 -55
- package/plugins/harness-everything/hooks/scripts/state-persist.js +7 -95
- package/plugins/harness-everything/hooks/scripts/workflow-disposition.js +0 -2
- package/plugins/harness-everything/hooks/scripts/workflow-stop-gate.js +17 -30
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/rules/AGENTS.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +0 -2
- package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +105 -11
- package/sbom.cdx.json +7 -7
- package/ci/fixtures/doc-obligations/reconciliation-s1/cases.json +0 -6854
- package/ci/fixtures/doc-obligations/reconciliation-s1/fail-session-writes.js +0 -116
- package/ci/fixtures/doc-obligations/reconciliation-s2a/harness.js +0 -507
- package/ci/fixtures/doc-obligations/reconciliation-s2a/run13-workflow-requirements.json +0 -42
- package/ci/fixtures/doc-obligations/reconciliation-s2a/vectors.json +0 -617
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/harness.js +0 -415
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-post-tool-use-success-minimal.json +0 -9
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-start.json +0 -7
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-freetext-reject.json +0 -11
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-reject.json +0 -11
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop.json +0 -11
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-task-result.json +0 -19
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-capture-only.json +0 -99
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-legacy.json +0 -67
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-concurrent-writers.json +0 -62
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-lookalikes-runtime-mutations.json +0 -67
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-malformed.json +0 -85
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-normal-session.json +0 -74
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-runtime-drift-later-npm-test.json +0 -58
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-valid-direct-quoted-review.json +0 -85
- package/ci/fixtures/doc-obligations/reconciliation-s2b/f4/cases.json +0 -2267
- package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/cases.json +0 -1110
- package/ci/lib/doc-reconciliation-file-spy.js +0 -23
- package/ci/lib/doc-reconciliation-qualification-preload.js +0 -37
- package/ci/lib/doc-reconciliation-replay.js +0 -104
- package/ci/lib/doc-reconciliation-staged-tree.js +0 -102
- package/ci/mechanism-325-3b-h1-qualification.test.js +0 -206
- package/ci/mechanism-325-3b-s1.test.js +0 -188
- package/ci/mechanism-325-3b-s2a-core.test.js +0 -840
- package/ci/mechanism-325-3b-s2a-producer.test.js +0 -564
- package/ci/mechanism-325-3b-s2b-capture.test.js +0 -566
- package/ci/mechanism-325-3b-s2b-wiring.test.js +0 -679
- package/ci/mechanism-325-f4-invariants.test.js +0 -606
- package/ci/mechanism-325-f4-projections.test.js +0 -392
- package/ci/mechanism-325-f4-qualification.test.js +0 -228
- package/ci/mechanism-325-f4-trust-boundary.test.js +0 -880
- package/ci/mechanism-e1-dependency-artifact-scope.test.js +0 -657
- package/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
- package/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
- package/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
- package/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
- package/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
- package/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
- package/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
- package/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
- package/hooks/scripts/w6-state-operations.js +0 -239
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
- package/plugins/harness-everything/hooks/scripts/w6-state-operations.js +0 -239
- package/scripts/system-one-eval-laya.js +0 -112
- /package/ci/fixtures/{doc-obligations/reconciliation-s2b/capture → state-persist-post-tool-use}/payload-post-tool-use-failure.json +0 -0
- /package/ci/fixtures/{doc-obligations/reconciliation-s2b/wiring → workflow-contract}/legacy-off-golden.json +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Document lifecycle index
|
|
2
|
+
|
|
3
|
+
## Active documents
|
|
4
|
+
|
|
5
|
+
- `EVID-001` — `docs/adr/EVID-001-verify-all-evidence.md` (role: adr; status: proposed)
|
|
6
|
+
|
|
7
|
+
## PRD revision chains
|
|
8
|
+
|
|
9
|
+
_None._
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Legacy documents
|
|
13
|
+
|
|
14
|
+
_None._
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Unresolved
|
|
18
|
+
|
|
19
|
+
_None._
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Document lifecycle index
|
|
2
|
+
|
|
3
|
+
## Active documents
|
|
4
|
+
|
|
5
|
+
- `EVID-001` — `docs/adr/EVID-001-verify-all-evidence.md` (role: adr; status: accepted)
|
|
6
|
+
|
|
7
|
+
## PRD revision chains
|
|
8
|
+
|
|
9
|
+
_None._
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Legacy documents
|
|
13
|
+
|
|
14
|
+
_None._
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Unresolved
|
|
18
|
+
|
|
19
|
+
_None._
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"governed": [
|
|
3
|
+
{
|
|
4
|
+
"path": "docs/adr/*.md",
|
|
5
|
+
"role": "adr"
|
|
6
|
+
}
|
|
7
|
+
],
|
|
8
|
+
"domains": [
|
|
9
|
+
"EVID"
|
|
10
|
+
],
|
|
11
|
+
"derived": [
|
|
12
|
+
{
|
|
13
|
+
"path": "docs/governed-index.md",
|
|
14
|
+
"generator": "node harness-everything/scripts/doc-lifecycle.js index --workspace . --config .agents/harness-everything/project-docs.json --all"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"description": "Fixed regression pins for unchanged deriveDocFacts, deriveDocObligations and checkDocObligations outputs across the four canonical vectors (moved from reconciliation-s2a/vectors.json in #553 T2-D without recapturing digests).",
|
|
4
|
+
"deriveConfig": "ci/fixtures/doc-obligations/derive/config.json",
|
|
5
|
+
"vectors": {
|
|
6
|
+
"normative": {
|
|
7
|
+
"deriveCase": "missing-approval"
|
|
8
|
+
},
|
|
9
|
+
"nonnormative": {
|
|
10
|
+
"deriveCase": "docs-only"
|
|
11
|
+
},
|
|
12
|
+
"code-only": {
|
|
13
|
+
"deriveCase": "code-only"
|
|
14
|
+
},
|
|
15
|
+
"nondocument": {
|
|
16
|
+
"files": {
|
|
17
|
+
"base": {
|
|
18
|
+
"assets/notes.txt": "Release notes draft.\n"
|
|
19
|
+
},
|
|
20
|
+
"candidate": {
|
|
21
|
+
"assets/notes.txt": "Release notes draft, revised.\n"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"pins": {
|
|
27
|
+
"normative": {
|
|
28
|
+
"deriveFactsSha256": "c78d208ccba00c5e47bd5d72abc595b05f7f340a005da0a14b598cd5c4743437",
|
|
29
|
+
"deriveObligationsSha256": "5ff5fcfe1edaf939a2b8b526b2bff131de1253319f3cbe97b3c4c60f75480deb",
|
|
30
|
+
"checkerResultsSha256": "3a55b457ee4f8eb918fcfeda1f12236e57817d0fd4db185799ffb73b9c162b9a",
|
|
31
|
+
"mustApplicability": [
|
|
32
|
+
[
|
|
33
|
+
"doc-change:doc-lint",
|
|
34
|
+
"applicable"
|
|
35
|
+
],
|
|
36
|
+
[
|
|
37
|
+
"doc-change:link-check",
|
|
38
|
+
"applicable"
|
|
39
|
+
],
|
|
40
|
+
[
|
|
41
|
+
"doc-change:derived-regenerate",
|
|
42
|
+
"N/A"
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
"doc-change:quality-review",
|
|
46
|
+
"applicable"
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
"doc-change:conflict-check",
|
|
50
|
+
"applicable"
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
"doc-change:requirement-sync",
|
|
54
|
+
"N/A"
|
|
55
|
+
]
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
"nonnormative": {
|
|
59
|
+
"deriveFactsSha256": "72659ade94266aa542198aed0ada2dfa243297520f70e40b86b5896592d8a457",
|
|
60
|
+
"deriveObligationsSha256": "ece5929fd7bec6d836312dbc2b90c4c8eabc7f82fc1b49605f7f342b9eb7071d",
|
|
61
|
+
"checkerResultsSha256": "74a20d2e250c40c7dfad7025bfcad080345667e7d558a33f615452c40597854d",
|
|
62
|
+
"mustApplicability": [
|
|
63
|
+
[
|
|
64
|
+
"doc-change:doc-lint",
|
|
65
|
+
"applicable"
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
"doc-change:link-check",
|
|
69
|
+
"applicable"
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
"doc-change:derived-regenerate",
|
|
73
|
+
"N/A"
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"doc-change:quality-review",
|
|
77
|
+
"N/A"
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
"doc-change:conflict-check",
|
|
81
|
+
"N/A"
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
"doc-change:requirement-sync",
|
|
85
|
+
"N/A"
|
|
86
|
+
]
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"code-only": {
|
|
90
|
+
"deriveFactsSha256": "1134fae14ea8f888f12f5dff1bd32b8a2788ba09e91299e7ce3d2a9dc81d0d1f",
|
|
91
|
+
"deriveObligationsSha256": "b8ece9008764bad6e015d99252dd73570164684b768449d89d4ff0de98def44e",
|
|
92
|
+
"checkerResultsSha256": "3080bfcaafb7f330f4d26f4087a60a9a76c7a5154b7581209fc26e365333edcb",
|
|
93
|
+
"mustApplicability": [
|
|
94
|
+
[
|
|
95
|
+
"doc-change:doc-lint",
|
|
96
|
+
"N/A"
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
"doc-change:link-check",
|
|
100
|
+
"N/A"
|
|
101
|
+
],
|
|
102
|
+
[
|
|
103
|
+
"doc-change:derived-regenerate",
|
|
104
|
+
"N/A"
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
"doc-change:quality-review",
|
|
108
|
+
"N/A"
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
"doc-change:conflict-check",
|
|
112
|
+
"N/A"
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
"doc-change:requirement-sync",
|
|
116
|
+
"unknown"
|
|
117
|
+
]
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
"nondocument": {
|
|
121
|
+
"deriveFactsSha256": "5ba5a35c74165a94deff0e935799f93b7d5efa1eb554e4fad9717560e0828d43",
|
|
122
|
+
"deriveObligationsSha256": "0cfb1cbd5ebb220a3c174d716dcba67c46b0d58e87bfebf0a930e8e0be9f843b",
|
|
123
|
+
"checkerResultsSha256": "25026cdafe353e58bdc3a74e8b1db6feb1a2f180f9cce04f81527e96d57c251a",
|
|
124
|
+
"mustApplicability": [
|
|
125
|
+
[
|
|
126
|
+
"doc-change:doc-lint",
|
|
127
|
+
"N/A"
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
"doc-change:link-check",
|
|
131
|
+
"N/A"
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
"doc-change:derived-regenerate",
|
|
135
|
+
"N/A"
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
"doc-change:quality-review",
|
|
139
|
+
"N/A"
|
|
140
|
+
],
|
|
141
|
+
[
|
|
142
|
+
"doc-change:conflict-check",
|
|
143
|
+
"N/A"
|
|
144
|
+
],
|
|
145
|
+
[
|
|
146
|
+
"doc-change:requirement-sync",
|
|
147
|
+
"N/A"
|
|
148
|
+
]
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"pinNote": "sha256 of stable JSON (sorted keys) of the current unchanged outputs; recorded at R2a RED."
|
|
153
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Test-only harness for the general state-persist PostToolUse compatibility
|
|
4
|
+
// controls. Copies the capture fixture's two-leg loader/driver contract so the
|
|
5
|
+
// moved controls keep the same input, same assertion and both real hook legs
|
|
6
|
+
// (canonical hooks/scripts + packaged plugins/harness-everything copy).
|
|
7
|
+
// No runtime module is required at load time; R2 may retire the E1 modules
|
|
8
|
+
// without affecting these controls.
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const os = require('os');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const { spawnSync } = require('child_process');
|
|
14
|
+
|
|
15
|
+
const HERE = __dirname;
|
|
16
|
+
const ROOT = path.resolve(HERE, '..', '..', '..');
|
|
17
|
+
|
|
18
|
+
const LEGS = [
|
|
19
|
+
{
|
|
20
|
+
name: 'source',
|
|
21
|
+
hooksScripts: path.join(ROOT, 'hooks', 'scripts'),
|
|
22
|
+
hooksManifest: path.join(ROOT, 'hooks', 'hooks.json'),
|
|
23
|
+
lib: path.join(ROOT, 'hooks', 'scripts', 'lib'),
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'packaged',
|
|
27
|
+
hooksScripts: path.join(ROOT, 'plugins', 'harness-everything', 'hooks', 'scripts'),
|
|
28
|
+
hooksManifest: path.join(ROOT, 'plugins', 'harness-everything', 'hooks', 'hooks.json'),
|
|
29
|
+
lib: path.join(ROOT, 'plugins', 'harness-everything', 'hooks', 'scripts', 'lib'),
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
class InfraError extends Error {}
|
|
34
|
+
|
|
35
|
+
const CAPTURE_EVENT_NAMES = ['PostToolUse', 'PostToolUseFailure', 'SubagentStart', 'SubagentStop'];
|
|
36
|
+
const CAPTURE_BASE_REQUIRED = ['event', 'command', 'cwd', 'tool_use_id', 'session_id', 'responseDigest', 'responseRef'];
|
|
37
|
+
|
|
38
|
+
function payload(name) {
|
|
39
|
+
return JSON.parse(fs.readFileSync(path.join(HERE, name), 'utf8'));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function golden() {
|
|
43
|
+
return JSON.parse(fs.readFileSync(path.join(HERE, 'off-handoff-golden.json'), 'utf8'));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const moduleCache = new Map();
|
|
47
|
+
function loadModule(leg, file) {
|
|
48
|
+
const key = `${leg.name}:${file}`;
|
|
49
|
+
if (moduleCache.has(key)) return moduleCache.get(key);
|
|
50
|
+
const abs = path.join(leg.lib, file);
|
|
51
|
+
const rel = path.relative(ROOT, abs);
|
|
52
|
+
let result;
|
|
53
|
+
if (!fs.existsSync(abs)) {
|
|
54
|
+
result = { error: `module-missing: ${rel} does not exist` };
|
|
55
|
+
} else {
|
|
56
|
+
try {
|
|
57
|
+
result = { mod: require(abs) };
|
|
58
|
+
} catch (error) {
|
|
59
|
+
result = { error: `load-error: ${rel}: ${String(error && error.message).split('\n')[0]}` };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
moduleCache.set(key, result);
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function requirementsMet(leg, requirements) {
|
|
67
|
+
const mods = {};
|
|
68
|
+
for (const req of requirements || []) {
|
|
69
|
+
const loaded = loadModule(leg, req.file);
|
|
70
|
+
if (loaded.error) return { error: loaded.error };
|
|
71
|
+
for (const name of req.exports || []) {
|
|
72
|
+
if (typeof loaded.mod[name] !== 'function') {
|
|
73
|
+
return { error: `export-missing: ${req.file} does not export ${name}` };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
mods[req.file] = loaded.mod;
|
|
77
|
+
}
|
|
78
|
+
return { mods };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function createRunner(label) {
|
|
82
|
+
const rows = [];
|
|
83
|
+
const counts = { PASS: 0, FAIL: 0, INFRA: 0 };
|
|
84
|
+
function emit(status, id, leg, detail) {
|
|
85
|
+
counts[status] += 1;
|
|
86
|
+
rows.push({ status, id, leg, detail: detail || '' });
|
|
87
|
+
console.log(` ${status} ${id}${leg ? ` [${leg}]` : ''}${detail ? ` — ${detail}` : ''}`);
|
|
88
|
+
}
|
|
89
|
+
function run(id, requirements, fn) {
|
|
90
|
+
for (const leg of LEGS) {
|
|
91
|
+
const met = requirementsMet(leg, requirements);
|
|
92
|
+
if (met.error) { emit('FAIL', id, leg.name, met.error); continue; }
|
|
93
|
+
try {
|
|
94
|
+
fn(met.mods, leg);
|
|
95
|
+
emit('PASS', id, leg.name);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
if (error instanceof InfraError) emit('INFRA', id, leg.name, String(error && error.message).split('\n')[0]);
|
|
98
|
+
else emit('FAIL', id, leg.name, String(error && error.message).split('\n')[0]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function summary() {
|
|
103
|
+
console.log(`\n${label} summary: ${counts.PASS} PASS, ${counts.FAIL} FAIL, ${counts.INFRA} INFRA across ${rows.length} assertion-legs`);
|
|
104
|
+
return counts;
|
|
105
|
+
}
|
|
106
|
+
return { run, summary, counts, rows, emit };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function sessionDirectoryNameSafe(sessionId) {
|
|
110
|
+
return String(sessionId || 'default').replace(/[^A-Za-z0-9._-]+/g, '_').replace(/^\.+/, '');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function snapshotSessionTree(stateHome, sessionId) {
|
|
114
|
+
const dirName = sessionDirectoryNameSafe(sessionId);
|
|
115
|
+
const hits = [];
|
|
116
|
+
(function walk(dir) {
|
|
117
|
+
if (!fs.existsSync(dir)) return;
|
|
118
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
119
|
+
const abs = path.join(dir, entry.name);
|
|
120
|
+
if (entry.isDirectory()) walk(abs);
|
|
121
|
+
else if (abs.split(path.sep).includes(dirName)) hits.push(abs);
|
|
122
|
+
}
|
|
123
|
+
})(stateHome);
|
|
124
|
+
const files = {};
|
|
125
|
+
for (const abs of hits) files[path.relative(stateHome, abs).replace(/\\/g, '/')] = fs.readFileSync(abs, 'utf8');
|
|
126
|
+
return files;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function driveStatePersist(leg, baseName, overrides = {}, options = {}) {
|
|
130
|
+
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'state-persist-post-'));
|
|
131
|
+
const wsRoot = path.join(home, 'ws');
|
|
132
|
+
fs.mkdirSync(wsRoot, { recursive: true });
|
|
133
|
+
const stateHome = path.join(home, 'state-home');
|
|
134
|
+
fs.mkdirSync(stateHome, { recursive: true });
|
|
135
|
+
const driven = JSON.parse(JSON.stringify(payload(baseName)));
|
|
136
|
+
for (const [k, v] of Object.entries(overrides)) {
|
|
137
|
+
if (v === undefined) delete driven[k];
|
|
138
|
+
else driven[k] = v;
|
|
139
|
+
}
|
|
140
|
+
driven.cwd = wsRoot;
|
|
141
|
+
const env = {
|
|
142
|
+
...process.env,
|
|
143
|
+
CLAUDE: '1',
|
|
144
|
+
HARNESS_STATE_HOME: stateHome,
|
|
145
|
+
HARNESS_WORKSPACE_ROOT: wsRoot,
|
|
146
|
+
...(options.env || {}),
|
|
147
|
+
};
|
|
148
|
+
let result;
|
|
149
|
+
try {
|
|
150
|
+
result = spawnSync('node', [path.join(leg.hooksScripts, 'state-persist.js')], {
|
|
151
|
+
input: JSON.stringify(driven),
|
|
152
|
+
encoding: 'utf8',
|
|
153
|
+
env,
|
|
154
|
+
timeout: 30000,
|
|
155
|
+
});
|
|
156
|
+
} catch (error) {
|
|
157
|
+
throw new InfraError(`state-persist subprocess could not be started: ${error.message}`);
|
|
158
|
+
}
|
|
159
|
+
if (result.error) throw new InfraError(`state-persist subprocess error: ${String(result.error.message || result.error)}`);
|
|
160
|
+
const out = {
|
|
161
|
+
code: result.status,
|
|
162
|
+
stdout: result.stdout || '',
|
|
163
|
+
stderr: result.stderr || '',
|
|
164
|
+
files: snapshotSessionTree(stateHome, driven.session_id),
|
|
165
|
+
filesRoot: stateHome,
|
|
166
|
+
wsRoot,
|
|
167
|
+
payload: driven,
|
|
168
|
+
};
|
|
169
|
+
try { fs.rmSync(home, { recursive: true, force: true }); } catch { /* best effort */ }
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function deepScan(value, visit) {
|
|
174
|
+
if (value && typeof value === 'object') {
|
|
175
|
+
visit(value);
|
|
176
|
+
if (Array.isArray(value)) for (const item of value) deepScan(item, visit);
|
|
177
|
+
else for (const key of Object.keys(value)) deepScan(value[key], visit);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function findCaptureRecords(files) {
|
|
182
|
+
const found = [];
|
|
183
|
+
for (const content of Object.values(files)) {
|
|
184
|
+
let parsed;
|
|
185
|
+
try { parsed = JSON.parse(content); } catch { continue; }
|
|
186
|
+
deepScan(parsed, node => {
|
|
187
|
+
if (node && CAPTURE_EVENT_NAMES.includes(node.event)
|
|
188
|
+
&& CAPTURE_BASE_REQUIRED.every(k => Object.prototype.hasOwnProperty.call(node, k))) {
|
|
189
|
+
found.push(node);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return found;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
module.exports = {
|
|
197
|
+
ROOT,
|
|
198
|
+
LEGS,
|
|
199
|
+
InfraError,
|
|
200
|
+
payload,
|
|
201
|
+
golden,
|
|
202
|
+
createRunner,
|
|
203
|
+
requirementsMet,
|
|
204
|
+
driveStatePersist,
|
|
205
|
+
findCaptureRecords,
|
|
206
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"session_id": "r2c1-sess-a",
|
|
3
|
+
"prompt_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
4
|
+
"transcript_path": "/tmp/r2c1/transcript-a.jsonl",
|
|
5
|
+
"cwd": "/tmp/r2c1-ws",
|
|
6
|
+
"permission_mode": "default",
|
|
7
|
+
"hook_event_name": "PostToolUse",
|
|
8
|
+
"tool_name": "Bash",
|
|
9
|
+
"tool_input": { "command": "npm test", "description": "Run test suite" },
|
|
10
|
+
"tool_response": { "stdout": "ok", "stderr": "", "interrupted": false, "isImage": false },
|
|
11
|
+
"tool_use_id": "toolu_r2c1_a",
|
|
12
|
+
"duration_ms": 12
|
|
13
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Test preload for real Stop hooks: reject writes whose target is inside one
|
|
4
|
+
// selected session directory while leaving reads and unrelated writes alone.
|
|
5
|
+
// The migration suite passes the target with HARNESS_STOP_TEST_SESSION_DIR.
|
|
6
|
+
|
|
7
|
+
const fs = require('node:fs');
|
|
8
|
+
const path = require('node:path');
|
|
9
|
+
|
|
10
|
+
(function install() {
|
|
11
|
+
const sessionDirectory = process.env.HARNESS_STOP_TEST_SESSION_DIR;
|
|
12
|
+
if (!sessionDirectory) return;
|
|
13
|
+
let resolvedDirectory;
|
|
14
|
+
try { resolvedDirectory = path.resolve(sessionDirectory); } catch (_) { return; }
|
|
15
|
+
if (!resolvedDirectory || resolvedDirectory === path.parse(resolvedDirectory).root) return;
|
|
16
|
+
|
|
17
|
+
function unwritable(target) {
|
|
18
|
+
if (target === undefined || target === null) return false;
|
|
19
|
+
try {
|
|
20
|
+
const resolved = path.resolve(String(target));
|
|
21
|
+
const relative = path.relative(resolvedDirectory, resolved);
|
|
22
|
+
return relative === '' || (!relative.startsWith('..' + path.sep) && relative !== '..' && !path.isAbsolute(relative));
|
|
23
|
+
} catch (_) { return false; }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function denied(method, target) {
|
|
27
|
+
const error = new Error(`EACCES: permission denied, ${method} ${target} (simulated session store write failure)`);
|
|
28
|
+
error.code = 'EACCES';
|
|
29
|
+
error.errno = -13;
|
|
30
|
+
error.syscall = method;
|
|
31
|
+
error.path = String(target);
|
|
32
|
+
return error;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const originalWriteFileSync = fs.writeFileSync;
|
|
36
|
+
fs.writeFileSync = function (file, ...rest) {
|
|
37
|
+
if (unwritable(file)) throw denied('write', file);
|
|
38
|
+
return originalWriteFileSync.call(fs, file, ...rest);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const originalRenameSync = fs.renameSync;
|
|
42
|
+
fs.renameSync = function (from, to, ...rest) {
|
|
43
|
+
if (unwritable(from) || unwritable(to)) throw denied('rename', from);
|
|
44
|
+
return originalRenameSync.call(fs, from, to, ...rest);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const originalOpenSync = fs.openSync;
|
|
48
|
+
fs.openSync = function (file, flags, ...rest) {
|
|
49
|
+
const value = String(flags || 'r');
|
|
50
|
+
if (unwritable(file) && (value.startsWith('w') || value.startsWith('a') || value.includes('+') || value.includes('x'))) {
|
|
51
|
+
throw denied('open', file);
|
|
52
|
+
}
|
|
53
|
+
return originalOpenSync.call(fs, file, flags, ...rest);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const originalUnlinkSync = fs.unlinkSync;
|
|
57
|
+
fs.unlinkSync = function (file, ...rest) {
|
|
58
|
+
if (unwritable(file)) throw denied('unlink', file);
|
|
59
|
+
return originalUnlinkSync.call(fs, file, ...rest);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const callback = args => typeof args[args.length - 1] === 'function' ? args[args.length - 1] : () => {};
|
|
63
|
+
const originalWriteFile = fs.writeFile;
|
|
64
|
+
fs.writeFile = function (file, data, ...rest) {
|
|
65
|
+
const done = callback(rest);
|
|
66
|
+
if (unwritable(file)) return process.nextTick(() => done(denied('write', file)));
|
|
67
|
+
return originalWriteFile.call(fs, file, data, ...rest);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const originalRename = fs.rename;
|
|
71
|
+
fs.rename = function (from, to, ...rest) {
|
|
72
|
+
const done = callback(rest);
|
|
73
|
+
if (unwritable(from) || unwritable(to)) return process.nextTick(() => done(denied('rename', from)));
|
|
74
|
+
return originalRename.call(fs, from, to, ...rest);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const originalUnlink = fs.unlink;
|
|
78
|
+
fs.unlink = function (file, ...rest) {
|
|
79
|
+
const done = callback(rest);
|
|
80
|
+
if (unwritable(file)) return process.nextTick(() => done(denied('unlink', file)));
|
|
81
|
+
return originalUnlink.call(fs, file, ...rest);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const promises = fs.promises;
|
|
85
|
+
if (!promises) return;
|
|
86
|
+
const originalPromisesWriteFile = promises.writeFile;
|
|
87
|
+
promises.writeFile = function (file, data, ...rest) {
|
|
88
|
+
if (unwritable(file)) return Promise.reject(denied('write', file));
|
|
89
|
+
return originalPromisesWriteFile.call(promises, file, data, ...rest);
|
|
90
|
+
};
|
|
91
|
+
const originalPromisesRename = promises.rename;
|
|
92
|
+
promises.rename = function (from, to, ...rest) {
|
|
93
|
+
if (unwritable(from) || unwritable(to)) return Promise.reject(denied('rename', from));
|
|
94
|
+
return originalPromisesRename.call(promises, from, to, ...rest);
|
|
95
|
+
};
|
|
96
|
+
const originalPromisesUnlink = promises.unlink;
|
|
97
|
+
promises.unlink = function (file, ...rest) {
|
|
98
|
+
if (unwritable(file)) return Promise.reject(denied('unlink', file));
|
|
99
|
+
return originalPromisesUnlink.call(promises, file, ...rest);
|
|
100
|
+
};
|
|
101
|
+
const originalPromisesOpen = promises.open;
|
|
102
|
+
promises.open = function (file, flags, ...rest) {
|
|
103
|
+
const value = String(flags || 'r');
|
|
104
|
+
if (unwritable(file) && (value.startsWith('w') || value.startsWith('a') || value.includes('+') || value.includes('x'))) {
|
|
105
|
+
return Promise.reject(denied('open', file));
|
|
106
|
+
}
|
|
107
|
+
return originalPromisesOpen.call(promises, file, flags, ...rest);
|
|
108
|
+
};
|
|
109
|
+
})();
|