From 71b40984e3d1f8262c2cb27b2b673d71c7c34fb9 Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Mon, 2 Nov 2026 23:16:54 -0500 Subject: [PATCH 01/15] Pin the fork at the fail-closed CMDB loader; test a malformed interlock actuates no service overlay/fork.json: core 0ea30a48f (tendcf-integration with cmdb-fail-closed merged): LoadCMDBData() installs nothing from host_specific.json if any entry is invalid (operator ruling R13). tests/policy/run.sh check 4b: a file with one malformed interlock beside a present service processes no service. upstream-register.md: note that B-5b is reversed on the fork. --- docs/architecture/upstream-register.md | 11 ++++++++++ overlay/fork.json | 2 +- tests/policy/run.sh | 29 ++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/docs/architecture/upstream-register.md b/docs/architecture/upstream-register.md index 697eda2..3b46cb2 100644 --- a/docs/architecture/upstream-register.md +++ b/docs/architecture/upstream-register.md @@ -344,6 +344,17 @@ unmerged-libntech submodule dependency, and [#1](https://github.com/djbclark/core/issues/1) is the investigation trail behind P-1/P-2 and is not itself a defect. +**B-5b reversed on the integration branch, 2026-11-02 (operator ruling R13).** +`8f0076b81` made the CMDB loader skip one bad entry and install the rest. For +tendcf that is fail-open: an interlock entry dropped at load leaves the +services it guards actuated unguarded. `tendcf-integration` now carries +`cmdb-fail-closed` (`a750b1dfe`, merged `0ea30a48f`): `LoadCMDBData()` validates +every entry of `vars`/`variables`/`classes` first and installs nothing from +`host_specific.json` if any one is invalid, logging each by name and returning +false; the agent then runs with no CMDB variables. Upstream PRs #6315/#6320 +stay closed unmerged; the overlay manifest's B-5b patch still describes +`8f0076b81`, not this behaviour (see the PR that bumped `overlay/fork.json`). + B-2 through B-7 are described, measured and sourced in [`cfengine-upstream-candidates-2026-08-16.md`](cfengine-upstream-candidates-2026-08-16.md); B-1's full evidence is in diff --git a/overlay/fork.json b/overlay/fork.json index 56cb7a0..dda17b6 100644 --- a/overlay/fork.json +++ b/overlay/fork.json @@ -3,7 +3,7 @@ "core": { "repo": "https://github.com/djbclark/core", "branch": "tendcf-integration", - "commit": "b8abf28408b1b54e285d372a9bc5f2d850c960ad" + "commit": "0ea30a48fc54c343aa04e9a99f12bfd128d4d3f5" }, "libntech": { "repo": "https://github.com/djbclark/libntech" diff --git a/tests/policy/run.sh b/tests/policy/run.sh index fa233fc..55d9c8e 100755 --- a/tests/policy/run.sh +++ b/tests/policy/run.sh @@ -26,6 +26,11 @@ # (darwin) and systemd (Linux booted by systemd), so the entry must be # refused by name and nothing rendered, on every host (linux-targets.md # step 3: the fail-closed guard, with this as its negative test). +# 4b. malformed interlock entry, enforce mode: a host_specific.json whose +# interlock has an unresolved variable reference, beside a present +# service. The fork's CMDB loader is all-or-nothing, so the file installs +# nothing: no service is processed and no interlock runs. A loader that +# skipped only the bad entry would let the service through unguarded. # 5. host guard, enforce mode, non-Darwin only: a satisfied interlock and # two present launchd services. launchd exists only on darwin, so a # Linux host must refuse both, write nothing under /Library and run no @@ -224,6 +229,30 @@ check "nothing rendered for the runit entry" \ check "no launchctl invocation" \ bash -c "! grep -q launchctl '$out'" +echo "# 4b. malformed interlock entry: the CMDB loader fails closed" +# One malformed entry (an unresolved variable reference in the interlock's +# pre_action) next to a present service. The pre_action would fail if it ran, +# so a loader that dropped only the bad entry and kept the rest would let the +# service through unguarded: the service would be processed and reported (the +# runit flavour is refused by name on every host, check 4). The fork's +# all-or-nothing CMDB loader installs nothing from the file, so no service and +# no interlock exists to act on, and the error names the entry. +cp "$repo/tests/policy/fixtures/interlock-malformed.json" "$work/data/host_specific.json" +out="$work/malformed.out" +"$cf_agent" -K -I -f "$work/inputs/entry.cf" >"$out" 2>&1 || true +check "malformed entry named in the CMDB error" \ + grep -q "offending value in entry 'tendcf_interlock'" "$out" +check "loader reports that it installed none of the file" \ + grep -q "installing none of its contents" "$out" +check "no service processed (the sibling service entry was not installed)" \ + bash -c "! grep -q \"tendcf: service 'demo-runit'\" '$out'" +check "no interlock command executed" \ + bash -c "! grep -q \"Executing .*'/usr/bin/false'\" '$out'" +check "nothing rendered" \ + bash -c "! grep -q 'Created file' '$out'" +check "no launchctl or systemctl invocation" \ + bash -c "! grep -Eq 'launchctl|systemctl' '$out'" + if [ "$(uname)" != Darwin ]; then echo "# 5. host guard: launchd entries refused on $(uname)" cp "$repo/tests/policy/fixtures/launchd-present.json" "$work/data/host_specific.json" From 341f37f3f3c8e3c89c2ec997738f0a420cfe596c Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Mon, 2 Nov 2026 23:22:21 -0500 Subject: [PATCH 02/15] Move the fork pin to c3afaac26 (acceptance 08/09 updated for all-or-nothing CMDB) --- docs/architecture/upstream-register.md | 2 +- overlay/fork.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/architecture/upstream-register.md b/docs/architecture/upstream-register.md index 3b46cb2..d2a3f99 100644 --- a/docs/architecture/upstream-register.md +++ b/docs/architecture/upstream-register.md @@ -348,7 +348,7 @@ investigation trail behind P-1/P-2 and is not itself a defect. `8f0076b81` made the CMDB loader skip one bad entry and install the rest. For tendcf that is fail-open: an interlock entry dropped at load leaves the services it guards actuated unguarded. `tendcf-integration` now carries -`cmdb-fail-closed` (`a750b1dfe`, merged `0ea30a48f`): `LoadCMDBData()` validates +`cmdb-fail-closed` (`a750b1dfe` + `dbf9dede6`, merged `c3afaac26`): `LoadCMDBData()` validates every entry of `vars`/`variables`/`classes` first and installs nothing from `host_specific.json` if any one is invalid, logging each by name and returning false; the agent then runs with no CMDB variables. Upstream PRs #6315/#6320 diff --git a/overlay/fork.json b/overlay/fork.json index dda17b6..0af08f2 100644 --- a/overlay/fork.json +++ b/overlay/fork.json @@ -3,7 +3,7 @@ "core": { "repo": "https://github.com/djbclark/core", "branch": "tendcf-integration", - "commit": "0ea30a48fc54c343aa04e9a99f12bfd128d4d3f5" + "commit": "c3afaac26098972ba46f61cdd4955557e73582a6" }, "libntech": { "repo": "https://github.com/djbclark/libntech" From d4e8c1f09b82c5fd0ee497797c0ce6f70bcf26e2 Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Fri, 6 Nov 2026 11:28:07 -0500 Subject: [PATCH 03/15] Pin the fork at 8e70831f3; check 4b probes for both containers, adds an index-key case The fork now also rejects index-bracket keys, frame-dependent scopes, null sections, non-string rule elements, duplicate variables and unknown top-level keys. run.sh 4b runs a probe policy (fixtures/cmdb-probe.cf) that asks isvariable() whether data:variables.tendcf_interlock and ...tendcf_service exist after each malformed load, with a loading file as positive control, and a second fixture whose key 'tendcf_interlock[' the variable parser reads as the interlock container. --- docs/architecture/upstream-register.md | 11 ++- overlay/fork.json | 2 +- tests/policy/fixtures/cmdb-probe.cf | 24 +++++ .../fixtures/interlock-malformed-key.json | 1 + tests/policy/run.sh | 88 +++++++++++++------ 5 files changed, 93 insertions(+), 33 deletions(-) create mode 100644 tests/policy/fixtures/cmdb-probe.cf create mode 100644 tests/policy/fixtures/interlock-malformed-key.json diff --git a/docs/architecture/upstream-register.md b/docs/architecture/upstream-register.md index d2a3f99..c6fd793 100644 --- a/docs/architecture/upstream-register.md +++ b/docs/architecture/upstream-register.md @@ -348,10 +348,13 @@ investigation trail behind P-1/P-2 and is not itself a defect. `8f0076b81` made the CMDB loader skip one bad entry and install the rest. For tendcf that is fail-open: an interlock entry dropped at load leaves the services it guards actuated unguarded. `tendcf-integration` now carries -`cmdb-fail-closed` (`a750b1dfe` + `dbf9dede6`, merged `c3afaac26`): `LoadCMDBData()` validates -every entry of `vars`/`variables`/`classes` first and installs nothing from -`host_specific.json` if any one is invalid, logging each by name and returning -false; the agent then runs with no CMDB variables. Upstream PRs #6315/#6320 +`cmdb-fail-closed` (`a750b1dfe`, `dbf9dede6`, `61065e551`; merged `8e70831f3`): +`LoadCMDBData()` validates every entry of `vars`/`variables`/`classes` first +and installs nothing from `host_specific.json` if any one is invalid (also an +unknown top-level key, a null section, a key with index brackets, a +frame-dependent special scope, two entries naming one variable), logging each +by name and returning false; the agent then runs with no CMDB variables. +Upstream PRs #6315/#6320 stay closed unmerged; the overlay manifest's B-5b patch still describes `8f0076b81`, not this behaviour (see the PR that bumped `overlay/fork.json`). diff --git a/overlay/fork.json b/overlay/fork.json index 0af08f2..a9d9102 100644 --- a/overlay/fork.json +++ b/overlay/fork.json @@ -3,7 +3,7 @@ "core": { "repo": "https://github.com/djbclark/core", "branch": "tendcf-integration", - "commit": "c3afaac26098972ba46f61cdd4955557e73582a6" + "commit": "8e70831f3c473309765b850685a04bdba48b5e2f" }, "libntech": { "repo": "https://github.com/djbclark/libntech" diff --git a/tests/policy/fixtures/cmdb-probe.cf b/tests/policy/fixtures/cmdb-probe.cf new file mode 100644 index 0000000..1cfb8e3 --- /dev/null +++ b/tests/policy/fixtures/cmdb-probe.cf @@ -0,0 +1,24 @@ +# Reports whether the two goal-file containers the generic bundle reads are +# installed as CMDB data. Run alone by tests/policy/run.sh, after a load that +# must have installed everything or nothing; it actuates nothing. +body common control +{ + bundlesequence => { "cmdb_probe" }; +} + +bundle agent cmdb_probe +{ + classes: + "interlock_present" expression => isvariable("data:variables.tendcf_interlock"); + "service_present" expression => isvariable("data:variables.tendcf_service"); + + reports: + interlock_present:: + "cmdb-probe: tendcf_interlock present"; + !interlock_present:: + "cmdb-probe: tendcf_interlock absent"; + service_present:: + "cmdb-probe: tendcf_service present"; + !service_present:: + "cmdb-probe: tendcf_service absent"; +} diff --git a/tests/policy/fixtures/interlock-malformed-key.json b/tests/policy/fixtures/interlock-malformed-key.json new file mode 100644 index 0000000..c54abcb --- /dev/null +++ b/tests/policy/fixtures/interlock-malformed-key.json @@ -0,0 +1 @@ +{"vars":{"tendcf_interlock":{"demo-check":{"blocks":"enclosing-bundle","bundle":"demo","defines_class":"demo_ok","pre_action":{"command":["/usr/bin/false"],"expect_exit":0,"timeout_seconds":5},"report":true,"state":"present"}},"tendcf_interlock[":[],"tendcf_service":{"demo-runit":{"bundle":"demo","command":["/bin/sleep","1"],"run_as":"nobody","state":"present","unit":{"runit":{"enabled":true}},"working_dir":"/"}}}} diff --git a/tests/policy/run.sh b/tests/policy/run.sh index 55d9c8e..99dcd04 100755 --- a/tests/policy/run.sh +++ b/tests/policy/run.sh @@ -26,11 +26,15 @@ # (darwin) and systemd (Linux booted by systemd), so the entry must be # refused by name and nothing rendered, on every host (linux-targets.md # step 3: the fail-closed guard, with this as its negative test). -# 4b. malformed interlock entry, enforce mode: a host_specific.json whose -# interlock has an unresolved variable reference, beside a present -# service. The fork's CMDB loader is all-or-nothing, so the file installs -# nothing: no service is processed and no interlock runs. A loader that -# skipped only the bad entry would let the service through unguarded. +# 4b. malformed CMDB entries, enforce mode: a host_specific.json with one +# malformed entry (an unresolved variable reference in the interlock; +# then a key 'tendcf_interlock[' that the variable parser reads as the +# interlock container) beside a valid interlock and a present service. +# The fork's CMDB loader is all-or-nothing, so the file installs nothing: +# no service is processed, no interlock runs, and a probe policy finds +# neither data:variables.tendcf_interlock nor ...tendcf_service. A +# loader that skipped only the bad entry would let the service through +# unguarded. # 5. host guard, enforce mode, non-Darwin only: a satisfied interlock and # two present launchd services. launchd exists only on darwin, so a # Linux host must refuse both, write nothing under /Library and run no @@ -229,29 +233,57 @@ check "nothing rendered for the runit entry" \ check "no launchctl invocation" \ bash -c "! grep -q launchctl '$out'" -echo "# 4b. malformed interlock entry: the CMDB loader fails closed" -# One malformed entry (an unresolved variable reference in the interlock's -# pre_action) next to a present service. The pre_action would fail if it ran, -# so a loader that dropped only the bad entry and kept the rest would let the -# service through unguarded: the service would be processed and reported (the -# runit flavour is refused by name on every host, check 4). The fork's -# all-or-nothing CMDB loader installs nothing from the file, so no service and -# no interlock exists to act on, and the error names the entry. -cp "$repo/tests/policy/fixtures/interlock-malformed.json" "$work/data/host_specific.json" -out="$work/malformed.out" -"$cf_agent" -K -I -f "$work/inputs/entry.cf" >"$out" 2>&1 || true -check "malformed entry named in the CMDB error" \ - grep -q "offending value in entry 'tendcf_interlock'" "$out" -check "loader reports that it installed none of the file" \ - grep -q "installing none of its contents" "$out" -check "no service processed (the sibling service entry was not installed)" \ - bash -c "! grep -q \"tendcf: service 'demo-runit'\" '$out'" -check "no interlock command executed" \ - bash -c "! grep -q \"Executing .*'/usr/bin/false'\" '$out'" -check "nothing rendered" \ - bash -c "! grep -q 'Created file' '$out'" -check "no launchctl or systemctl invocation" \ - bash -c "! grep -Eq 'launchctl|systemctl' '$out'" +echo "# 4b. malformed CMDB entries: the loader fails closed" +# Each fixture is a host_specific.json with one malformed entry next to a +# valid interlock and a present service. The interlock's pre_action would +# fail if it ran, so a loader that dropped only the bad entry (or let it take +# the place of another) would let the service through unguarded: the service +# would be processed and reported (the runit flavour is refused by name on +# every host, check 4). The fork's all-or-nothing CMDB loader installs +# nothing from the file, so no service and no interlock exists to act on. +# Besides what the agent did, the probe policy asks it directly whether either +# container exists, which a service-only or interlock-only leftover cannot hide +# from; its positive control is a file that loads. +cp "$repo/tests/policy/fixtures/cmdb-probe.cf" "$work/inputs/cmdb-probe.cf" +probe() { # probe FIXTURE OUT: run the probe policy over FIXTURE as CMDB data + cp "$repo/tests/policy/fixtures/$1" "$work/data/host_specific.json" + "$cf_agent" -K -f "$work/inputs/cmdb-probe.cf" >"$2" 2>&1 || true +} +probe interlock-refused.json "$work/probe-control.out" +check "probe control: a file that loads has tendcf_interlock" \ + grep -q "cmdb-probe: tendcf_interlock present" "$work/probe-control.out" +check "probe control: a file that loads has tendcf_service" \ + grep -q "cmdb-probe: tendcf_service present" "$work/probe-control.out" + +malformed_case() { # malformed_case NAME FIXTURE ERROR-PATTERN + local name="$1" fixture="$2" pattern="$3" + out="$work/malformed-$name.out" + cp "$repo/tests/policy/fixtures/$fixture" "$work/data/host_specific.json" + "$cf_agent" -K -I -f "$work/inputs/entry.cf" >"$out" 2>&1 || true + check "$name: malformed entry named in the CMDB error" grep -q "$pattern" "$out" + check "$name: loader reports that it installed none of the file" \ + grep -q "installing none of its contents" "$out" + check "$name: no service processed (the sibling service entry was not installed)" \ + bash -c "! grep -q \"tendcf: service 'demo-runit'\" '$out'" + check "$name: no interlock command executed" \ + bash -c "! grep -q \"Executing .*'/usr/bin/false'\" '$out'" + check "$name: nothing rendered" \ + bash -c "! grep -q 'Created file' '$out'" + check "$name: no launchctl or systemctl invocation" \ + bash -c "! grep -Eq 'launchctl|systemctl' '$out'" + probe "$fixture" "$work/probe-$name.out" + check "$name: no tendcf_interlock variable" \ + grep -q "cmdb-probe: tendcf_interlock absent" "$work/probe-$name.out" + check "$name: no tendcf_service variable" \ + grep -q "cmdb-probe: tendcf_service absent" "$work/probe-$name.out" +} +# an unresolved variable reference in the interlock's pre_action +malformed_case unresolved interlock-malformed.json \ + "offending value in entry 'tendcf_interlock'" +# a key the variable parser reads as the interlock container itself +# ('tendcf_interlock[' is 'tendcf_interlock' to it, with only a log message) +malformed_case index-key interlock-malformed-key.json \ + "Invalid variable specification in CMDB data: 'tendcf_interlock\\['" if [ "$(uname)" != Darwin ]; then echo "# 5. host guard: launchd entries refused on $(uname)" From c9813afe9fa8a4e62df21c918b3697264954f10b Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Fri, 6 Nov 2026 11:33:14 -0500 Subject: [PATCH 04/15] Move the fork pin to d32cade13 (rollback free() fix) --- docs/architecture/upstream-register.md | 2 +- overlay/fork.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/architecture/upstream-register.md b/docs/architecture/upstream-register.md index c6fd793..27a3cdd 100644 --- a/docs/architecture/upstream-register.md +++ b/docs/architecture/upstream-register.md @@ -348,7 +348,7 @@ investigation trail behind P-1/P-2 and is not itself a defect. `8f0076b81` made the CMDB loader skip one bad entry and install the rest. For tendcf that is fail-open: an interlock entry dropped at load leaves the services it guards actuated unguarded. `tendcf-integration` now carries -`cmdb-fail-closed` (`a750b1dfe`, `dbf9dede6`, `61065e551`; merged `8e70831f3`): +`cmdb-fail-closed` (`a750b1dfe`, `dbf9dede6`, `61065e551`, `736becc07`; merged `d32cade13`): `LoadCMDBData()` validates every entry of `vars`/`variables`/`classes` first and installs nothing from `host_specific.json` if any one is invalid (also an unknown top-level key, a null section, a key with index brackets, a diff --git a/overlay/fork.json b/overlay/fork.json index a9d9102..7551567 100644 --- a/overlay/fork.json +++ b/overlay/fork.json @@ -3,7 +3,7 @@ "core": { "repo": "https://github.com/djbclark/core", "branch": "tendcf-integration", - "commit": "8e70831f3c473309765b850685a04bdba48b5e2f" + "commit": "d32cade138cad76ebd9ac8ab7757a29a6afe59e4" }, "libntech": { "repo": "https://github.com/djbclark/libntech" From 236302adb1f909b783c557118475816a847dc12b Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 14 Nov 2026 14:48:35 -0500 Subject: [PATCH 05/15] Correct the loader statements the all-or-nothing pin makes false (run.sh, sim-loader.cf, policy comment) The pinned fork (d32cade13) installs nothing from a file with any invalid entry. run.sh check 9's NB and check 10's header said the fork skips one entry; the policy's CMDB cross-check comment and the sim-loader.cf header said the same. State what each loader does, and why the simulated loader stays valid. Check 9's malformed case now also asserts the valid sibling tendcf_service is not installed. The 'did not load' report no longer says the loader 'skipped' the key. Co-Authored-By: Claude Sonnet 5.5 --- policy/tendcf_services.cf | 19 ++++++++++++------- tests/policy/run.sh | 26 +++++++++++++++++++------- tests/policy/sim-loader.cf | 10 +++++++--- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/policy/tendcf_services.cf b/policy/tendcf_services.cf index 29f0508..5009436 100644 --- a/policy/tendcf_services.cf +++ b/policy/tendcf_services.cf @@ -62,12 +62,17 @@ # # CMDB cross-check (`tendcf_cmdb`, proposal 2026-11-03 section 13, option 3, # operator ruling Q10 2026-11-02). Everything above assumes CFEngine's loader -# installed what host_specific.json says. It does not promise that: the fork's -# loader skips a bad entry on its own and still returns success, so a skipped -# `tendcf_interlock` leaves every service ungated (services are gated -# negatively, on `!interlock_blocked_*`, and that class only exists for an -# interlock that loaded). The check does not model WHY an entry was dropped. It -# reads the file itself and compares it with what the loader installed: +# installed what host_specific.json says. Nothing promises that for every +# engine: the fork before 2026-11-02 (`8f0076b81`, B-5b) skipped a bad entry on +# its own and still returned success, and a skipped `tendcf_interlock` leaves +# every service ungated (services are gated negatively, on +# `!interlock_blocked_*`, and that class only exists for an interlock that +# loaded). The fork at the pin (overlay/fork.json, PR #41, operator ruling R13) +# loads all-or-nothing instead: any invalid entry and it installs none of the +# file, so this check then sees every `vars` key missing and refuses. The two +# are independent: the check holds for a loader that fails closed, for one that +# does not, and for a gap in either. The check does not model WHY an entry was +# dropped. It reads the file itself and compares it with what the loader installed: # - the file's top-level keys must be exactly `vars`. The loader also applies # a `variables` section (loaded AFTER `vars`, replacing a same-named # variable) and a `classes` section (which can define `interlock_ok_*`); @@ -544,7 +549,7 @@ bundle agent tendcf_interlocks "tendcf: CMDB cross-check: $(tendcf_cmdb.file) does not exist but CFEngine loaded data:variables.$(tendcf_cmdb.loaded_clean)"; "tendcf_cmdb_problem_missing":: - "tendcf: CMDB cross-check: key '$(tendcf_cmdb.missing_clean)' is under 'vars' in $(tendcf_cmdb.file) but CFEngine did not load data:variables.$(tendcf_cmdb.missing_clean) (the loader skipped it)"; + "tendcf: CMDB cross-check: key '$(tendcf_cmdb.missing_clean)' is under 'vars' in $(tendcf_cmdb.file) but CFEngine did not load data:variables.$(tendcf_cmdb.missing_clean) (the loader did not install it)"; "tendcf_cmdb_problem_unlisted":: "tendcf: CMDB cross-check: CFEngine loaded data:variables.$(tendcf_cmdb.unlisted_clean), which is not a key under 'vars' in $(tendcf_cmdb.file)"; diff --git a/tests/policy/run.sh b/tests/policy/run.sh index 99dcd04..ee57ee5 100755 --- a/tests/policy/run.sh +++ b/tests/policy/run.sh @@ -81,14 +81,21 @@ # container that is a list of strings is the positive control: accepted, # actuates. A plain-identifier key longer than 64 characters is refused and # its report line shows only the first 64. Every file of checks 2-8 and 6 is also a no-report control. -# NB: the fork's loader skips a bad entry and installs the rest, but the -# Mac dev build rejects the whole `vars` instead (the same fixture refuses -# on both, as "nothing loaded"), so only the fork's CI legs see the -# per-entry skip. +# NB: the fork at the pin (overlay/fork.json) loads all-or-nothing (PR #41, +# operator ruling R13): a file with any invalid entry installs none of its +# contents, so on the Linux legs this check sees every `vars` key missing, +# as the Mac dev build does when it rejects the whole `vars`. The same +# fixture refuses the same way on both ("nothing loaded"). No loader this +# check runs against skips one entry and installs the rest; the fork did +# before R13 (`8f0076b81`, B-5b), which is the 2026-11-02 fail-open. # 10. the same cross-check against a loader that skips ONE container, which -# the Mac dev build cannot do: tests/policy/sim-loader.cf installs -# data:variables.* in the loader's place (cf-agent --no-host-specific-data) -# from the very file the policy reads. Each case must report what differs +# neither the Mac dev build nor the pinned fork does: tests/policy/sim-loader.cf +# installs data:variables.* in the loader's place (cf-agent +# --no-host-specific-data) from the very file the policy reads. It stays +# valid after R13: the check compares the file with what is installed +# whatever the loader's policy, and this is the only way to test the +# partial states (a fork before the pin, another engine, a gap in the +# loader's validation). Each case must report what differs # and run nothing; the control case (everything installed) must run as # before, so the others cannot pass because the stand-in installed nothing. # A skipped interlock container with the services loaded is the 2026-11-02 @@ -613,6 +620,11 @@ out="$work/xc-malformed.out" check "malformed interlock: refusal reported" refusal_reported "$out" check "malformed interlock: the container the loader did not install is named" \ key_not_loaded "$out" tendcf_interlock +# All-or-nothing: the valid sibling container is not installed either (the +# pre-R13 fork installed it, which was the fail-open; the Mac dev build rejects +# the whole `vars`, so it agrees). +check "malformed interlock: the sibling tendcf_service is not installed either (all-or-nothing)" \ + key_not_loaded "$out" tendcf_service check "malformed interlock: refusal reported once" refusal_once "$out" check "malformed interlock: nothing actuated, no pre_action run, no service processed" \ no_actuation "$out" diff --git a/tests/policy/sim-loader.cf b/tests/policy/sim-loader.cf index b35a30b..d816a17 100644 --- a/tests/policy/sim-loader.cf +++ b/tests/policy/sim-loader.cf @@ -1,7 +1,11 @@ # Test only (tests/policy/run.sh checks 9-10). Stands in for a CMDB loader that -# skipped, or half installed, a container of host_specific.json, which is the -# fork's behaviour on a bad `tendcf_interlock` entry (the Mac dev build rejects -# the whole `vars` instead, so it cannot be made to skip one container). Run +# skipped, or half installed, a container of host_specific.json. No loader the +# tests run does that: the fork at the pin (overlay/fork.json) is all-or-nothing +# (a file with any invalid entry installs nothing, since PR #41, operator ruling +# R13) and the Mac dev build rejects the whole `vars`. The fork before R13 +# (`8f0076b81`, B-5b) did skip one bad entry, which was the 2026-11-02 +# fail-open; this stand-in keeps that state testable, and the cross-check +# must refuse it however a loader came to leave it. Run # cf-agent with --no-host-specific-data so this is the only thing installing # data:variables.*, and list this file BEFORE tendcf_services.cf in `inputs`: # the data must exist before tendcf_cmdb reads it. From 59b725394288906602cbaebc64a29887444be4a9 Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 14 Nov 2026 14:49:11 -0500 Subject: [PATCH 06/15] Validate proposal: record the 2026-11-02 rulings (Q10 option 3, R13 option 5); date the pre-#41 loader statements Section 13 now says both options were ruled, each independent of the other, without repeating the 'Implemented 2026-11-06' paragraph. Fact 2, the checked- commit sentence, the expand.c citation and finding (1) described the pin of the time as the pinned fork; they now name b8abf28408b1 as the earlier pin and say the Linux legs no longer see a per-entry skip. Co-Authored-By: Claude Sonnet 5.5 --- .../tendcf-validate-proposal-2026-11-03.md | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/docs/architecture/tendcf-validate-proposal-2026-11-03.md b/docs/architecture/tendcf-validate-proposal-2026-11-03.md index 5e5aeb0..163a2f0 100644 --- a/docs/architecture/tendcf-validate-proposal-2026-11-03.md +++ b/docs/architecture/tendcf-validate-proposal-2026-11-03.md @@ -15,8 +15,9 @@ TUF); map §11 (timeout is deny); [`change-process.md`](change-process.md) of [`projector-reconciliation-2026-08-16.md`](projector-reconciliation-2026-08-16.md). How the CFEngine claims were checked: the fork source at the commit -`overlay/fork.json` pins (`b8abf28408b1b54e285d372a9bc5f2d850c960ad`, -read with `git show` in `~/src/cfengine-core`). The book (*Learning +`overlay/fork.json` pinned when this was written +(`b8abf28408b1b54e285d372a9bc5f2d850c960ad`, read with `git show` in +`~/src/cfengine-core`; PR #41 later moved the pin, see §13). The book (*Learning CFEngine*, 3.12) was searched first. It covers cf-execd's role and five-minute default schedule (ch. 23) and `cf-runagent` (ch. 35). `book-kb query` finds neither `host_specific` nor `exec_command` in it: both postdate or @@ -33,8 +34,9 @@ Each was read in the pinned fork source or in this repository on (`libpromises/generic_agent.c:1234`) logs a failed load ("Failed to load CMDB data") and the run continues. `cf-agent --no-host-specific-data` skips the load entirely. -2. **On the pinned fork, a bad entry is skipped on its own, not with the - whole file.** `ReadCMDBVars` `continue`s past an entry carrying an +2. **On the fork at the pin of the time (`b8abf28408b1`), a bad entry is + skipped on its own, not with the whole file.** (Superseded: the pin + now carries an all-or-nothing loader, PR #41, §13.) `ReadCMDBVars` `continue`s past an entry carrying an unexpanded variable reference or an invalid key, and still installs the others. The cause is fork commit `8f0076b81` ("Fixed one bad CMDB entry discarding every entry in its section"), merged into @@ -1022,8 +1024,11 @@ projection that `tendcf-install.sh install --data` puts on pastebin (deploy/linux/README.md) carries both containers: its `vars` keys are `tendcf_interlock` and `tendcf_service`, checked 2026-11-02. Any skip of the first leaves the second ungated. No skip is known to happen with the -current bytes, which pass the N-series. It is flagged for djbclark, not -decided here. +current bytes, which pass the N-series. It was flagged for djbclark. +**Ruled 2026-11-02:** option 3 (Q10), implemented in PR #42, which records it +below; and option 5 (R13, Q49), the fork's all-or-nothing loader pinned by PR +#41 ([`upstream-register.md`](upstream-register.md) B-5b note). Each holds +without the other. **(a) Question.** When the CMDB loader installs `tendcf_service` but not `tendcf_interlock` (fact 2), how does the policy refuse, instead of @@ -1204,8 +1209,8 @@ rvalue does redefine a preset, a function call does not), and the two no pre_action, no service, no tombstone. The vars and classes of a `bundle common` are pre-evaluated before the vars of any non-common bundle, whatever `bundlesequence` says (`PolicyResolve` and `BundleResolve`, -`libpromises/expand.c` lines 846-871 and 1145-1177 at the pinned fork commit -`b8abf28408b1`, [expand.c](https://github.com/djbclark/core/blob/b8abf28408b1b54e285d372a9bc5f2d850c960ad/libpromises/expand.c#L846)), +`libpromises/expand.c` lines 846-871 and 1145-1177 at fork commit +`b8abf28408b1` (the pin when this was written), [expand.c](https://github.com/djbclark/core/blob/b8abf28408b1b54e285d372a9bc5f2d850c960ad/libpromises/expand.c#L846)), so `tendcf_cmdb_refused` is decided before a gate is first read. That is a statement about vars and classes only, not that every promise type of a common bundle completes first, and the classes inside the check rely on their written @@ -1224,9 +1229,15 @@ makes it install nothing at all, so the fail-open cannot be reproduced there with a file. `tests/policy/sim-loader.cf` therefore installs `data:variables.*` in the loader's place, from the same file, to emulate the per-entry skip; the original policy was run against it first and did -process the service with its interlock skipped. The Linux CI legs build the -pinned fork and so also exercise the real per-entry skip with the literal -fixture (`tests/policy/fixtures/interlock-malformed.json`). (2) The check +process the service with its interlock skipped. When this was written the +Linux CI legs built the fork at `b8abf28408b1` and so also exercised the real +per-entry skip with the literal fixture +(`tests/policy/fixtures/interlock-malformed.json`). That no longer holds: PR +#41 moved the pin to the all-or-nothing loader, which installs nothing from +that fixture, so check 9 sees both keys missing and the partial states stay +tested only through the stand-in (check 10), which remains valid because the +check compares the file with what was installed whatever the loader's policy. +(2) The check needs `readjson` and `variablesmatching` to compose on the loader's installed variables; they do on the dev build (checks 9-10 of `tests/policy/run.sh`), so option 4 stays unneeded. The policy-tree digest From 0b41cb5db964cd1a3a298c72ef702f7b74bbd091 Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 14 Nov 2026 14:49:11 -0500 Subject: [PATCH 07/15] Overlay B-5b: note that the fork's all-or-nothing loader supersedes it (manifest, register, overlay doc) The B-5b entry still reproduces 8f0076b81, which the pinned fork reversed (R13). Add a superseded_on_fork note to overlay.json, replace the register's 'see the PR' pointer with the actual statement, and add a section 7 note. Whether to keep, retire or replace the patch is a separate ruling because it changes what the overlay reproduces. Co-Authored-By: Claude Sonnet 5.5 --- docs/architecture/upstream-overlay.md | 10 ++++++++++ docs/architecture/upstream-register.md | 8 ++++++-- overlay/overlay.json | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/architecture/upstream-overlay.md b/docs/architecture/upstream-overlay.md index 8722cb5..d23dfbe 100644 --- a/docs/architecture/upstream-overlay.md +++ b/docs/architecture/upstream-overlay.md @@ -220,6 +220,16 @@ drops it. | `retired --strict` against upstream master | nothing to retire | nothing to retire | | `self-test` | 13/13 | | +**Since 2026-11-02 (R13, PR #41) the core column's B-5b is not what the fork +the tests run does.** The pin in `overlay/fork.json` carries an all-or-nothing +CMDB loader that replaces B-5b's per-entry skip (a skipped interlock leaves the +services it guards unguarded). The manifest entry still reproduces `8f0076b81` +and carries a `superseded_on_fork` note; the table above is the 2026-10-09 +state and is not updated. Upstream plus this overlay skips a bad entry; the +pinned fork installs nothing from the file. Keeping, retiring or replacing the +patch is a separate ruling ([`upstream-register.md`](upstream-register.md) B-5b +note). + So the overlay reproduces exactly the inputs whose build was verified on 2026-08-19, from this repository alone, and would still apply to a build cut from today's upstream. diff --git a/docs/architecture/upstream-register.md b/docs/architecture/upstream-register.md index 27a3cdd..1eaec7e 100644 --- a/docs/architecture/upstream-register.md +++ b/docs/architecture/upstream-register.md @@ -355,8 +355,12 @@ unknown top-level key, a null section, a key with index brackets, a frame-dependent special scope, two entries naming one variable), logging each by name and returning false; the agent then runs with no CMDB variables. Upstream PRs #6315/#6320 -stay closed unmerged; the overlay manifest's B-5b patch still describes -`8f0076b81`, not this behaviour (see the PR that bumped `overlay/fork.json`). +stay closed unmerged. The overlay manifest's B-5b entry (`overlay/overlay.json`) +still describes and reproduces `8f0076b81`, not this behaviour; it now carries +a `superseded_on_fork` note saying so, and +[`upstream-overlay.md`](upstream-overlay.md) section 7 repeats it. Whether the +overlay keeps, retires or replaces that patch is left to a separate ruling, +because it changes what the overlay reproduces. B-2 through B-7 are described, measured and sourced in [`cfengine-upstream-candidates-2026-08-16.md`](cfengine-upstream-candidates-2026-08-16.md); diff --git a/overlay/overlay.json b/overlay/overlay.json index 3670b7e..949e2d7 100644 --- a/overlay/overlay.json +++ b/overlay/overlay.json @@ -32,6 +32,7 @@ "retire_when": "an upstream commit carries the same change (`bin/overlay.py retired` says RETIRE), or the code it protects is no longer shipped", "role": "load-bearing", "subject": "Fixed one bad CMDB entry discarding every entry in its section", + "superseded_on_fork": "2026-11-02, operator ruling R13 (PR #41): the fork's tendcf-integration branch, which overlay/fork.json pins, replaces this patch's per-entry skip with an all-or-nothing loader (branch cmdb-fail-closed: a750b1dfe, dbf9dede6, 61065e551, 736becc07; merged d32cade13). A skipped interlock entry leaves the services it guards unguarded. This entry still describes, and apply reproduces, commit 8f0076b81 exactly, so upstream plus the overlay skips a bad entry and does NOT behave like the pinned fork. Keeping, retiring or replacing it is a separate ruling because it changes what the overlay reproduces (upstream-overlay.md section 7).", "upstream_pr": "https://github.com/cfengine/core/pull/6320", "upstream_pr_state": "closed unmerged 2026-08-19" } From 867591e0bf70a7109b8911de79b288fd2e63282c Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 14 Nov 2026 14:49:35 -0500 Subject: [PATCH 08/15] Policy comment: the verify_vars.c reading was at b8abf28408b1; the pin moved to d32cade13, which differs only in cmdb.c/cmdb.h and tests Checked with the GitHub compare API on djbclark/core (8 commits, 10 files). Co-Authored-By: Claude Sonnet 5.5 --- policy/tendcf_services.cf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/policy/tendcf_services.cf b/policy/tendcf_services.cf index 5009436..38e8047 100644 --- a/policy/tendcf_services.cf +++ b/policy/tendcf_services.cf @@ -138,8 +138,9 @@ # Presets. The loader installs a `vars` key under any name, so a key such as # `default:tendcf_cmdb.doc` or `default:tendcf_services.interlock_ids` presets # that variable before any policy runs. What a preset does then depends on the -# promise (verify_vars.c VerifyVarPromise, commit b8abf28408b1 pinned in -# overlay/fork.json): a promise with a LITERAL rvalue (`slist => { }`) always +# promise (verify_vars.c VerifyVarPromise, read at commit b8abf28408b1; the +# pin in overlay/fork.json is now d32cade13, which differs from it only in +# libpromises/cmdb.c, cmdb.h and tests): a promise with a LITERAL rvalue (`slist => { }`) always # redefines it, so the policy's value stands. A promise whose rvalue is a # FUNCTION CALL is skipped when the variable exists ("Already did this") if the # call was not already evaluated to a value when the promise runs, and From 219f9fc121e3df1b06473a174899dc5e0cf6caef Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 14 Nov 2026 14:57:38 -0500 Subject: [PATCH 09/15] Check 9 variables collision: assert what the pinned loader does (refuses the whole file), not a content difference The pinned fork rejects a file in which 'variables' names a variable 'vars' already names (CMDBPendingCheckNoDuplicates, 61065e551) and installs none of it, so the cross-check sees the key missing, not a content difference (Linux CI 867591e, all 4 legs, one FAIL). Assert the loader's duplicate refusal, 'installing none', the interlock reported not installed and no content-difference report; keep section named, refusal once, no actuation. Same-id content differences stay tested in check 10 (stand-in loader) and check 11. Fix the stale 'loader applies variables after vars' text in run.sh, the policy comment, the proposal and projector.py. Co-Authored-By: Claude Sonnet 5.5 --- bin/projector.py | 4 ++- .../tendcf-validate-proposal-2026-11-03.md | 8 +++-- policy/tendcf_services.cf | 8 +++-- tests/policy/run.sh | 32 +++++++++++++------ 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/bin/projector.py b/bin/projector.py index c8ad5f4..8700cb9 100755 --- a/bin/projector.py +++ b/bin/projector.py @@ -409,7 +409,9 @@ def flag(rule: str, msg: str) -> None: # E-6/E-7: these are LEGAL to CFEngine, which is exactly why the # negative exists — `variables` loads after `vars` and overwrites # the same name, so a checker that only asks "is `vars` right?" - # never sees the document that replaced it. + # never sees the document that replaced it. (The fork pinned in + # overlay/fork.json instead refuses a file in which `variables` + # names a variable `vars` already names; upstream replaces it.) extra = ( " — legal to CFEngine, loaded after `vars` and overwriting the " "same names, which is why envelope-shape checking misses it" diff --git a/docs/architecture/tendcf-validate-proposal-2026-11-03.md b/docs/architecture/tendcf-validate-proposal-2026-11-03.md index 163a2f0..9257e42 100644 --- a/docs/architecture/tendcf-validate-proposal-2026-11-03.md +++ b/docs/architecture/tendcf-validate-proposal-2026-11-03.md @@ -1148,9 +1148,11 @@ cannot differ on a consistent file; a `vars` value that is not an object is refused when it reads back differently: the loader installs a scalar as a string, which `storejson()` cannot read, and a list of numbers as an slist of strings, while a list of strings reads back equal and is accepted.) It -also refuses any top-level key of the file other than `vars` (the fork's -loader also applies `variables`, loaded after `vars`, and `classes`, which can -define `interlock_ok_*`; the projector emits neither, N-2), any `vars` key that +also refuses any top-level key of the file other than `vars` (the loader also +applies `variables`, loaded after `vars` (the fork at the pin refuses a file +in which `variables` names a variable `vars` already names; upstream replaces +it), and `classes`, which can define `interlock_ok_*`; the projector emits +neither, N-2), any `vars` key that is not a plain identifier `[A-Za-z0-9_]+` (the loader reads a key as a variable reference, `GetCMDBVariableRef`, so `default:tendcf_services.service_ids` presets a variable of the policy's own bundles), a loaded `data:variables.*` diff --git a/policy/tendcf_services.cf b/policy/tendcf_services.cf index 38e8047..7fa72d8 100644 --- a/policy/tendcf_services.cf +++ b/policy/tendcf_services.cf @@ -74,8 +74,9 @@ # does not, and for a gap in either. The check does not model WHY an entry was # dropped. It reads the file itself and compares it with what the loader installed: # - the file's top-level keys must be exactly `vars`. The loader also applies -# a `variables` section (loaded AFTER `vars`, replacing a same-named -# variable) and a `classes` section (which can define `interlock_ok_*`); +# a `variables` section (after `vars`; upstream CFEngine lets it replace a +# same-named variable, the fork at the pin refuses a file that names one +# variable twice) and a `classes` section (which can define `interlock_ok_*`); # the projector emits neither (N-2, bin/projector.py check_projection), so # any other top-level key is refused rather than compared; # - every key under `vars` must be a plain identifier ([A-Za-z0-9_]+). The @@ -94,7 +95,8 @@ # a scalar as a string (storejson() fails) and a list of primitives as an # slist of strings (numbers read back as strings; a list of strings reads # back equal and is accepted). Equal ids with changed values, as a -# `variables` entry would give, are caught. A comparison that cannot be +# loader that replaced a container (upstream's `variables` section) would +# give, are caught. A comparison that cannot be # computed is a problem of its own (`..._problem_uncomparable_`, or # `..._problem_noverdict_` when both texts exist but neither equality # nor a difference could be evaluated), not the absence of a difference; diff --git a/tests/policy/run.sh b/tests/policy/run.sh index ee57ee5..9d1c10c 100755 --- a/tests/policy/run.sh +++ b/tests/policy/run.sh @@ -66,8 +66,10 @@ # actuates nothing; the consistent files of checks 2-4 raise no report; no # file at all, and a file with no vars, are the normal empty case. Also # refused and reported, each actuating nothing: a `variables` section that -# replaces a container under the same ids with another command (the -# comparison is of the whole container, not of key names and ids), a +# names a container of `vars` again (the fork at the pin refuses the file +# as a duplicate variable and installs none of it; the whole-container +# comparison that would catch the same ids with another command is tested +# in checks 10 and 11), a # `classes` section, and a `vars` key that is not a plain identifier, which # the loader would file under another scope (a preset of the policy's own # id lists), and a `vars` value that is not an object (not comparable as @@ -659,18 +661,28 @@ for f in noshell-or noshell-semi argv-alphabet argv-meta relative sysd1 sysd2 sy check "consistent file of the $f run: no cross-check report" no_crosscheck "$work/$f.out" done -# A `variables` section replaces `vars.tendcf_interlock` under the same id with -# a pre_action that passes (the file's own vars say /usr/bin/false). The loader -# applies `variables` after `vars` (cmdb.c LoadCMDBData), so the ids match and -# only the content differs. +# A `variables` section naming `tendcf_interlock` again, with a pre_action that +# passes (the file's own vars say /usr/bin/false). The fork at the pin refuses the +# whole file: two entries naming one variable are a duplicate (cmdb.c +# CMDBPendingCheckNoDuplicates, fork commit 61065e551), so the loader logs the +# duplicate, installs none of the file and the policy sees every `vars` key +# missing. (A loader that applied `variables` after `vars` and replaced the +# container, as upstream CFEngine does, would leave the same ids with another +# command; that content difference is the cross-check's whole-container +# comparison, tested in check 10 against the stand-in loader, "service|interlock +# value changed under the same id", and in check 11 against a replaced file.) cp "$repo/tests/policy/fixtures/cmdb-variables-collision.json" "$work/data/host_specific.json" out="$work/xc-collision.out" "$cf_agent" -K -I -f "$work/inputs/entry.cf" >"$out" 2>&1 || true check "variables-section collision: refusal reported" refusal_reported "$out" -check "variables-section collision: the content difference is named" \ - grep -q "key 'tendcf_interlock' content differs between" "$out" -check "variables-section collision: not an id difference" \ - bash -c "! grep -q 'loaded differently' '$out'" +check "variables-section collision: the loader refuses the duplicate variable" \ + grep -q "Invalid variable specification in CMDB data: 'tendcf_interlock' names the variable 'data:variables.tendcf_interlock' that another entry names too" "$out" +check "variables-section collision: the loader installs none of the file" \ + grep -q "installing none of its contents" "$out" +check "variables-section collision: tendcf_interlock is reported not installed" \ + key_not_loaded "$out" tendcf_interlock +check "variables-section collision: nothing was loaded to differ in content" \ + bash -c "! grep -q 'content differs' '$out'" check "variables-section collision: the section is named" \ grep -q "has top-level section 'variables' besides 'vars'" "$out" check "variables-section collision: refusal reported once" refusal_once "$out" From 7d43372027ce718e1936a845000b2ca4b2552adc Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 14 Nov 2026 16:28:57 -0500 Subject: [PATCH 10/15] Pin the fork at 6505f488a (strict CMDB parse, class insertion fails closed); log core and libntech shas in the build; CI requires the fork loader Co-Authored-By: Claude Sonnet 5.5 --- .github/actions/build-fork/action.yml | 4 ++++ .github/workflows/linux.yml | 2 ++ AGENTS.md | 10 +++++++++- overlay/fork.json | 2 +- overlay/overlay.json | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/actions/build-fork/action.yml b/.github/actions/build-fork/action.yml index 2cedf93..cf069d4 100644 --- a/.github/actions/build-fork/action.yml +++ b/.github/actions/build-fork/action.yml @@ -38,6 +38,10 @@ runs: git -C /tmp/core/libntech checkout -q FETCH_HEAD echo "core=$core" >> "$GITHUB_OUTPUT" echo "libntech=$libntech" >> "$GITHUB_OUTPUT" + # In the job log, not only the summary: the libntech commit core's + # submodule pointer names exists on the fork, not on the upstream URL + # in .gitmodules, and is fetched from `libntech.repo` above. + echo "build-fork: core $core, libntech $libntech (from $libntech_repo)" - name: Build dependencies (core's own script; Debian/Ubuntu branch) shell: bash diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 7c7139d..df32dde 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -42,6 +42,7 @@ jobs: - name: Generic-bundle tests (systemd lifecycle in enforce mode) env: TENDCF_TEST_SYSTEMD: "1" + TENDCF_REQUIRE_FORK_LOADER: "1" run: tests/policy/run.sh --bindir /opt/tendcf/bin # Schema v5 S1 (schema-v5-dpkg-reconciliation-2026-11-02.md section 6): # the read-only unit classifier against the real manager and real @@ -92,6 +93,7 @@ jobs: - name: Generic-bundle tests (plus the NixOS-shape refusal) env: TENDCF_TEST_NIXOS_SHAPE: "1" + TENDCF_REQUIRE_FORK_LOADER: "1" run: tests/policy/run.sh --bindir /opt/tendcf/bin # librsync (and its libb2) is a build-time pick of core's configure # and not part of a minimal Debian; pastebin lacked it (2026-10-29). diff --git a/AGENTS.md b/AGENTS.md index c6ab9a2..0188a9a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -242,7 +242,15 @@ a book: `site-private/AGENTS.md` ("Book knowledge base"). - `tests/policy/run.sh --bindir DIR` runs the generic bundle against a real `cf-agent`/`cf-promises` (Mac dev build: `~/opt/cfengine-dev/bin`); it is - platform-independent and is the test CI runs on Linux. Run it through + the test CI runs on Linux. The policy-layer assertions (the cross-check's + refusal, no actuation) run against any `cf-agent`. The assertions about the + CMDB loader itself (its log strings, "this container was not installed") + hold only for the pinned fork's all-or-nothing loader: a probe in check 4b + decides once, and on any other build (the Mac dev build today) those + assertions print `SKIP (loader not all-or-nothing): `, never pass + silently. The Linux CI legs set `TENDCF_REQUIRE_FORK_LOADER=1`, which makes + a skip a failure. Whether the Mac dev build stays a test target is an open + operator question. Run it through `~/ops/site-private/bin/bg`. Two checks are opt-in because they reshape the host and need root: `TENDCF_TEST_SYSTEMD=1` (check 6, the real-systemd lifecycle; the ubuntu VM jobs) and `TENDCF_TEST_NIXOS_SHAPE=1` (check 7, diff --git a/overlay/fork.json b/overlay/fork.json index 7551567..d96ed95 100644 --- a/overlay/fork.json +++ b/overlay/fork.json @@ -3,7 +3,7 @@ "core": { "repo": "https://github.com/djbclark/core", "branch": "tendcf-integration", - "commit": "d32cade138cad76ebd9ac8ab7757a29a6afe59e4" + "commit": "6505f488a80ab3e18b089c7d8e32571c88128866" }, "libntech": { "repo": "https://github.com/djbclark/libntech" diff --git a/overlay/overlay.json b/overlay/overlay.json index 949e2d7..cabea8d 100644 --- a/overlay/overlay.json +++ b/overlay/overlay.json @@ -32,7 +32,7 @@ "retire_when": "an upstream commit carries the same change (`bin/overlay.py retired` says RETIRE), or the code it protects is no longer shipped", "role": "load-bearing", "subject": "Fixed one bad CMDB entry discarding every entry in its section", - "superseded_on_fork": "2026-11-02, operator ruling R13 (PR #41): the fork's tendcf-integration branch, which overlay/fork.json pins, replaces this patch's per-entry skip with an all-or-nothing loader (branch cmdb-fail-closed: a750b1dfe, dbf9dede6, 61065e551, 736becc07; merged d32cade13). A skipped interlock entry leaves the services it guards unguarded. This entry still describes, and apply reproduces, commit 8f0076b81 exactly, so upstream plus the overlay skips a bad entry and does NOT behave like the pinned fork. Keeping, retiring or replacing it is a separate ruling because it changes what the overlay reproduces (upstream-overlay.md section 7).", + "superseded_on_fork": "2026-11-02, operator ruling R13 (PR #41): the fork's tendcf-integration branch, which overlay/fork.json pins, replaces this patch's per-entry skip with an all-or-nothing loader (branch cmdb-fail-closed: a750b1dfe, dbf9dede6, 61065e551, 736becc07; merged d32cade13, hardened by djbclark/core PR #98 and a strict libntech parse, pin 6505f488a). A skipped interlock entry leaves the services it guards unguarded. This entry still describes, and apply reproduces, commit 8f0076b81 exactly, so upstream plus the overlay skips a bad entry and does NOT behave like the pinned fork. Keeping, retiring or replacing it is a separate ruling because it changes what the overlay reproduces (upstream-overlay.md section 7).", "upstream_pr": "https://github.com/cfengine/core/pull/6320", "upstream_pr_state": "closed unmerged 2026-08-19" } From c2a1131e1389073439682ffa8c111797f42893c2 Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 14 Nov 2026 16:28:57 -0500 Subject: [PATCH 11/15] run.sh: capability-gate fork-only assertions (SKIP, never silent; CI requires the fork loader); policy-level refusal in 4b; strict-parse and class cases 9b; fuller failure dump Co-Authored-By: Claude Sonnet 5.5 --- .../policy/fixtures/loader-class-exists.json | 1 + tests/policy/fixtures/loader-class-space.json | 1 + tests/policy/fixtures/loader-dup-member.json | 1 + tests/policy/fixtures/loader-dup-vars.json | 1 + tests/policy/fixtures/loader-trailing.json | 2 + tests/policy/run.sh | 210 +++++++++++++++--- tests/policy/sim-loader.cf | 5 +- 7 files changed, 193 insertions(+), 28 deletions(-) create mode 100644 tests/policy/fixtures/loader-class-exists.json create mode 100644 tests/policy/fixtures/loader-class-space.json create mode 100644 tests/policy/fixtures/loader-dup-member.json create mode 100644 tests/policy/fixtures/loader-dup-vars.json create mode 100644 tests/policy/fixtures/loader-trailing.json diff --git a/tests/policy/fixtures/loader-class-exists.json b/tests/policy/fixtures/loader-class-exists.json new file mode 100644 index 0000000..df3940e --- /dev/null +++ b/tests/policy/fixtures/loader-class-exists.json @@ -0,0 +1 @@ +{"vars":{"tendcf_interlock":{"demo-check":{"blocks":"enclosing-bundle","bundle":"demo","defines_class":"demo_ok","pre_action":{"command":["/usr/bin/false"],"expect_exit":0,"timeout_seconds":5},"report":true,"state":"present"}},"tendcf_service":{"demo-runit":{"bundle":"demo","command":["/bin/sleep","1"],"run_as":"nobody","state":"present","unit":{"runit":{"enabled":true}},"working_dir":"/"}}},"classes":{"default:linux":"any::"}} diff --git a/tests/policy/fixtures/loader-class-space.json b/tests/policy/fixtures/loader-class-space.json new file mode 100644 index 0000000..b3596c9 --- /dev/null +++ b/tests/policy/fixtures/loader-class-space.json @@ -0,0 +1 @@ +{"vars":{"tendcf_interlock":{"demo-check":{"blocks":"enclosing-bundle","bundle":"demo","defines_class":"demo_ok","pre_action":{"command":["/usr/bin/false"],"expect_exit":0,"timeout_seconds":5},"report":true,"state":"present"}},"tendcf_service":{"demo-runit":{"bundle":"demo","command":["/bin/sleep","1"],"run_as":"nobody","state":"present","unit":{"runit":{"enabled":true}},"working_dir":"/"}}},"classes":{"default: ":"any::"}} diff --git a/tests/policy/fixtures/loader-dup-member.json b/tests/policy/fixtures/loader-dup-member.json new file mode 100644 index 0000000..761bc84 --- /dev/null +++ b/tests/policy/fixtures/loader-dup-member.json @@ -0,0 +1 @@ +{"vars":{"tendcf_interlock":null,"tendcf_interlock":{"demo-check":{"blocks":"enclosing-bundle","bundle":"demo","defines_class":"demo_ok","pre_action":{"command":["/usr/bin/false"],"expect_exit":0,"timeout_seconds":5},"report":true,"state":"present"}},"tendcf_service":{"demo-runit":{"bundle":"demo","command":["/bin/sleep","1"],"run_as":"nobody","state":"present","unit":{"runit":{"enabled":true}},"working_dir":"/"}}}} diff --git a/tests/policy/fixtures/loader-dup-vars.json b/tests/policy/fixtures/loader-dup-vars.json new file mode 100644 index 0000000..588c1fb --- /dev/null +++ b/tests/policy/fixtures/loader-dup-vars.json @@ -0,0 +1 @@ +{"vars":{"tendcf_interlock":{"demo-check":{"blocks":"enclosing-bundle","bundle":"demo","defines_class":"demo_ok","pre_action":{"command":["/usr/bin/false"],"expect_exit":0,"timeout_seconds":5},"report":true,"state":"present"}},"tendcf_service":{"demo-runit":{"bundle":"demo","command":["/bin/sleep","1"],"run_as":"nobody","state":"present","unit":{"runit":{"enabled":true}},"working_dir":"/"}}},"vars":{"tendcf_service":{"demo-runit":{"bundle":"demo","command":["/bin/sleep","1"],"run_as":"nobody","state":"present","unit":{"runit":{"enabled":true}},"working_dir":"/"}}}} diff --git a/tests/policy/fixtures/loader-trailing.json b/tests/policy/fixtures/loader-trailing.json new file mode 100644 index 0000000..6e83efb --- /dev/null +++ b/tests/policy/fixtures/loader-trailing.json @@ -0,0 +1,2 @@ +{"vars":{"tendcf_interlock":{"demo-check":{"blocks":"enclosing-bundle","bundle":"demo","defines_class":"demo_ok","pre_action":{"command":["/usr/bin/false"],"expect_exit":0,"timeout_seconds":5},"report":true,"state":"present"}},"tendcf_service":{"demo-runit":{"bundle":"demo","command":["/bin/sleep","1"],"run_as":"nobody","state":"present","unit":{"runit":{"enabled":true}},"working_dir":"/"}}}} +not json after the document diff --git a/tests/policy/run.sh b/tests/policy/run.sh index 9d1c10c..3163c8b 100755 --- a/tests/policy/run.sh +++ b/tests/policy/run.sh @@ -1,9 +1,18 @@ #!/usr/bin/env bash # Generic-bundle tests for policy/tendcf_services.cf against a real cf-agent. # -# Platform-independent on purpose: nothing here touches launchd or -# /Library/LaunchDaemons, so the same run passes on a Linux CI runner and on -# the Mac dev build. Three checks: +# Nothing here touches launchd or /Library/LaunchDaemons. Most assertions are +# policy-layer and hold on any cf-agent (a Linux CI runner, the Mac dev build). +# The ones about the CMDB loader's own behaviour (its log strings, the +# duplicate-variable message, "this container was not installed") hold only for +# the pinned fork's all-or-nothing loader (overlay/fork.json). They go through +# fork_only(): a one-time capability probe in check 4b (a file with a repeated +# member of `vars`) decides whether the loader is the fork's, and on any other +# build each such assertion prints `SKIP (loader not all-or-nothing): `, +# never a silent pass, and the run ends with a count of skips. The Linux CI legs +# set TENDCF_REQUIRE_FORK_LOADER=1, which turns a non-fork loader (so, any skip) +# into a failure. Whether the Mac dev build stays a target is an open operator +# question; both states are honest here. Checks: # # 1. wiring: cf-promises parses the bundle with the example projection # (examples/host_specific.json) installed as CMDB data, so every @@ -30,11 +39,15 @@ # malformed entry (an unresolved variable reference in the interlock; # then a key 'tendcf_interlock[' that the variable parser reads as the # interlock container) beside a valid interlock and a present service. -# The fork's CMDB loader is all-or-nothing, so the file installs nothing: -# no service is processed, no interlock runs, and a probe policy finds -# neither data:variables.tendcf_interlock nor ...tendcf_service. A -# loader that skipped only the bad entry would let the service through -# unguarded. +# The policy layer must refuse and report it (refusal_reported, +# refusal_once) and actuate nothing on any loader. On the pinned fork's +# all-or-nothing loader the file also installs nothing (loader log +# strings; a probe policy finds neither data:variables.tendcf_interlock +# nor ...tendcf_service): those assertions are fork_only. A loader that +# skipped only the bad entry would let the service through unguarded, +# which the policy-layer assertions would catch. +# The same block holds the capability probe (fork_loader) and the +# TENDCF_REQUIRE_FORK_LOADER=1 assertion. # 5. host guard, enforce mode, non-Darwin only: a satisfied interlock and # two present launchd services. launchd exists only on darwin, so a # Linux host must refuse both, write nothing under /Library and run no @@ -83,13 +96,33 @@ # container that is a list of strings is the positive control: accepted, # actuates. A plain-identifier key longer than 64 characters is refused and # its report line shows only the first 64. Every file of checks 2-8 and 6 is also a no-report control. -# NB: the fork at the pin (overlay/fork.json) loads all-or-nothing (PR #41, -# operator ruling R13): a file with any invalid entry installs none of its -# contents, so on the Linux legs this check sees every `vars` key missing, -# as the Mac dev build does when it rejects the whole `vars`. The same -# fixture refuses the same way on both ("nothing loaded"). No loader this -# check runs against skips one entry and installs the rest; the fork did -# before R13 (`8f0076b81`, B-5b), which is the 2026-11-02 fail-open. +# NB: the fork at the pin (overlay/fork.json, core 6505f488a) loads +# all-or-nothing (PR #41, operator ruling R13): a file in which an entry is +# invalid, a class cannot be inserted, a `vars` member or section is +# repeated, or non-whitespace follows the document, installs none of its +# contents (libpromises/cmdb.c, strict libntech parse; the strict parse is +# the CMDB loader's alone, readjson and def.json stay lenient). On the +# Linux legs this check sees every `vars` key missing, as the Mac dev build +# does when it rejects the whole `vars`. The same fixture refuses the same +# way on both ("nothing loaded"). No loader this check runs against skips +# one entry and installs the rest; the fork did before R13 (`8f0076b81`, +# B-5b), which is the 2026-11-02 fail-open. +# 9b. the loader's strict-parse and class refusals, one fixture each in +# tests/policy/fixtures/loader-*.json, each beside a valid interlock and a +# present service: a repeated member of `vars` (dup-member), a repeated +# top-level `vars` whose later section drops the interlock (dup-vars), +# non-whitespace after a valid document (trailing), a whitespace-only +# default-namespace class name (class-space). Each must be refused and +# reported once by PR 42's cross-check and actuate nothing (unconditional); +# on the fork each also loads nothing, logs the loader's reason and +# reports each key as not loaded (fork_only). A class that already exists (class-exists, +# the host's own hard class) is not an error: the fork leaves it as it is +# and installs the rest, so no refusal is expected; the case asserts that +# `classes` beside good vars is still refused by the cross-check's own +# `classes` rule. In dup-vars the lenient readjson sees only the last +# `vars` section, so the report names only what that section holds +# (tendcf_service), not the interlock the loader dropped: the +# cross-check's independence from the loader is limited (proposal 13). # 10. the same cross-check against a loader that skips ONE container, which # neither the Mac dev build nor the pinned fork does: tests/policy/sim-loader.cf # installs data:variables.* in the loader's place (cf-agent @@ -183,6 +216,22 @@ check() { # check NAME COND... if "$@"; then echo "ok $name"; else echo "FAIL $name"; fail=1; fi } +# Assertions that hold only on the pinned fork's CMDB loader (overlay/fork.json: +# all-or-nothing, strict parse): its log strings, and "this container was not +# installed". Policy-layer assertions (the cross-check's refusal, no actuation) +# stay on `check` and run against every loader. fork_loader is set once, by the +# probe in check 4b. A loader that is not the fork's makes fork_only print a +# SKIP line, never pass silently; TENDCF_REQUIRE_FORK_LOADER=1, which the Linux +# CI legs set because they build the pinned fork, turns "not the fork's loader" +# into a failure, so CI cannot pass by skipping. +fork_loader=unknown +skipped=0 +fork_only() { # fork_only NAME COND... + if [ "$fork_loader" = 1 ]; then check "$@"; return 0; fi + echo "SKIP (loader not all-or-nothing): $1" + skipped=$((skipped + 1)) +} + # The cross-check's report. "refusing to actuate anything" is the summary line # tendcf_interlocks prints once; no_actuation is what a refused run must not do: # run any command (-I logs every one, pre_action included), render, or process @@ -249,7 +298,8 @@ echo "# 4b. malformed CMDB entries: the loader fails closed" # the place of another) would let the service through unguarded: the service # would be processed and reported (the runit flavour is refused by name on # every host, check 4). The fork's all-or-nothing CMDB loader installs -# nothing from the file, so no service and no interlock exists to act on. +# nothing from a file it finds invalid (this one is), so no service and no +# interlock exists to act on. # Besides what the agent did, the probe policy asks it directly whether either # container exists, which a service-only or interlock-only leftover cannot hide # from; its positive control is a file that loads. @@ -264,13 +314,33 @@ check "probe control: a file that loads has tendcf_interlock" \ check "probe control: a file that loads has tendcf_service" \ grep -q "cmdb-probe: tendcf_service present" "$work/probe-control.out" +# Loader capability, once: a repeated object member in `vars` must install +# nothing (the fork's strict parse, LoadCMDBData reading with JsonParseFileStrict, +# cmdb.c:1171 at 6505f488a), where a lenient loader keeps the last member and +# installs both containers. Positive evidence only: both "absent" lines. +probe loader-dup-member.json "$work/probe-capability.out" +if grep -q "cmdb-probe: tendcf_interlock absent" "$work/probe-capability.out" && + grep -q "cmdb-probe: tendcf_service absent" "$work/probe-capability.out"; then + fork_loader=1 + echo "# loader capability: all-or-nothing with strict parse (the pinned fork)" +else + fork_loader=0 + echo "# loader capability: NOT the pinned fork's loader; fork-only assertions print SKIP" +fi +if [ "${TENDCF_REQUIRE_FORK_LOADER:-0}" = 1 ]; then + check "TENDCF_REQUIRE_FORK_LOADER=1: the loader is the pinned fork's (no skipping)" \ + test "$fork_loader" = 1 +fi + malformed_case() { # malformed_case NAME FIXTURE ERROR-PATTERN local name="$1" fixture="$2" pattern="$3" out="$work/malformed-$name.out" cp "$repo/tests/policy/fixtures/$fixture" "$work/data/host_specific.json" "$cf_agent" -K -I -f "$work/inputs/entry.cf" >"$out" 2>&1 || true - check "$name: malformed entry named in the CMDB error" grep -q "$pattern" "$out" - check "$name: loader reports that it installed none of the file" \ + check "$name: the policy refuses and reports it" refusal_reported "$out" + check "$name: the policy reports it once" refusal_once "$out" + fork_only "$name: malformed entry named in the CMDB error" grep -q "$pattern" "$out" + fork_only "$name: loader reports that it installed none of the file" \ grep -q "installing none of its contents" "$out" check "$name: no service processed (the sibling service entry was not installed)" \ bash -c "! grep -q \"tendcf: service 'demo-runit'\" '$out'" @@ -281,9 +351,9 @@ malformed_case() { # malformed_case NAME FIXTURE ERROR-PATTERN check "$name: no launchctl or systemctl invocation" \ bash -c "! grep -Eq 'launchctl|systemctl' '$out'" probe "$fixture" "$work/probe-$name.out" - check "$name: no tendcf_interlock variable" \ + fork_only "$name: no tendcf_interlock variable" \ grep -q "cmdb-probe: tendcf_interlock absent" "$work/probe-$name.out" - check "$name: no tendcf_service variable" \ + fork_only "$name: no tendcf_service variable" \ grep -q "cmdb-probe: tendcf_service absent" "$work/probe-$name.out" } # an unresolved variable reference in the interlock's pre_action @@ -625,7 +695,7 @@ check "malformed interlock: the container the loader did not install is named" \ # All-or-nothing: the valid sibling container is not installed either (the # pre-R13 fork installed it, which was the fail-open; the Mac dev build rejects # the whole `vars`, so it agrees). -check "malformed interlock: the sibling tendcf_service is not installed either (all-or-nothing)" \ +fork_only "malformed interlock: the sibling tendcf_service is not installed either (all-or-nothing)" \ key_not_loaded "$out" tendcf_service check "malformed interlock: refusal reported once" refusal_once "$out" check "malformed interlock: nothing actuated, no pre_action run, no service processed" \ @@ -675,13 +745,13 @@ cp "$repo/tests/policy/fixtures/cmdb-variables-collision.json" "$work/data/host_ out="$work/xc-collision.out" "$cf_agent" -K -I -f "$work/inputs/entry.cf" >"$out" 2>&1 || true check "variables-section collision: refusal reported" refusal_reported "$out" -check "variables-section collision: the loader refuses the duplicate variable" \ +fork_only "variables-section collision: the loader refuses the duplicate variable" \ grep -q "Invalid variable specification in CMDB data: 'tendcf_interlock' names the variable 'data:variables.tendcf_interlock' that another entry names too" "$out" -check "variables-section collision: the loader installs none of the file" \ +fork_only "variables-section collision: the loader installs none of the file" \ grep -q "installing none of its contents" "$out" -check "variables-section collision: tendcf_interlock is reported not installed" \ +fork_only "variables-section collision: tendcf_interlock is reported not installed" \ key_not_loaded "$out" tendcf_interlock -check "variables-section collision: nothing was loaded to differ in content" \ +fork_only "variables-section collision: nothing was loaded to differ in content" \ bash -c "! grep -q 'content differs' '$out'" check "variables-section collision: the section is named" \ grep -q "has top-level section 'variables' besides 'vars'" "$out" @@ -795,6 +865,87 @@ check "list of strings in vars: no cross-check report" no_crosscheck "$out" check "list of strings in vars: actuates normally (the pre_action ran)" \ grep -q "Executing .*'/usr/bin/true'" "$out" +echo "# 9b. the real loader's strict parse and class handling (fork 6505f488a), policy level" +# What the pinned loader does with each file is read from libpromises/cmdb.c at +# 6505f488a (line numbers there), and each case asserts it. Whatever it does, the +# cross-check refuses and nothing actuates: those assertions are unconditional. +# Where the loader refuses the file, `key_not_loaded` reports each key of the +# file the cross-check could read: it reads with readjson, which stays lenient, +# so after a repeated member or a repeated `vars` section it sees the LAST one +# only, and an earlier container (here the interlock of case b) is not named. +# That is the limit of the cross-check's independence from the loader's parser. +strict_case() { # strict_case NAME FIXTURE LOADER-ERROR-PATTERN INSTALL-NONE KEY... + local name="$1" fixture="$2" pattern="$3" none="$4"; shift 4 + out="$work/strict-$name.out" + cp "$repo/tests/policy/fixtures/$fixture" "$work/data/host_specific.json" + "$cf_agent" -K -I -f "$work/inputs/entry.cf" >"$out" 2>&1 || true + check "$name: the policy refuses and reports it" refusal_reported "$out" + check "$name: the policy reports it once" refusal_once "$out" + fork_only "$name: the loader refuses the file" grep -q "$pattern" "$out" + if [ "$none" = yes ]; then + fork_only "$name: the loader installs none of the file" \ + grep -q "installing none of its contents" "$out" + fi + local k + for k in "$@"; do + fork_only "$name: $k reported not installed" key_not_loaded "$out" "$k" + done + check "$name: nothing actuated (no service, no interlock, no render)" no_actuation "$out" + probe "$fixture" "$work/probe-strict-$name.out" + fork_only "$name: no tendcf_interlock variable" \ + grep -q "cmdb-probe: tendcf_interlock absent" "$work/probe-strict-$name.out" + fork_only "$name: no tendcf_service variable" \ + grep -q "cmdb-probe: tendcf_service absent" "$work/probe-strict-$name.out" +} +dup_member="Could not parse JSON file .*host_specific\\.json: Unwilling to parse json data with a duplicate object member" +# (a) a repeated member: an invalid earlier value (null), then a valid interlock. +# The lenient parser keeps the last (valid) one; the strict parse the loader reads +# with (cmdb.c:59-84 ReadJsonFileMode, :1171-1177) refuses the file before any +# validation, so the first value is no longer discarded unseen. +strict_case dup-member loader-dup-member.json "$dup_member" no tendcf_interlock tendcf_service +# (b) `vars` twice at the top level, the later one without the interlock +strict_case dup-vars loader-dup-vars.json "$dup_member" no tendcf_service +# (c) a complete valid document, then more input (the lenient parser stops after +# the first document and ignores the rest) +strict_case trailing loader-trailing.json \ + "Could not parse JSON file .*host_specific\\.json: Unwilling to parse json data with trailing non-whitespace characters" \ + no tendcf_interlock tendcf_service +# (d) a default-namespace class whose name is whitespace only: refused in +# validation (CheckCMDBClassName, cmdb.c:776-), so nothing is installed, where it +# used to reach insertion, fail, and be taken for "a class that exists already" +strict_case class-space loader-class-space.json \ + "Invalid CMDB class 'default: ': the class name starts or ends with whitespace" yes \ + tendcf_interlock tendcf_service +check "class-space: the classes section is named by the policy" \ + grep -q "has top-level section 'classes' besides 'vars'" "$out" + +# (e) a class that exists already, beside good vars. The loader leaves it as it +# is and goes on (InstallCMDBPending, cmdb.c:1095-1102: CMDBClassExists by +# canonical identity, logged at VERBOSE only), so both containers are installed; +# the policy refuses all the same, for the `classes` section. `linux` is a hard +# class on the Linux legs (`darwin` on a Mac), set before the loader runs +# (generic_agent.c:1234); a CMDB class of a name that is taken is not installed, +# so it is not reported as a class the CMDB defined. +hardclass=linux +[ "$(uname)" = Darwin ] && hardclass=darwin +exists_json=$(cat "$repo/tests/policy/fixtures/loader-class-exists.json") +printf '%s\n' "${exists_json//default:linux/default:$hardclass}" >"$work/data/host_specific.json" +out="$work/strict-class-exists.out" +"$cf_agent" -K -I -f "$work/inputs/entry.cf" >"$out" 2>&1 || true +check "class-exists: the policy refuses and reports it" refusal_reported "$out" +check "class-exists: the policy reports it once" refusal_once "$out" +check "class-exists: the classes section is named by the policy" \ + grep -q "has top-level section 'classes' besides 'vars'" "$out" +check "class-exists: nothing actuated" no_actuation "$out" +fork_only "class-exists: the loader did not fail on the existing class" \ + bash -c "! grep -q 'Failed to add CMDB class' '$out'" +fork_only "class-exists: the loader did not refuse the rest of the file" \ + bash -c "! grep -q 'installing none of its contents' '$out'" +fork_only "class-exists: the good variables were installed" \ + bash -c "! grep -q 'but CFEngine did not load' '$out'" +fork_only "class-exists: the existing class was not redefined by the CMDB" \ + bash -c "! grep -q 'defined a class' '$out'" + echo "# 10. CMDB cross-check, a loader that skips one container (tests/policy/sim-loader.cf)" sim_run() { # sim_run FIXTURE|none CLASSES OUT if [ "$1" = none ]; then rm -f "$work/data/host_specific.json" @@ -964,6 +1115,9 @@ check "probe no verdict: nothing ran (neither the loaded nor the replaced pre_ac if [ "$fail" != 0 ]; then for f in refused satisfied noshell-or noshell-semi argv-alphabet argv-meta relative flavour host sysd-host sysd-host-tomb sysd1 sysd2 sysd3 sysd4 sysd5 sysd6 nixos-shape nixos-tombstone \ xc-malformed xc-nofile xc-novars xc-garbage xc-collision xc-classes xc-preset xc-preset-vars xc-uncomparable xc-checker-preset xc-checker-preset-keys xc-classes-hidden xc-augments xc-strlist xc-probe-before xc-probe-after xc-probe-noverdict xc-longkey \ + malformed-unresolved malformed-index-key probe-control probe-capability probe-unresolved probe-index-key \ + strict-dup-member strict-dup-vars strict-trailing strict-class-space strict-class-exists \ + probe-strict-dup-member probe-strict-dup-vars probe-strict-trailing probe-strict-class-space \ xc-sim-control xc-sim-nointerlock xc-sim-noservice xc-sim-partial xc-sim-stray xc-sim-nofile xc-sim-changed-service xc-sim-changed-interlock \ sysd-sim-present sysd-sim-tomb; do [ -f "$work/$f.out" ] || continue @@ -971,4 +1125,8 @@ if [ "$fail" != 0 ]; then done exit 1 fi -echo; echo "all policy tests passed" +echo +if [ "$skipped" != 0 ]; then + echo "NOTE: $skipped assertion(s) skipped (loader not all-or-nothing); see the SKIP lines" +fi +echo "all policy tests passed" diff --git a/tests/policy/sim-loader.cf b/tests/policy/sim-loader.cf index d816a17..273dd08 100644 --- a/tests/policy/sim-loader.cf +++ b/tests/policy/sim-loader.cf @@ -1,8 +1,9 @@ # Test only (tests/policy/run.sh checks 9-10). Stands in for a CMDB loader that # skipped, or half installed, a container of host_specific.json. No loader the # tests run does that: the fork at the pin (overlay/fork.json) is all-or-nothing -# (a file with any invalid entry installs nothing, since PR #41, operator ruling -# R13) and the Mac dev build rejects the whole `vars`. The fork before R13 +# (a file it finds invalid, by the reasons listed in policy/tendcf_services.cf +# tendcf_cmdb, installs nothing, since PR #41, operator ruling R13) and the Mac +# dev build rejects the whole `vars`. The fork before R13 # (`8f0076b81`, B-5b) did skip one bad entry, which was the 2026-11-02 # fail-open; this stand-in keeps that state testable, and the cross-check # must refuse it however a loader came to leave it. Run From c2e372d2e70201d0fe9b1c1519b0396224d79f3c Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 14 Nov 2026 16:28:57 -0500 Subject: [PATCH 12/15] projector: E-6/E-7 note distinguishes upstream CFEngine from the pinned fork Co-Authored-By: Claude Sonnet 5.5 --- bin/projector.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/projector.py b/bin/projector.py index 8700cb9..67b69ea 100755 --- a/bin/projector.py +++ b/bin/projector.py @@ -413,8 +413,11 @@ def flag(rule: str, msg: str) -> None: # overlay/fork.json instead refuses a file in which `variables` # names a variable `vars` already names; upstream replaces it.) extra = ( - " — legal to CFEngine, loaded after `vars` and overwriting the " - "same names, which is why envelope-shape checking misses it" + " — legal to upstream CFEngine, which loads it after `vars` and " + "lets it overwrite the same names, which is why envelope-shape " + "checking misses it; the fork pinned in overlay/fork.json " + "instead refuses a file in which `variables` or `classes` is " + "invalid or names a variable `vars` already names" ) flag( RULE_PROJECTION, From d90c78a287add18fe73d581c4ed4f49a0e78378b Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 14 Nov 2026 16:28:57 -0500 Subject: [PATCH 13/15] Docs and policy comments: qualify the all-or-nothing claims against the 6505f488a source; strict parse is the CMDB loader's alone Co-Authored-By: Claude Sonnet 5.5 --- .../tendcf-validate-proposal-2026-11-03.md | 18 +++++++++++++----- docs/architecture/upstream-register.md | 19 +++++++++++++------ policy/tendcf_services.cf | 19 +++++++++++++------ 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/docs/architecture/tendcf-validate-proposal-2026-11-03.md b/docs/architecture/tendcf-validate-proposal-2026-11-03.md index 9257e42..d8933ff 100644 --- a/docs/architecture/tendcf-validate-proposal-2026-11-03.md +++ b/docs/architecture/tendcf-validate-proposal-2026-11-03.md @@ -983,8 +983,9 @@ that hold the stale text, per its brief. a function of. 5. **Map §12 item 1** ("deleting or withholding the projection is not a demonstrated fail-closed launch protocol") is right, and fact 2 - strengthens it: on the pinned fork, a *malformed* projection is not - even all-or-nothing. + strengthens it: on the fork pinned when this was written (`b8abf28408b1`), + a *malformed* projection was not even all-or-nothing (the pin has since + moved to the fail-closed loader, §13). 6. **`deploy/linux/tendcf-install.sh` `put_data`** is not atomic against a concurrent cf-agent (fact 8). This matters once a scheduler runs, which stage B enables. @@ -1220,9 +1221,16 @@ order within the one pass. `bundlesequence` guard classes in `promises.cf` are not needed for this check. This is a consistency check, not a sandbox: a CMDB author (root) already chooses each pre_action executable, `/bin/sh` included, and the unit commands, so it does not stop a hostile but self-consistent file. -The fork-side all-or-nothing loader (PR #41) and this check are independent: -with the loader failing closed, the file's keys are not loaded and the check -refuses and reports it, which is correct and louder. +The fork-side all-or-nothing loader (PR #41) and this check hold each without +the other: with the loader failing closed, the file's keys are not loaded and +the check refuses and reports it, which is correct and louder. The independence +is limited, not complete: the loader's strict parse (a repeated member or +trailing input refuses the file; fork `6505f488a`) belongs to the CMDB loader +only, while this check's `readjson` stays lenient and sees the last of a +repeated member or `vars` section, so an earlier container the loader refused +is not named by the check (it still refuses, as nothing the file lists was +loaded). The check does not detect such a file when the loader is lenient and +the repeated member is invisible to both parsers. Two findings from the implementation, both about the proof above. (1) The Mac dev build (`3.29.0a.086d27749`) does not carry the per-entry loader diff --git a/docs/architecture/upstream-register.md b/docs/architecture/upstream-register.md index 1eaec7e..7bbb7ad 100644 --- a/docs/architecture/upstream-register.md +++ b/docs/architecture/upstream-register.md @@ -348,12 +348,19 @@ investigation trail behind P-1/P-2 and is not itself a defect. `8f0076b81` made the CMDB loader skip one bad entry and install the rest. For tendcf that is fail-open: an interlock entry dropped at load leaves the services it guards actuated unguarded. `tendcf-integration` now carries -`cmdb-fail-closed` (`a750b1dfe`, `dbf9dede6`, `61065e551`, `736becc07`; merged `d32cade13`): -`LoadCMDBData()` validates every entry of `vars`/`variables`/`classes` first -and installs nothing from `host_specific.json` if any one is invalid (also an -unknown top-level key, a null section, a key with index brackets, a -frame-dependent special scope, two entries naming one variable), logging each -by name and returning false; the agent then runs with no CMDB variables. +`cmdb-fail-closed` (`a750b1dfe`, `dbf9dede6`, `61065e551`, `736becc07`, merged +`d32cade13`; hardened by djbclark/core PR #98 and a strict libntech JSON parse, +the pin now `6505f488a`): `LoadCMDBData()` validates every entry of +`vars`/`variables`/`classes` first and installs nothing from +`host_specific.json` if any one is invalid (also an unknown top-level key, a +null section, a key with index brackets, a frame-dependent special scope, two +entries naming one variable, a variable that exists already, a class name with +whitespace at either end), logging each by name and returning false; the agent +then runs with no CMDB variables. It reads the file with a strict parse +(`JsonParseFileStrict`, libntech `cc892efae`): a repeated object member and +anything but whitespace after the document refuse the file before validation. +A class that exists already is left as it is and the rest is installed. Strict +parsing is the CMDB loader's alone: `readjson` and `def.json` stay lenient. Upstream PRs #6315/#6320 stay closed unmerged. The overlay manifest's B-5b entry (`overlay/overlay.json`) still describes and reproduces `8f0076b81`, not this behaviour; it now carries diff --git a/policy/tendcf_services.cf b/policy/tendcf_services.cf index 7fa72d8..b449211 100644 --- a/policy/tendcf_services.cf +++ b/policy/tendcf_services.cf @@ -68,10 +68,17 @@ # every service ungated (services are gated negatively, on # `!interlock_blocked_*`, and that class only exists for an interlock that # loaded). The fork at the pin (overlay/fork.json, PR #41, operator ruling R13) -# loads all-or-nothing instead: any invalid entry and it installs none of the -# file, so this check then sees every `vars` key missing and refuses. The two -# are independent: the check holds for a loader that fails closed, for one that -# does not, and for a gap in either. The check does not model WHY an entry was +# loads all-or-nothing instead: an invalid entry, a repeated object member +# anywhere, anything after the document, a class name with whitespace at either +# end, a variable that exists already, and it installs none of the file, so this +# check then sees every `vars` key missing and refuses. That strict parse is the +# CMDB loader's only: `readjson`, which this check reads the file with, and +# def.json stay lenient, so after a repeated member or a repeated `vars` section +# the check sees the LAST one only (an earlier container is not named). It still +# refuses, because the loader installed nothing the file lists. The two are not +# fully independent for that reason, and each holds for a loader that fails +# closed, for one that does not, and for a gap in either, to the extent the +# other does not share the gap. The check does not model WHY an entry was # dropped. It reads the file itself and compares it with what the loader installed: # - the file's top-level keys must be exactly `vars`. The loader also applies # a `variables` section (after `vars`; upstream CFEngine lets it replace a @@ -141,8 +148,8 @@ # `default:tendcf_cmdb.doc` or `default:tendcf_services.interlock_ids` presets # that variable before any policy runs. What a preset does then depends on the # promise (verify_vars.c VerifyVarPromise, read at commit b8abf28408b1; the -# pin in overlay/fork.json is now d32cade13, which differs from it only in -# libpromises/cmdb.c, cmdb.h and tests): a promise with a LITERAL rvalue (`slist => { }`) always +# pin in overlay/fork.json is now 6505f488a, which differs from it only in +# libpromises/cmdb.c, cmdb.h, tests and the libntech submodule pointer): a promise with a LITERAL rvalue (`slist => { }`) always # redefines it, so the policy's value stands. A promise whose rvalue is a # FUNCTION CALL is skipped when the variable exists ("Already did this") if the # call was not already evaluated to a value when the promise runs, and From fd13eb3a7b12c97785a0d6b0f4f2923dd4aa5920 Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 14 Nov 2026 16:56:55 -0500 Subject: [PATCH 14/15] run.sh: gate the strict-parse integration assertions (repeated member, repeated vars, trailing input) as fork_only; empty-view controls; header and AGENTS.md say which assertions are integration and what a non-fork run does Co-Authored-By: Claude Sonnet 5.5 --- AGENTS.md | 22 ++-- .../fixtures/loader-empty-dup-vars.json | 1 + .../fixtures/loader-empty-trailing.json | 2 + tests/policy/run.sh | 111 +++++++++++++----- 4 files changed, 98 insertions(+), 38 deletions(-) create mode 100644 tests/policy/fixtures/loader-empty-dup-vars.json create mode 100644 tests/policy/fixtures/loader-empty-trailing.json diff --git a/AGENTS.md b/AGENTS.md index 0188a9a..7ef43d2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -242,15 +242,19 @@ a book: `site-private/AGENTS.md` ("Book knowledge base"). - `tests/policy/run.sh --bindir DIR` runs the generic bundle against a real `cf-agent`/`cf-promises` (Mac dev build: `~/opt/cfengine-dev/bin`); it is - the test CI runs on Linux. The policy-layer assertions (the cross-check's - refusal, no actuation) run against any `cf-agent`. The assertions about the - CMDB loader itself (its log strings, "this container was not installed") - hold only for the pinned fork's all-or-nothing loader: a probe in check 4b - decides once, and on any other build (the Mac dev build today) those - assertions print `SKIP (loader not all-or-nothing): `, never pass - silently. The Linux CI legs set `TENDCF_REQUIRE_FORK_LOADER=1`, which makes - a skip a failure. Whether the Mac dev build stays a test target is an open - operator question. Run it through + the test CI runs on Linux. Policy-layer assertions that hold on any loader + (most of the file) run against any `cf-agent`. Two kinds hold only with the + pinned fork's all-or-nothing, strict-parse loader: loader assertions (its log + strings, "this container was not installed") and loader+policy integration + assertions (9b: the cross-check's refusal and no actuation for a repeated + member, a repeated `vars`, trailing input; a lenient loader and the lenient + `readjson` see the same surviving data, so there is nothing to refuse). A + probe in check 4b decides once; on any other build each of those prints + `SKIP (loader not all-or-nothing): `, never passes silently, and the + run is expected to pass with SKIP lines and a count (not yet run on the Mac: + derived from the parser behaviour). The Mac dev build stays a target + (operator, 2026-11-14, "keep Mac, SKIPs"). The Linux CI legs set + `TENDCF_REQUIRE_FORK_LOADER=1`, which makes a skip a failure. Run it through `~/ops/site-private/bin/bg`. Two checks are opt-in because they reshape the host and need root: `TENDCF_TEST_SYSTEMD=1` (check 6, the real-systemd lifecycle; the ubuntu VM jobs) and `TENDCF_TEST_NIXOS_SHAPE=1` (check 7, diff --git a/tests/policy/fixtures/loader-empty-dup-vars.json b/tests/policy/fixtures/loader-empty-dup-vars.json new file mode 100644 index 0000000..a249200 --- /dev/null +++ b/tests/policy/fixtures/loader-empty-dup-vars.json @@ -0,0 +1 @@ +{"vars":{},"vars":{}} diff --git a/tests/policy/fixtures/loader-empty-trailing.json b/tests/policy/fixtures/loader-empty-trailing.json new file mode 100644 index 0000000..dc98d6a --- /dev/null +++ b/tests/policy/fixtures/loader-empty-trailing.json @@ -0,0 +1,2 @@ +{"vars":{}} +not json after the document diff --git a/tests/policy/run.sh b/tests/policy/run.sh index 3163c8b..09a8f5d 100755 --- a/tests/policy/run.sh +++ b/tests/policy/run.sh @@ -1,18 +1,26 @@ #!/usr/bin/env bash # Generic-bundle tests for policy/tendcf_services.cf against a real cf-agent. # -# Nothing here touches launchd or /Library/LaunchDaemons. Most assertions are -# policy-layer and hold on any cf-agent (a Linux CI runner, the Mac dev build). -# The ones about the CMDB loader's own behaviour (its log strings, the -# duplicate-variable message, "this container was not installed") hold only for -# the pinned fork's all-or-nothing loader (overlay/fork.json). They go through -# fork_only(): a one-time capability probe in check 4b (a file with a repeated -# member of `vars`) decides whether the loader is the fork's, and on any other -# build each such assertion prints `SKIP (loader not all-or-nothing): `, -# never a silent pass, and the run ends with a count of skips. The Linux CI legs -# set TENDCF_REQUIRE_FORK_LOADER=1, which turns a non-fork loader (so, any skip) -# into a failure. Whether the Mac dev build stays a target is an open operator -# question; both states are honest here. Checks: +# Nothing here touches launchd or /Library/LaunchDaemons. Two kinds of +# assertion hold only with the pinned fork's all-or-nothing, strict-parse loader +# (overlay/fork.json), and go through fork_only(): +# - loader assertions: its log strings, the duplicate-variable message, "this +# container was not installed", the probe-absent lines; +# - loader+policy integration assertions: the cross-check's refusal and the +# absence of actuation for a repeated member, a repeated `vars` and trailing +# input (9b dup-member, dup-vars, trailing). A lenient loader and the lenient +# readjson see the same surviving data, so the cross-check has no difference +# to refuse and the interlock or service guard acts instead. +# Everything else is policy-layer and holds on any cf-agent (the Linux CI +# legs, the Mac dev build). A one-time capability probe in check 4b (a file with +# a repeated member of `vars`) decides whether the loader is the fork's; on a +# non-fork run (the Mac dev build, retained as a target by the operator, +# 2026-11-14) each fork_only assertion prints `SKIP (loader not all-or-nothing): +# ` and the run is expected to pass with those SKIP lines and a final +# count, never a silent pass. The Linux CI legs set TENDCF_REQUIRE_FORK_LOADER=1, +# which turns a non-fork loader (so, any skip) into a failure. The non-fork +# outcome has been derived from the parser behaviour, not yet run on the Mac. +# Checks: # # 1. wiring: cf-promises parses the bundle with the example projection # (examples/host_specific.json) installed as CMDB data, so every @@ -113,8 +121,10 @@ # top-level `vars` whose later section drops the interlock (dup-vars), # non-whitespace after a valid document (trailing), a whitespace-only # default-namespace class name (class-space). Each must be refused and -# reported once by PR 42's cross-check and actuate nothing (unconditional); -# on the fork each also loads nothing, logs the loader's reason and +# reported once by PR 42's cross-check and actuate nothing (fork_only for +# the first three, the integration assertions above; unconditional for +# class-space, whose `classes` section the cross-check refuses on any +# loader); on the fork each also loads nothing, logs the loader's reason and # reports each key as not loaded (fork_only). A class that already exists (class-exists, # the host's own hard class) is not an error: the fork leaves it as it is # and installs the rest, so no refusal is expected; the case asserts that @@ -123,6 +133,12 @@ # `vars` section, so the report names only what that section holds # (tendcf_service), not the interlock the loader dropped: the # cross-check's independence from the loader is limited (proposal 13). +# Two empty-view controls (empty-dup-vars `{"vars":{},"vars":{}}`, +# empty-trailing `{"vars":{}}` plus trailing input) are refused by the +# strict loader but read as an empty `vars` by readjson: nothing installs, +# nothing actuates and no cross-check report is made (asserted on any +# loader; only the loader's refusal is fork_only). No actuation is not a +# refusal report. # 10. the same cross-check against a loader that skips ONE container, which # neither the Mac dev build nor the pinned fork does: tests/policy/sim-loader.cf # installs data:variables.* in the loader's place (cf-agent @@ -217,9 +233,11 @@ check() { # check NAME COND... } # Assertions that hold only on the pinned fork's CMDB loader (overlay/fork.json: -# all-or-nothing, strict parse): its log strings, and "this container was not -# installed". Policy-layer assertions (the cross-check's refusal, no actuation) -# stay on `check` and run against every loader. fork_loader is set once, by the +# all-or-nothing, strict parse): its log strings, "this container was not +# installed", and the loader+policy integration assertions of 9b (the +# cross-check's refusal and no actuation for a repeated member, a repeated +# `vars`, trailing input). Policy-layer assertions that hold on every loader +# stay on `check`. fork_loader is set once, by the # probe in check 4b. A loader that is not the fork's makes fork_only print a # SKIP line, never pass silently; TENDCF_REQUIRE_FORK_LOADER=1, which the Linux # CI legs set because they build the pinned fork, turns "not the fork's loader" @@ -867,20 +885,35 @@ check "list of strings in vars: actuates normally (the pre_action ran)" \ echo "# 9b. the real loader's strict parse and class handling (fork 6505f488a), policy level" # What the pinned loader does with each file is read from libpromises/cmdb.c at -# 6505f488a (line numbers there), and each case asserts it. Whatever it does, the -# cross-check refuses and nothing actuates: those assertions are unconditional. +# 6505f488a (line numbers there), and each case asserts it. The cross-check's +# refusal and the absence of actuation are asserted unconditionally only where +# the policy refuses on its own (class-space, class-exists: a `classes` section) +# or where nothing can actuate (the empty-view controls). For a repeated member, +# a repeated `vars` and trailing input they are loader+policy integration +# assertions (strict_case POLICY=fork): a lenient loader and the lenient readjson +# see the same surviving data, the cross-check has nothing to refuse, and the +# interlock or the service guard acts, so they SKIP on a non-fork loader. # Where the loader refuses the file, `key_not_loaded` reports each key of the # file the cross-check could read: it reads with readjson, which stays lenient, # so after a repeated member or a repeated `vars` section it sees the LAST one # only, and an earlier container (here the interlock of case b) is not named. # That is the limit of the cross-check's independence from the loader's parser. -strict_case() { # strict_case NAME FIXTURE LOADER-ERROR-PATTERN INSTALL-NONE KEY... - local name="$1" fixture="$2" pattern="$3" none="$4"; shift 4 +# POLICY is `any` when the cross-check refuses on any loader (the file has a +# `classes` section, which it refuses on its own), `fork` when the refusal and +# the absence of actuation depend on the strict loader: a lenient loader and the +# lenient readjson read the same surviving member, section or prefix, so the +# cross-check sees no difference, and the interlock (whose pre_action fails) or +# the service's own guard actuates or reports. Those are loader+policy +# integration assertions and SKIP on a non-fork loader. +strict_case() { # strict_case NAME FIXTURE LOADER-ERROR-PATTERN INSTALL-NONE POLICY KEY... + local name="$1" fixture="$2" pattern="$3" none="$4" policy="$5"; shift 5 + local pcheck=check + [ "$policy" = fork ] && pcheck=fork_only out="$work/strict-$name.out" cp "$repo/tests/policy/fixtures/$fixture" "$work/data/host_specific.json" "$cf_agent" -K -I -f "$work/inputs/entry.cf" >"$out" 2>&1 || true - check "$name: the policy refuses and reports it" refusal_reported "$out" - check "$name: the policy reports it once" refusal_once "$out" + "$pcheck" "$name: the policy refuses and reports it" refusal_reported "$out" + "$pcheck" "$name: the policy reports it once" refusal_once "$out" fork_only "$name: the loader refuses the file" grep -q "$pattern" "$out" if [ "$none" = yes ]; then fork_only "$name: the loader installs none of the file" \ @@ -890,7 +923,7 @@ strict_case() { # strict_case NAME FIXTURE LOADER-ERROR-PATTERN INSTALL-NONE KE for k in "$@"; do fork_only "$name: $k reported not installed" key_not_loaded "$out" "$k" done - check "$name: nothing actuated (no service, no interlock, no render)" no_actuation "$out" + "$pcheck" "$name: nothing actuated (no service, no interlock, no render)" no_actuation "$out" probe "$fixture" "$work/probe-strict-$name.out" fork_only "$name: no tendcf_interlock variable" \ grep -q "cmdb-probe: tendcf_interlock absent" "$work/probe-strict-$name.out" @@ -902,19 +935,19 @@ dup_member="Could not parse JSON file .*host_specific\\.json: Unwilling to parse # The lenient parser keeps the last (valid) one; the strict parse the loader reads # with (cmdb.c:59-84 ReadJsonFileMode, :1171-1177) refuses the file before any # validation, so the first value is no longer discarded unseen. -strict_case dup-member loader-dup-member.json "$dup_member" no tendcf_interlock tendcf_service +strict_case dup-member loader-dup-member.json "$dup_member" no fork tendcf_interlock tendcf_service # (b) `vars` twice at the top level, the later one without the interlock -strict_case dup-vars loader-dup-vars.json "$dup_member" no tendcf_service +strict_case dup-vars loader-dup-vars.json "$dup_member" no fork tendcf_service # (c) a complete valid document, then more input (the lenient parser stops after # the first document and ignores the rest) strict_case trailing loader-trailing.json \ "Could not parse JSON file .*host_specific\\.json: Unwilling to parse json data with trailing non-whitespace characters" \ - no tendcf_interlock tendcf_service + no fork tendcf_interlock tendcf_service # (d) a default-namespace class whose name is whitespace only: refused in # validation (CheckCMDBClassName, cmdb.c:776-), so nothing is installed, where it # used to reach insertion, fail, and be taken for "a class that exists already" strict_case class-space loader-class-space.json \ - "Invalid CMDB class 'default: ': the class name starts or ends with whitespace" yes \ + "Invalid CMDB class 'default: ': the class name starts or ends with whitespace" yes any \ tendcf_interlock tendcf_service check "class-space: the classes section is named by the policy" \ grep -q "has top-level section 'classes' besides 'vars'" "$out" @@ -946,6 +979,26 @@ fork_only "class-exists: the good variables were installed" \ fork_only "class-exists: the existing class was not redefined by the CMDB" \ bash -c "! grep -q 'defined a class' '$out'" +# (f) empty-view controls (Astra r2 C1, adversary r2 I1). The strict loader refuses +# each file, but the lenient readjson the cross-check reads with sees an EMPTY +# `vars` (the last of two, or the prefix before the trailing input), the same as +# `{"vars":{}}` in check 9: nothing is installed, nothing actuates, and the +# cross-check has nothing to report. So there is no refusal report here, and none +# is claimed: the loader's own ERR is the only trace. On any loader the file is +# empty or lenient-empty, so no report and no actuation hold everywhere; only the +# loader's refusal is fork-only. +for spec in "empty-dup-vars:loader-empty-dup-vars.json:Unwilling to parse json data with a duplicate object member" \ + "empty-trailing:loader-empty-trailing.json:Unwilling to parse json data with trailing non-whitespace characters"; do + name=${spec%%:*}; rest=${spec#*:}; fixture=${rest%%:*}; pattern=${rest#*:} + out="$work/strict-$name.out" + cp "$repo/tests/policy/fixtures/$fixture" "$work/data/host_specific.json" + "$cf_agent" -K -I -f "$work/inputs/entry.cf" >"$out" 2>&1 || true + check "$name: the lenient view is empty, so no cross-check report" no_crosscheck "$out" + check "$name: nothing actuated" no_actuation "$out" + fork_only "$name: the loader refuses the file" \ + grep -q "Could not parse JSON file .*host_specific\\.json: $pattern" "$out" +done + echo "# 10. CMDB cross-check, a loader that skips one container (tests/policy/sim-loader.cf)" sim_run() { # sim_run FIXTURE|none CLASSES OUT if [ "$1" = none ]; then rm -f "$work/data/host_specific.json" @@ -1116,7 +1169,7 @@ if [ "$fail" != 0 ]; then for f in refused satisfied noshell-or noshell-semi argv-alphabet argv-meta relative flavour host sysd-host sysd-host-tomb sysd1 sysd2 sysd3 sysd4 sysd5 sysd6 nixos-shape nixos-tombstone \ xc-malformed xc-nofile xc-novars xc-garbage xc-collision xc-classes xc-preset xc-preset-vars xc-uncomparable xc-checker-preset xc-checker-preset-keys xc-classes-hidden xc-augments xc-strlist xc-probe-before xc-probe-after xc-probe-noverdict xc-longkey \ malformed-unresolved malformed-index-key probe-control probe-capability probe-unresolved probe-index-key \ - strict-dup-member strict-dup-vars strict-trailing strict-class-space strict-class-exists \ + strict-dup-member strict-dup-vars strict-trailing strict-class-space strict-class-exists strict-empty-dup-vars strict-empty-trailing \ probe-strict-dup-member probe-strict-dup-vars probe-strict-trailing probe-strict-class-space \ xc-sim-control xc-sim-nointerlock xc-sim-noservice xc-sim-partial xc-sim-stray xc-sim-nofile xc-sim-changed-service xc-sim-changed-interlock \ sysd-sim-present sysd-sim-tomb; do From beddad9e9d6bdfc04d138395b4eeaea52ef58c00 Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 14 Nov 2026 16:56:55 -0500 Subject: [PATCH 15/15] Qualify the cross-check refusal claim (empty lenient view: no actuation, no report); non-whitespace after the document; record the 2026-11-14 Replace ruling for B-5b Co-Authored-By: Claude Sonnet 5.5 --- .../tendcf-validate-proposal-2026-11-03.md | 9 ++++++-- docs/architecture/upstream-overlay.md | 7 ++++--- docs/architecture/upstream-register.md | 6 ++++-- overlay/overlay.json | 2 +- policy/tendcf_services.cf | 21 ++++++++++++------- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/docs/architecture/tendcf-validate-proposal-2026-11-03.md b/docs/architecture/tendcf-validate-proposal-2026-11-03.md index d8933ff..e7ef2c9 100644 --- a/docs/architecture/tendcf-validate-proposal-2026-11-03.md +++ b/docs/architecture/tendcf-validate-proposal-2026-11-03.md @@ -1228,8 +1228,13 @@ is limited, not complete: the loader's strict parse (a repeated member or trailing input refuses the file; fork `6505f488a`) belongs to the CMDB loader only, while this check's `readjson` stays lenient and sees the last of a repeated member or `vars` section, so an earlier container the loader refused -is not named by the check (it still refuses, as nothing the file lists was -loaded). The check does not detect such a file when the loader is lenient and +is not named by the check. The check reports a refusal when that lenient view +still lists variables the loader did not install (or another feature it refuses +on its own); when the lenient view is empty (`{"vars":{},"vars":{}}`, or +`{"vars":{}}` followed by non-whitespace) nothing is installed and nothing +actuates, but the check has nothing to report, so no actuation is not a refusal +report and the loader's own error is the only trace (`run.sh` 9b, empty-view +controls). The check does not detect such a file when the loader is lenient and the repeated member is invisible to both parsers. Two findings from the implementation, both about the proof above. (1) The diff --git a/docs/architecture/upstream-overlay.md b/docs/architecture/upstream-overlay.md index d23dfbe..5ea36ab 100644 --- a/docs/architecture/upstream-overlay.md +++ b/docs/architecture/upstream-overlay.md @@ -226,9 +226,10 @@ CMDB loader that replaces B-5b's per-entry skip (a skipped interlock leaves the services it guards unguarded). The manifest entry still reproduces `8f0076b81` and carries a `superseded_on_fork` note; the table above is the 2026-10-09 state and is not updated. Upstream plus this overlay skips a bad entry; the -pinned fork installs nothing from the file. Keeping, retiring or replacing the -patch is a separate ruling ([`upstream-register.md`](upstream-register.md) B-5b -note). +pinned fork installs nothing from the file. The operator ruled on 2026-11-14 +to replace the patch: a later, separate PR makes the overlay carry the +all-or-nothing loader in its place ([`upstream-register.md`](upstream-register.md) +B-5b note). So the overlay reproduces exactly the inputs whose build was verified on 2026-08-19, from this repository alone, and would still apply to a build diff --git a/docs/architecture/upstream-register.md b/docs/architecture/upstream-register.md index 7bbb7ad..c757715 100644 --- a/docs/architecture/upstream-register.md +++ b/docs/architecture/upstream-register.md @@ -366,8 +366,10 @@ stay closed unmerged. The overlay manifest's B-5b entry (`overlay/overlay.json`) still describes and reproduces `8f0076b81`, not this behaviour; it now carries a `superseded_on_fork` note saying so, and [`upstream-overlay.md`](upstream-overlay.md) section 7 repeats it. Whether the -overlay keeps, retires or replaces that patch is left to a separate ruling, -because it changes what the overlay reproduces. +overlay keeps, retires or replaces that patch was ruled on 2026-11-14 (Replace: +the overlay will carry the all-or-nothing loader instead of the per-entry skip), +and is done in a later, separate PR because it changes what the overlay +reproduces. B-2 through B-7 are described, measured and sourced in [`cfengine-upstream-candidates-2026-08-16.md`](cfengine-upstream-candidates-2026-08-16.md); diff --git a/overlay/overlay.json b/overlay/overlay.json index cabea8d..2716b5b 100644 --- a/overlay/overlay.json +++ b/overlay/overlay.json @@ -32,7 +32,7 @@ "retire_when": "an upstream commit carries the same change (`bin/overlay.py retired` says RETIRE), or the code it protects is no longer shipped", "role": "load-bearing", "subject": "Fixed one bad CMDB entry discarding every entry in its section", - "superseded_on_fork": "2026-11-02, operator ruling R13 (PR #41): the fork's tendcf-integration branch, which overlay/fork.json pins, replaces this patch's per-entry skip with an all-or-nothing loader (branch cmdb-fail-closed: a750b1dfe, dbf9dede6, 61065e551, 736becc07; merged d32cade13, hardened by djbclark/core PR #98 and a strict libntech parse, pin 6505f488a). A skipped interlock entry leaves the services it guards unguarded. This entry still describes, and apply reproduces, commit 8f0076b81 exactly, so upstream plus the overlay skips a bad entry and does NOT behave like the pinned fork. Keeping, retiring or replacing it is a separate ruling because it changes what the overlay reproduces (upstream-overlay.md section 7).", + "superseded_on_fork": "2026-11-02, operator ruling R13 (PR #41): the fork's tendcf-integration branch, which overlay/fork.json pins, replaces this patch's per-entry skip with an all-or-nothing loader (branch cmdb-fail-closed: a750b1dfe, dbf9dede6, 61065e551, 736becc07; merged d32cade13, hardened by djbclark/core PR #98 and a strict libntech parse, pin 6505f488a). A skipped interlock entry leaves the services it guards unguarded. This entry still describes, and apply reproduces, commit 8f0076b81 exactly, so upstream plus the overlay skips a bad entry and does NOT behave like the pinned fork. Operator ruling 2026-11-14: Replace. A later, separate PR makes the overlay carry the all-or-nothing loader instead of this per-entry skip, because that changes what the overlay reproduces (upstream-overlay.md section 7); this PR leaves the patch and its manifest entry as they are.", "upstream_pr": "https://github.com/cfengine/core/pull/6320", "upstream_pr_state": "closed unmerged 2026-08-19" } diff --git a/policy/tendcf_services.cf b/policy/tendcf_services.cf index b449211..ac9d854 100644 --- a/policy/tendcf_services.cf +++ b/policy/tendcf_services.cf @@ -69,14 +69,19 @@ # `!interlock_blocked_*`, and that class only exists for an interlock that # loaded). The fork at the pin (overlay/fork.json, PR #41, operator ruling R13) # loads all-or-nothing instead: an invalid entry, a repeated object member -# anywhere, anything after the document, a class name with whitespace at either -# end, a variable that exists already, and it installs none of the file, so this -# check then sees every `vars` key missing and refuses. That strict parse is the -# CMDB loader's only: `readjson`, which this check reads the file with, and -# def.json stay lenient, so after a repeated member or a repeated `vars` section -# the check sees the LAST one only (an earlier container is not named). It still -# refuses, because the loader installed nothing the file lists. The two are not -# fully independent for that reason, and each holds for a loader that fails +# anywhere, non-whitespace after the document, a class name with whitespace at +# either end, a variable that exists already, and it installs none of the file, +# so this check then sees every `vars` key missing and refuses. That strict parse +# is the CMDB loader's only: `readjson`, which this check reads the file with, +# and def.json stay lenient, so after a repeated member or a repeated `vars` +# section the check sees the LAST one only (an earlier container is not named). +# It reports a refusal when that lenient view still lists variables the loader +# did not install (or another feature it refuses on its own). When the lenient +# view is EMPTY (`{"vars":{},"vars":{}}`, or `{"vars":{}}` plus non-whitespace +# after it) nothing is installed and nothing actuates, but the check has nothing +# to report: no actuation is not a refusal report, and the loader's own error is +# then the only trace (tests/policy/run.sh 9b, empty-view controls). The two are +# not fully independent for that reason, and each holds for a loader that fails # closed, for one that does not, and for a gap in either, to the extent the # other does not share the gap. The check does not model WHY an entry was # dropped. It reads the file itself and compares it with what the loader installed: