@synopackageland/cli 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/build-spk/generator.js +3 -0
- package/dist/build-spk/notices.d.ts +5 -0
- package/dist/build-spk/notices.js +60 -0
- package/dist/cli.js +9 -2
- package/dist/error-registry.js +20 -0
- package/dist/init.d.ts +4 -0
- package/dist/init.js +20 -12
- package/dist/standalone/build.js +3 -1
- package/dist/standalone/daemon.d.ts +23 -0
- package/dist/standalone/daemon.js +114 -0
- package/dist/standalone/dsm-window.d.ts +1 -1
- package/dist/standalone/dsm-window.js +50 -10
- package/dist/standalone/helper-inventory.d.ts +16 -0
- package/dist/standalone/helper-inventory.js +2 -0
- package/dist/standalone/helper.d.ts +2 -12
- package/dist/standalone/helper.js +8 -7
- package/dist/standalone/host-adapter.d.ts +5 -0
- package/dist/standalone/host-adapter.js +148 -0
- package/dist/standalone/host-platform.d.ts +13 -0
- package/dist/standalone/host-platform.js +42 -0
- package/dist/standalone/host-types.d.ts +49 -0
- package/dist/standalone/host-types.js +1 -0
- package/dist/standalone/inspect-helper.d.ts +6 -0
- package/dist/standalone/inspect-helper.js +88 -0
- package/dist/standalone/inspect-spk.d.ts +2 -0
- package/dist/standalone/inspect-spk.js +49 -0
- package/dist/standalone/lifecycle-helper.d.ts +2 -0
- package/dist/standalone/lifecycle-helper.js +12 -0
- package/dist/standalone/lifecycle.d.ts +3 -0
- package/dist/standalone/lifecycle.js +53 -0
- package/dist/standalone/manifest.d.ts +2 -0
- package/dist/standalone/manifest.js +4 -1
- package/dist/standalone/reopen-events.d.ts +2 -0
- package/dist/standalone/reopen-events.js +28 -0
- package/dist/standalone/root-messages.js +9 -0
- package/dist/standalone/root-window.d.ts +4 -3
- package/dist/standalone/root-window.js +17 -5
- package/dist/standalone/spk.d.ts +4 -3
- package/dist/standalone/spk.js +20 -33
- package/dist/template-paths.d.ts +2 -0
- package/dist/template-paths.js +9 -0
- package/dist/templates/_daemon/fixture_linux_test.go +15 -0
- package/dist/templates/_daemon/fixture_other_test.go +7 -0
- package/dist/templates/_daemon/go.mod +3 -0
- package/dist/templates/_daemon/main.go +608 -0
- package/dist/templates/_daemon/main_test.go +242 -0
- package/dist/templates/_daemon/process_linux.go +55 -0
- package/dist/templates/_daemon/process_linux_test.go +161 -0
- package/dist/templates/_daemon/process_other.go +14 -0
- package/dist/templates/_daemon/testdata/child.go +41 -0
- package/dist/templates/_shared/GO-LICENSE +27 -0
- package/dist/templates/_shared/GO-PATENTS +22 -0
- package/dist/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/dist/templates/_shared/notice-overrides/index.json +14 -0
- package/dist/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/dist/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/dist/templates/_shared/third-party-notices.mjs +51 -0
- package/dist/templates/native-go/README.md +57 -1
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/dist/templates/native-go/backend/go.mod +4 -0
- package/dist/templates/native-go/backend/go.sum +4 -0
- package/dist/templates/native-go/backend/internal/api/binary.go +154 -0
- package/dist/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/dist/templates/native-go/backend/internal/api/registry.go +14 -4
- package/dist/templates/native-go/backend/internal/api/server.go +4 -0
- package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/dist/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +11 -0
- package/dist/templates/native-go/backend/internal/app/routes_test.go +10 -5
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/dist/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/control.go +226 -21
- package/dist/templates/native-go/backend/internal/helper/control_test.go +10 -2
- package/dist/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/dist/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/dist/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/dist/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/dist/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/dist/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/dist/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/dist/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/dist/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/dist/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/dist/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/dist/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/dist/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/dist/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/dist/templates/native-go/backend/internal/helper/process_linux.go +11 -1
- package/dist/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/dist/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/dist/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/dist/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/server_linux.go +44 -3
- package/dist/templates/native-go/backend/internal/helper/status.go +74 -11
- package/dist/templates/native-go/backend/internal/helper/status_test.go +83 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +28 -5
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +187 -16
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/dist/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/dist/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/dist/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/dist/templates/native-go/backend/internal/helper/write.go +77 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/dist/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/dist/templates/native-go/ui/app.js +8 -1
- package/dist/templates/native-go-better-auth/node/build.mjs +2 -0
- package/dist/templates/native-go-vue/README.md +115 -1
- package/dist/templates/native-go-vue/frontend/DESIGN.md +1 -1
- package/dist/templates/native-go-vue/frontend/package-lock.json +132 -229
- package/dist/templates/native-go-vue/frontend/package.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/App.vue +33 -6
- package/dist/templates/native-go-vue/frontend/src/context.ts +41 -2
- package/dist/templates/native-go-vue/frontend/src/main.ts +4 -1
- package/dist/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/dist/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/dist/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/dist/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/dist/templates/native-go-vue/frontend/src/style.css +17 -0
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
- package/dist/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/dist/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/dist/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/dist/templates/native-go-vue/frontend/tsconfig.json +1 -1
- package/dist/templates/native-go-vue/frontend/vite.config.ts +6 -4
- package/package.json +3 -2
- package/templates/_daemon/fixture_linux_test.go +15 -0
- package/templates/_daemon/fixture_other_test.go +7 -0
- package/templates/_daemon/go.mod +3 -0
- package/templates/_daemon/main.go +608 -0
- package/templates/_daemon/main_test.go +242 -0
- package/templates/_daemon/process_linux.go +55 -0
- package/templates/_daemon/process_linux_test.go +161 -0
- package/templates/_daemon/process_other.go +14 -0
- package/templates/_daemon/testdata/child.go +41 -0
- package/templates/_shared/GO-LICENSE +27 -0
- package/templates/_shared/GO-PATENTS +22 -0
- package/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/templates/_shared/notice-overrides/index.json +14 -0
- package/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/templates/_shared/third-party-notices.mjs +51 -0
- package/templates/native-go/README.md +57 -1
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/templates/native-go/backend/go.mod +4 -0
- package/templates/native-go/backend/go.sum +4 -0
- package/templates/native-go/backend/internal/api/binary.go +154 -0
- package/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/templates/native-go/backend/internal/api/registry.go +14 -4
- package/templates/native-go/backend/internal/api/server.go +4 -0
- package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/templates/native-go/backend/internal/app/routes.go +11 -0
- package/templates/native-go/backend/internal/app/routes_test.go +10 -5
- package/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/templates/native-go/backend/internal/helper/control.go +226 -21
- package/templates/native-go/backend/internal/helper/control_test.go +10 -2
- package/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/templates/native-go/backend/internal/helper/process_linux.go +11 -1
- package/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/templates/native-go/backend/internal/helper/server_linux.go +44 -3
- package/templates/native-go/backend/internal/helper/status.go +74 -11
- package/templates/native-go/backend/internal/helper/status_test.go +83 -0
- package/templates/native-go/backend/internal/helper/supervision.go +28 -5
- package/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux.go +187 -16
- package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
- package/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/templates/native-go/backend/internal/helper/write.go +77 -0
- package/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/templates/native-go/ui/app.js +8 -1
- package/templates/native-go-better-auth/node/build.mjs +2 -0
- package/templates/native-go-vue/README.md +115 -1
- package/templates/native-go-vue/frontend/DESIGN.md +1 -1
- package/templates/native-go-vue/frontend/package-lock.json +132 -229
- package/templates/native-go-vue/frontend/package.json +1 -1
- package/templates/native-go-vue/frontend/src/App.vue +33 -6
- package/templates/native-go-vue/frontend/src/context.ts +41 -2
- package/templates/native-go-vue/frontend/src/main.ts +4 -1
- package/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/templates/native-go-vue/frontend/src/style.css +17 -0
- package/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
- package/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/templates/native-go-vue/frontend/tsconfig.json +1 -1
- package/templates/native-go-vue/frontend/vite.config.ts +6 -4
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"github.com/godbus/dbus/v5"
|
|
7
|
+
"os"
|
|
8
|
+
"os/exec"
|
|
9
|
+
"path/filepath"
|
|
10
|
+
"reflect"
|
|
11
|
+
"testing"
|
|
12
|
+
"time"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
func logObserverResult(t *testing.T, p LinuxProcesses, before Record, identity Process, mustFence bool, childBefore ...int) {
|
|
16
|
+
t.Helper()
|
|
17
|
+
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second)
|
|
18
|
+
defer cancel()
|
|
19
|
+
if mustFence {
|
|
20
|
+
if err := waitHealthy(ctx, func(context.Context) bool {
|
|
21
|
+
r, e := readRecord(p.StateDir, 0)
|
|
22
|
+
return e == nil && r.Lifecycle.Phase == "stopped" && r.Lifecycle.Completion != ""
|
|
23
|
+
}); err != nil {
|
|
24
|
+
t.Fatal("no durable teardown", err)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
r, err := readRecord(p.StateDir, 0)
|
|
28
|
+
if err != nil {
|
|
29
|
+
t.Fatal(err)
|
|
30
|
+
}
|
|
31
|
+
if r.Lifecycle.Phase == "running" {
|
|
32
|
+
if mustFence || !reflect.DeepEqual(r, before) || p.Client.Status(ctx).State != "ready" {
|
|
33
|
+
t.Fatalf("invalid preservation: %+v", r)
|
|
34
|
+
}
|
|
35
|
+
current, e := readProcess(p.RunDir, 0)
|
|
36
|
+
if e != nil || current != identity {
|
|
37
|
+
t.Fatalf("helper identity changed: %+v %v", current, e)
|
|
38
|
+
}
|
|
39
|
+
if len(childBefore) == 1 && supervisedPID(t, identity.PID) != childBefore[0] {
|
|
40
|
+
t.Fatal("owned child replaced during reload")
|
|
41
|
+
}
|
|
42
|
+
t.Logf("mechanism preserved epoch=%s supervisor=%d child=%d", r.Lifecycle.Epoch, identity.PID, supervisedPID(t, identity.PID))
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
if r.Lifecycle.Phase != "stopped" {
|
|
46
|
+
t.Fatalf("incomplete fence: %+v", r)
|
|
47
|
+
}
|
|
48
|
+
proof, err := completionRecord(p.Client, r)
|
|
49
|
+
if err != nil || proof.Process != identity {
|
|
50
|
+
t.Fatalf("wrong proof: %+v %v", proof, err)
|
|
51
|
+
}
|
|
52
|
+
var d observerDiagnostic
|
|
53
|
+
if err := waitHealthy(ctx, func(context.Context) bool {
|
|
54
|
+
b, e := os.ReadFile(filepath.Join(p.StateDir, "observer-diagnostic.json"))
|
|
55
|
+
return e == nil && json.Unmarshal(b, &d) == nil
|
|
56
|
+
}); err != nil {
|
|
57
|
+
t.Fatal(err)
|
|
58
|
+
}
|
|
59
|
+
if d.Epoch != before.Lifecycle.Epoch || d.Fence.Detail != r.Lifecycle.SubReason || r.Lifecycle.SubReason == "" {
|
|
60
|
+
t.Fatalf("inconsistent diagnostic: %+v %+v", r, d)
|
|
61
|
+
}
|
|
62
|
+
b, _ := json.Marshal(d)
|
|
63
|
+
t.Logf("mechanism durable reason=%s subReason=%s diagnostic=%s", r.Lifecycle.Reason, r.Lifecycle.SubReason, b)
|
|
64
|
+
}
|
|
65
|
+
func TestLinuxObserverDaemonReexecMechanism(t *testing.T) {
|
|
66
|
+
p := linuxFixture(t)
|
|
67
|
+
identity := startVMHelper(t, p)
|
|
68
|
+
before, err := readRecord(p.StateDir, 0)
|
|
69
|
+
if err != nil {
|
|
70
|
+
t.Fatal(err)
|
|
71
|
+
}
|
|
72
|
+
if out, err := exec.Command("systemctl", "daemon-reexec").CombinedOutput(); err != nil {
|
|
73
|
+
t.Fatalf("reexec %s %v", out, err)
|
|
74
|
+
}
|
|
75
|
+
time.Sleep(1500 * time.Millisecond)
|
|
76
|
+
logObserverResult(t, p, before, identity, false)
|
|
77
|
+
}
|
|
78
|
+
func TestLinuxObserverLongReloadMechanism(t *testing.T) {
|
|
79
|
+
p := linuxFixture(t)
|
|
80
|
+
identity := startVMHelper(t, p)
|
|
81
|
+
childBefore := supervisedPID(t, identity.PID)
|
|
82
|
+
before, err := readRecord(p.StateDir, 0)
|
|
83
|
+
if err != nil {
|
|
84
|
+
t.Fatal(err)
|
|
85
|
+
}
|
|
86
|
+
dir := "/etc/systemd/system-generators"
|
|
87
|
+
if err = os.MkdirAll(dir, 0755); err != nil {
|
|
88
|
+
t.Fatal(err)
|
|
89
|
+
}
|
|
90
|
+
generator := filepath.Join(dir, "m1j-slow-reload")
|
|
91
|
+
if err = os.WriteFile(generator, []byte("#!/bin/sh\nsleep 4\n"), 0755); err != nil {
|
|
92
|
+
t.Fatal(err)
|
|
93
|
+
}
|
|
94
|
+
defer os.Remove(generator)
|
|
95
|
+
start := time.Now()
|
|
96
|
+
if out, err := exec.Command("systemctl", "daemon-reload").CombinedOutput(); err != nil {
|
|
97
|
+
t.Fatalf("reload %s %v", out, err)
|
|
98
|
+
}
|
|
99
|
+
t.Logf("slow reload duration=%s", time.Since(start))
|
|
100
|
+
time.Sleep(750 * time.Millisecond)
|
|
101
|
+
logObserverResult(t, p, before, identity, false, childBefore)
|
|
102
|
+
r, err := readRecord(p.StateDir, 0)
|
|
103
|
+
if err != nil || !reflect.DeepEqual(r, before) {
|
|
104
|
+
t.Fatalf("bounded long reload retired epoch: %+v %v", r, err)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
func TestLinuxObserverOtherUnitSequenceMechanism(t *testing.T) {
|
|
108
|
+
p := linuxFixture(t)
|
|
109
|
+
identity := startVMHelper(t, p)
|
|
110
|
+
childBefore := supervisedPID(t, identity.PID)
|
|
111
|
+
before, err := readRecord(p.StateDir, 0)
|
|
112
|
+
if err != nil {
|
|
113
|
+
t.Fatal(err)
|
|
114
|
+
}
|
|
115
|
+
unit := "pkgctl-m1j-other.service"
|
|
116
|
+
path := filepath.Join("/etc/systemd/system", unit)
|
|
117
|
+
if err = os.WriteFile(path, []byte("[Service]\nType=oneshot\nExecStart=/bin/true\nRemainAfterExit=yes\n"), 0644); err != nil {
|
|
118
|
+
t.Fatal(err)
|
|
119
|
+
}
|
|
120
|
+
defer os.Remove(path)
|
|
121
|
+
for _, args := range [][]string{{"daemon-reload"}, {"start", unit}, {"stop", unit}, {"restart", unit}, {"daemon-reload"}, {"stop", unit}} {
|
|
122
|
+
if out, err := exec.Command("systemctl", args...).CombinedOutput(); err != nil {
|
|
123
|
+
t.Fatalf("%v: %s %v", args, out, err)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
time.Sleep(600 * time.Millisecond)
|
|
127
|
+
logObserverResult(t, p, before, identity, false, childBefore)
|
|
128
|
+
r, err := readRecord(p.StateDir, 0)
|
|
129
|
+
if err != nil || !reflect.DeepEqual(r, before) {
|
|
130
|
+
t.Fatalf("other unit retired helper: %+v %v", r, err)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Deterministic delivery-seam probe in a real VM observer, not a claim that
|
|
135
|
+
// systemd emitted an invalidation or that this packet occurred on DSM.
|
|
136
|
+
func TestLinuxObserverOwnInvalidationDuringReloadMechanism(t *testing.T) {
|
|
137
|
+
p := linuxFixture(t)
|
|
138
|
+
o, err := openUnitObserver(context.Background(), p.Expected)
|
|
139
|
+
if err != nil {
|
|
140
|
+
t.Fatal(err)
|
|
141
|
+
}
|
|
142
|
+
defer o.conn.Close()
|
|
143
|
+
for _, key := range []string{"LoadState", "ActiveState", "SubState", "Job", "ActiveEnterTimestampMonotonic", "InvocationID"} {
|
|
144
|
+
// Fresh observer for each sticky cause.
|
|
145
|
+
fresh, err := openUnitObserver(context.Background(), p.Expected)
|
|
146
|
+
if err != nil {
|
|
147
|
+
t.Fatal(err)
|
|
148
|
+
}
|
|
149
|
+
fresh.DeliverSignal("", "", &dbus.Signal{Name: managerInterface + ".Reloading", Sender: fresh.owner, Path: "/org/freedesktop/systemd1", Body: []interface{}{true}})
|
|
150
|
+
fresh.DeliverSignal("", "", &dbus.Signal{Name: propertiesInterface + ".PropertiesChanged", Sender: fresh.owner, Path: fresh.path, Body: []interface{}{unitInterface, map[string]dbus.Variant{}, []string{key}}})
|
|
151
|
+
d := fresh.gate.observerDiagnostic("")
|
|
152
|
+
t.Logf("INJECTED own invalidation key=%s cause=%s/%s", key, d.Reason, d.Fence.Detail)
|
|
153
|
+
if fresh.gate.allow(time.Now()) || d.Fence.Detail != "property-invalidated-"+key {
|
|
154
|
+
t.Fatalf("lost invalidation: %+v", d)
|
|
155
|
+
}
|
|
156
|
+
fresh.conn.Close()
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
func TestLinuxObserverDiagnosticWriteFailureStillCompletes(t *testing.T) {
|
|
161
|
+
p := linuxFixture(t)
|
|
162
|
+
identity := startVMHelper(t, p)
|
|
163
|
+
before, err := readRecord(p.StateDir, 0)
|
|
164
|
+
if err != nil {
|
|
165
|
+
t.Fatal(err)
|
|
166
|
+
}
|
|
167
|
+
path := filepath.Join(p.StateDir, "observer-diagnostic.json")
|
|
168
|
+
if err = os.Mkdir(path, 0700); err != nil {
|
|
169
|
+
t.Fatal(err)
|
|
170
|
+
}
|
|
171
|
+
vmUnit(t, "stop")
|
|
172
|
+
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second)
|
|
173
|
+
defer cancel()
|
|
174
|
+
if err = waitHealthy(ctx, func(context.Context) bool {
|
|
175
|
+
r, e := readRecord(p.StateDir, 0)
|
|
176
|
+
return e == nil && r.Lifecycle.Phase == "stopped" && r.Lifecycle.Completion != ""
|
|
177
|
+
}); err != nil {
|
|
178
|
+
t.Fatal(err)
|
|
179
|
+
}
|
|
180
|
+
r, err := readRecord(p.StateDir, 0)
|
|
181
|
+
if err != nil {
|
|
182
|
+
t.Fatal(err)
|
|
183
|
+
}
|
|
184
|
+
proof, err := completionRecord(p.Client, r)
|
|
185
|
+
if err != nil || proof.Epoch != before.Lifecycle.Epoch || proof.Process != identity || r.Residual || r.Lifecycle.SubReason == "" {
|
|
186
|
+
t.Fatalf("diagnostic failure affected proof: %+v %+v %v", r, proof, err)
|
|
187
|
+
}
|
|
188
|
+
t.Logf("failed diagnostic write retained durable %s/%s and exact completion", r.Lifecycle.Reason, r.Lifecycle.SubReason)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
func TestLinuxObserverReloadCapStillFences(t *testing.T) {
|
|
192
|
+
p := linuxFixture(t)
|
|
193
|
+
identity := startVMHelper(t, p)
|
|
194
|
+
before, err := readRecord(p.StateDir, 0)
|
|
195
|
+
if err != nil {
|
|
196
|
+
t.Fatal(err)
|
|
197
|
+
}
|
|
198
|
+
dir := "/etc/systemd/system-generators"
|
|
199
|
+
if err = os.MkdirAll(dir, 0755); err != nil {
|
|
200
|
+
t.Fatal(err)
|
|
201
|
+
}
|
|
202
|
+
generator := filepath.Join(dir, "m1j-cap-reload")
|
|
203
|
+
if err = os.WriteFile(generator, []byte("#!/bin/sh\nsleep 12\n"), 0755); err != nil {
|
|
204
|
+
t.Fatal(err)
|
|
205
|
+
}
|
|
206
|
+
defer os.Remove(generator)
|
|
207
|
+
start := time.Now()
|
|
208
|
+
if out, err := exec.Command("systemctl", "daemon-reload").CombinedOutput(); err != nil {
|
|
209
|
+
t.Fatalf("reload %s %v", out, err)
|
|
210
|
+
}
|
|
211
|
+
t.Logf("cap reload duration=%s", time.Since(start))
|
|
212
|
+
logObserverResult(t, p, before, identity, true)
|
|
213
|
+
r, err := readRecord(p.StateDir, 0)
|
|
214
|
+
if err != nil || r.Lifecycle.SubReason != "reload-deadline" {
|
|
215
|
+
t.Fatalf("wrong cap cause: %+v %v", r, err)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/binary"
|
|
6
|
+
"errors"
|
|
7
|
+
"net"
|
|
8
|
+
"testing"
|
|
9
|
+
"time"
|
|
10
|
+
|
|
11
|
+
"github.com/godbus/dbus/v5"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
type observerTerminationBarrier struct {
|
|
15
|
+
*unitObserver
|
|
16
|
+
terminated chan struct{}
|
|
17
|
+
resume chan struct{}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
func (o *observerTerminationBarrier) Terminate() {
|
|
21
|
+
o.unitObserver.Terminate()
|
|
22
|
+
close(o.terminated)
|
|
23
|
+
<-o.resume
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Blocking Close after the production Terminate callback proves admission is
|
|
27
|
+
// fenced synchronously, before Context cancellation or the watcher's next tick.
|
|
28
|
+
// Closing only the underlying socket is essential: calling dbus.Conn.Close
|
|
29
|
+
// ourselves would fence even with the unfixed background decoder panic.
|
|
30
|
+
func testObserverPaddingClose(t *testing.T, order binary.ByteOrder, state string, verifyFence func(*unitObserver)) {
|
|
31
|
+
t.Helper()
|
|
32
|
+
b := testBinding()
|
|
33
|
+
o := &unitObserver{gate: newAdmission(b)}
|
|
34
|
+
now := time.Now()
|
|
35
|
+
o.gate.observe(b, 7, true, now)
|
|
36
|
+
if !o.gate.allow(now) {
|
|
37
|
+
t.Fatal("fixture did not begin ready")
|
|
38
|
+
}
|
|
39
|
+
wantReason := "observation-unavailable"
|
|
40
|
+
switch state {
|
|
41
|
+
case "reload":
|
|
42
|
+
o.gate.requestUnitCheck(true, now)
|
|
43
|
+
case "previous-fence":
|
|
44
|
+
wantReason = "unit-transition"
|
|
45
|
+
o.gate.fence(wantReason)
|
|
46
|
+
}
|
|
47
|
+
barrier := &observerTerminationBarrier{o, make(chan struct{}), make(chan struct{})}
|
|
48
|
+
conn, raw, peer := observerTestBus(t, barrier, dbus.WithIncomingInterceptor(o.incomingObserverMessage))
|
|
49
|
+
o.conn = conn
|
|
50
|
+
// Release before the bus fixture's cleanup tries to Close the connection.
|
|
51
|
+
released := false
|
|
52
|
+
defer func() {
|
|
53
|
+
if !released {
|
|
54
|
+
close(barrier.resume)
|
|
55
|
+
}
|
|
56
|
+
}()
|
|
57
|
+
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
|
58
|
+
defer cancel()
|
|
59
|
+
call := conn.BusObject().GoWithContext(ctx, "org.freedesktop.DBus.GetNameOwner", 0, make(chan *dbus.Call, 1), systemdName)
|
|
60
|
+
if _, err := dbus.DecodeMessage(peer); err != nil {
|
|
61
|
+
t.Fatal("pending method request:", err)
|
|
62
|
+
}
|
|
63
|
+
packet, header := observerPaddedFrame(t, order)
|
|
64
|
+
raw.arm(header)
|
|
65
|
+
if _, err := peer.Write(packet[:header]); err != nil {
|
|
66
|
+
t.Fatal(err)
|
|
67
|
+
}
|
|
68
|
+
select {
|
|
69
|
+
case <-raw.padding:
|
|
70
|
+
case <-time.After(time.Second):
|
|
71
|
+
t.Fatal("reader did not reach header alignment padding")
|
|
72
|
+
}
|
|
73
|
+
if err := raw.Conn.Close(); err != nil {
|
|
74
|
+
t.Fatal(err)
|
|
75
|
+
}
|
|
76
|
+
select {
|
|
77
|
+
case <-barrier.terminated:
|
|
78
|
+
case <-time.After(time.Second):
|
|
79
|
+
t.Fatal("socket failure did not synchronously terminate subscription")
|
|
80
|
+
}
|
|
81
|
+
select {
|
|
82
|
+
case <-conn.Context().Done():
|
|
83
|
+
t.Fatal("connection cancelled before subscription barrier")
|
|
84
|
+
default:
|
|
85
|
+
}
|
|
86
|
+
if o.gate.allow(time.Now()) || o.gate.reason() != wantReason {
|
|
87
|
+
t.Fatalf("subscription did not immediately preserve sticky fence: %s", o.gate.reason())
|
|
88
|
+
}
|
|
89
|
+
if verifyFence != nil {
|
|
90
|
+
verifyFence(o)
|
|
91
|
+
}
|
|
92
|
+
// Subsequent healthy observations, reload edges, and errors cannot revive or
|
|
93
|
+
// overwrite the first fence, even when the socket failed inside revalidation.
|
|
94
|
+
o.gate.observe(b, 7, true, time.Now())
|
|
95
|
+
o.gate.requestUnitCheck(false, time.Now())
|
|
96
|
+
o.gate.fence("bus-owner-changed")
|
|
97
|
+
if o.gate.allow(time.Now()) || o.gate.reason() != wantReason {
|
|
98
|
+
t.Fatalf("disconnect fence was cleared or overwritten: %s", o.gate.reason())
|
|
99
|
+
}
|
|
100
|
+
if verifyFence != nil {
|
|
101
|
+
verifyFence(o)
|
|
102
|
+
}
|
|
103
|
+
close(barrier.resume)
|
|
104
|
+
released = true
|
|
105
|
+
select {
|
|
106
|
+
case <-conn.Context().Done():
|
|
107
|
+
case <-time.After(time.Second):
|
|
108
|
+
t.Fatal("background reader did not close the connection")
|
|
109
|
+
}
|
|
110
|
+
select {
|
|
111
|
+
case completed := <-call.Done:
|
|
112
|
+
if !errors.Is(completed.Err, net.ErrClosed) {
|
|
113
|
+
t.Fatalf("pending call did not return the socket close error: %v", completed.Err)
|
|
114
|
+
}
|
|
115
|
+
case <-time.After(time.Second):
|
|
116
|
+
t.Fatal("background reader left a pending call unresolved")
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
func TestLinuxObserverDBusPaddingClose(t *testing.T) {
|
|
121
|
+
for _, order := range []binary.ByteOrder{binary.LittleEndian, binary.BigEndian} {
|
|
122
|
+
for _, state := range []string{"ready", "reload", "previous-fence"} {
|
|
123
|
+
t.Run(order.String()+"/"+state, func(t *testing.T) {
|
|
124
|
+
testObserverPaddingClose(t, order, state, observerPaddingFenceProof(t, state))
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// M1j is now on the base: verify the actual sticky sub-reason and durable
|
|
131
|
+
// completion in each production-path socket-close case, not only an overlay.
|
|
132
|
+
func observerPaddingFenceProof(t *testing.T, state string) func(*unitObserver) {
|
|
133
|
+
t.Helper()
|
|
134
|
+
want := "subscription-terminated"
|
|
135
|
+
if state == "previous-fence" {
|
|
136
|
+
want = "unit-transition"
|
|
137
|
+
}
|
|
138
|
+
var first observerEvent
|
|
139
|
+
checks := 0
|
|
140
|
+
return func(o *unitObserver) {
|
|
141
|
+
t.Helper()
|
|
142
|
+
d := o.gate.observerDiagnostic("")
|
|
143
|
+
if d.Fence.Detail != want {
|
|
144
|
+
t.Fatalf("wrong sticky detail: %+v", d)
|
|
145
|
+
}
|
|
146
|
+
checks++
|
|
147
|
+
if checks == 1 {
|
|
148
|
+
first = d.Fence
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
if d.Fence != first {
|
|
152
|
+
t.Fatalf("first fence changed: %+v -> %+v", first, d.Fence)
|
|
153
|
+
}
|
|
154
|
+
c := fixture(t)
|
|
155
|
+
b := testBinding()
|
|
156
|
+
l, err := newLifecycle(b)
|
|
157
|
+
if err != nil {
|
|
158
|
+
t.Fatal(err)
|
|
159
|
+
}
|
|
160
|
+
if err = writeProtected(c.StateDir, "approval.json", Record{Schema: 2, Inventory: c.Expected, Enabled: true, Lifecycle: l}); err != nil {
|
|
161
|
+
t.Fatal(err)
|
|
162
|
+
}
|
|
163
|
+
if err = fenceRecord(c, l.Epoch, o.gate.reason(), d.Fence.Detail); err != nil {
|
|
164
|
+
t.Fatal(err)
|
|
165
|
+
}
|
|
166
|
+
p := Process{Inventory: c.Expected, Mode: "supervised", Boot: b.Boot, PID: 42, Start: "123", Inode: 9}
|
|
167
|
+
if err = completeRecord(c, l.Epoch, p); err != nil {
|
|
168
|
+
t.Fatal(err)
|
|
169
|
+
}
|
|
170
|
+
record, err := readRecord(c.StateDir, c.Owner)
|
|
171
|
+
if err != nil || record.Lifecycle.SubReason != want || record.Lifecycle.Phase != "stopped" {
|
|
172
|
+
t.Fatalf("completion lost disconnect detail: %+v %v", record, err)
|
|
173
|
+
}
|
|
174
|
+
if _, err = completionRecord(c, record); err != nil {
|
|
175
|
+
t.Fatal(err)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"errors"
|
|
6
|
+
"fmt"
|
|
7
|
+
"github.com/godbus/dbus/v5"
|
|
8
|
+
"time"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// Queries have no admission side effects. A reload edge may invalidate their
|
|
12
|
+
// transient result while the fixed verification budget continues to deny access.
|
|
13
|
+
type unitSnapshotError struct {
|
|
14
|
+
reason string
|
|
15
|
+
definitive bool
|
|
16
|
+
cause error
|
|
17
|
+
phase string
|
|
18
|
+
detail string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
func (e *unitSnapshotError) Error() string { return fmt.Sprintf("%s: %v", e.reason, e.cause) }
|
|
22
|
+
func (e *unitSnapshotError) Unwrap() error { return e.cause }
|
|
23
|
+
func (o *unitObserver) snapshot(ctx context.Context) (Binding, map[string]dbus.Variant, error) {
|
|
24
|
+
o.gate.recordObserver(observerEvent{Kind: "query-phase", Phase: "get-owner"})
|
|
25
|
+
var owner string
|
|
26
|
+
if err := o.conn.BusObject().CallWithContext(ctx, "org.freedesktop.DBus.GetNameOwner", 0, systemdName).Store(&owner); err != nil {
|
|
27
|
+
return Binding{}, nil, &unitSnapshotError{reason: "observation-unavailable", definitive: false, cause: err, phase: "get-owner", detail: "query-failed"}
|
|
28
|
+
}
|
|
29
|
+
if owner != o.owner {
|
|
30
|
+
return Binding{}, nil, &unitSnapshotError{reason: "bus-owner-changed", definitive: true, cause: errTrust, phase: "get-owner", detail: "owner-query-changed"}
|
|
31
|
+
}
|
|
32
|
+
o.gate.recordObserver(observerEvent{Kind: "query-phase", Phase: "get-unit"})
|
|
33
|
+
var path dbus.ObjectPath
|
|
34
|
+
if err := o.conn.Object(o.owner, "/org/freedesktop/systemd1").CallWithContext(ctx, managerInterface+".GetUnit", 0, o.unit).Store(&path); err != nil {
|
|
35
|
+
return Binding{}, nil, &unitSnapshotError{reason: "observation-unavailable", definitive: false, cause: err, phase: "get-unit", detail: "query-failed"}
|
|
36
|
+
}
|
|
37
|
+
if path != o.path {
|
|
38
|
+
return Binding{}, nil, &unitSnapshotError{reason: "observation-unavailable", definitive: true, cause: errTrust, phase: "get-unit", detail: "unit-path-changed"}
|
|
39
|
+
}
|
|
40
|
+
o.gate.recordObserver(observerEvent{Kind: "query-phase", Phase: "installed-binding"})
|
|
41
|
+
b, err := installedBinding(o.inventory)
|
|
42
|
+
if err != nil {
|
|
43
|
+
return Binding{}, nil, &unitSnapshotError{reason: "installation-changed", definitive: true, cause: err, phase: "installed-binding", detail: "installation-query-failed"}
|
|
44
|
+
}
|
|
45
|
+
o.gate.recordObserver(observerEvent{Kind: "query-phase", Phase: "get-all"})
|
|
46
|
+
var values map[string]dbus.Variant
|
|
47
|
+
if err := o.conn.Object(o.owner, o.path).CallWithContext(ctx, propertiesInterface+".GetAll", 0, unitInterface).Store(&values); err != nil {
|
|
48
|
+
return Binding{}, nil, &unitSnapshotError{reason: "observation-unavailable", definitive: false, cause: err, phase: "get-all", detail: "query-failed"}
|
|
49
|
+
}
|
|
50
|
+
return b, values, nil
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
func (o *unitObserver) reconcile(ctx context.Context) error {
|
|
54
|
+
return o.reconcileSnapshot(ctx, o.snapshot)
|
|
55
|
+
}
|
|
56
|
+
func (o *unitObserver) reconcileSnapshot(ctx context.Context, query func(context.Context) (Binding, map[string]dbus.Variant, error)) error {
|
|
57
|
+
serial, ready := o.gate.unitProbe(time.Now())
|
|
58
|
+
// Initial observation has no freshness baseline yet.
|
|
59
|
+
if !ready {
|
|
60
|
+
return nil
|
|
61
|
+
}
|
|
62
|
+
o.gate.recordObserver(observerEvent{Kind: "query-start", QuerySerial: serial})
|
|
63
|
+
b, values, err := query(ctx)
|
|
64
|
+
if err != nil {
|
|
65
|
+
reason, definitive := "observation-unavailable", false
|
|
66
|
+
e := observerEvent{Kind: "query-error", Detail: "query-failed", Phase: "snapshot", ErrorClass: observerErrorClass(err), QuerySerial: serial}
|
|
67
|
+
var failure *unitSnapshotError
|
|
68
|
+
if errors.As(err, &failure) {
|
|
69
|
+
reason, definitive = failure.reason, failure.definitive
|
|
70
|
+
e.Phase = failure.phase
|
|
71
|
+
if failure.detail != "" {
|
|
72
|
+
e.Detail = failure.detail
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
o.gate.recordObserver(e)
|
|
76
|
+
if o.gate.failUnitProbe(serial, reason, definitive, time.Now(), e) {
|
|
77
|
+
return err
|
|
78
|
+
}
|
|
79
|
+
return nil
|
|
80
|
+
}
|
|
81
|
+
return o.observeValues(b, values, serial, time.Now())
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
func (o *unitObserver) observeValues(b Binding, values map[string]dbus.Variant, serial uint64, now time.Time) error {
|
|
85
|
+
id, jobOK := jobID(values["Job"])
|
|
86
|
+
entered, enteredOK := values["ActiveEnterTimestampMonotonic"].Value().(uint64)
|
|
87
|
+
active := values["Id"].Value() == o.unit && values["LoadState"].Value() == "loaded" && values["ActiveState"].Value() == "active" && (values["SubState"].Value() == "running" || values["SubState"].Value() == "exited") && jobOK && id == 0 && enteredOK && entered > 0
|
|
88
|
+
invocation, present, valid := unitInvocation(values)
|
|
89
|
+
detail := ""
|
|
90
|
+
switch {
|
|
91
|
+
case values["Id"].Value() != o.unit:
|
|
92
|
+
detail = "snapshot-Id"
|
|
93
|
+
case values["LoadState"].Value() != "loaded":
|
|
94
|
+
detail = "snapshot-LoadState"
|
|
95
|
+
case values["ActiveState"].Value() != "active":
|
|
96
|
+
detail = "snapshot-ActiveState"
|
|
97
|
+
case values["SubState"].Value() != "running" && values["SubState"].Value() != "exited":
|
|
98
|
+
detail = "snapshot-SubState"
|
|
99
|
+
case !jobOK || id != 0:
|
|
100
|
+
detail = "snapshot-Job"
|
|
101
|
+
case !enteredOK || entered == 0:
|
|
102
|
+
detail = "snapshot-ActiveEnterTimestampMonotonic"
|
|
103
|
+
case !valid:
|
|
104
|
+
detail = "snapshot-InvocationID"
|
|
105
|
+
}
|
|
106
|
+
o.gate.observeUnit(b, entered, invocation, present, active && valid, serial, now, observerEvent{Detail: detail, Phase: "validate-values", QuerySerial: serial})
|
|
107
|
+
if reason := o.gate.reason(); reason != "" {
|
|
108
|
+
return fmt.Errorf("unit observation %s: %w", reason, errTrust)
|
|
109
|
+
}
|
|
110
|
+
return nil
|
|
111
|
+
}
|