@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,69 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"net"
|
|
7
|
+
"path/filepath"
|
|
8
|
+
"strings"
|
|
9
|
+
"testing"
|
|
10
|
+
"time"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
func TestLinuxSupervisorFrameWaitPreservesStopFence(t *testing.T) {
|
|
14
|
+
p := linuxFixture(t)
|
|
15
|
+
process := startVMHelper(t, p)
|
|
16
|
+
conn, err := net.Dial("unix", filepath.Join(p.RunDir, "supervisor.sock"))
|
|
17
|
+
if err != nil {
|
|
18
|
+
t.Fatal(err)
|
|
19
|
+
}
|
|
20
|
+
defer conn.Close()
|
|
21
|
+
time.Sleep(50 * time.Millisecond)
|
|
22
|
+
vmUnit(t, "stop")
|
|
23
|
+
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second)
|
|
24
|
+
defer cancel()
|
|
25
|
+
if err = waitHealthy(ctx, func(context.Context) bool {
|
|
26
|
+
r, e := readRecord(p.StateDir, 0)
|
|
27
|
+
return e == nil && r.Lifecycle.Phase == "stopped" && r.Lifecycle.Completion != ""
|
|
28
|
+
}); err != nil {
|
|
29
|
+
t.Fatal("stalled peer prevented owned fence/completion", err)
|
|
30
|
+
}
|
|
31
|
+
record, err := readRecord(p.StateDir, 0)
|
|
32
|
+
if err != nil {
|
|
33
|
+
t.Fatal(err)
|
|
34
|
+
}
|
|
35
|
+
proof, err := completionRecord(p.Client, record)
|
|
36
|
+
if err != nil || proof.Process != process {
|
|
37
|
+
t.Fatal("wrong completion", err)
|
|
38
|
+
}
|
|
39
|
+
t.Logf("stalled root peer lifecycle reason=%s", record.Lifecycle.Reason)
|
|
40
|
+
vmUnit(t, "start")
|
|
41
|
+
if p.Client.Status(context.Background()).State == "ready" {
|
|
42
|
+
t.Fatal("later active revived stopped epoch")
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
func TestLinuxSupervisorRejectsForeignFrameAfterWait(t *testing.T) {
|
|
47
|
+
p := linuxFixture(t)
|
|
48
|
+
process := startVMHelper(t, p)
|
|
49
|
+
conn, err := net.Dial("unix", filepath.Join(p.RunDir, "supervisor.sock"))
|
|
50
|
+
if err != nil {
|
|
51
|
+
t.Fatal(err)
|
|
52
|
+
}
|
|
53
|
+
defer conn.Close()
|
|
54
|
+
time.Sleep(150 * time.Millisecond)
|
|
55
|
+
foreign := process
|
|
56
|
+
foreign.Start = "foreign"
|
|
57
|
+
req := supervisorRequest{Process: foreign, Op: "admit", Nonce: strings.Repeat("a", 64)}
|
|
58
|
+
conn.SetDeadline(time.Now().Add(time.Second))
|
|
59
|
+
if err = json.NewEncoder(conn).Encode(req); err != nil {
|
|
60
|
+
t.Fatal(err)
|
|
61
|
+
}
|
|
62
|
+
var response Response
|
|
63
|
+
if err = json.NewDecoder(conn).Decode(&response); err == nil || response.OK {
|
|
64
|
+
t.Fatal("foreign Process frame accepted", response)
|
|
65
|
+
}
|
|
66
|
+
if p.Client.Status(context.Background()).State != "ready" {
|
|
67
|
+
t.Fatal("foreign frame changed valid epoch")
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"net"
|
|
6
|
+
"strings"
|
|
7
|
+
"testing"
|
|
8
|
+
"time"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
func TestSupervisorReceivePhases(t *testing.T) {
|
|
12
|
+
req := supervisorRequest{Op: "grants", Nonce: strings.Repeat("a", 64), Data: json.RawMessage(`{}`)}
|
|
13
|
+
frame, _ := json.Marshal(req)
|
|
14
|
+
for _, kind := range []string{"delayed-attestation", "late-attestation", "buffered-large", "empty-eof", "silent", "partial", "drip", "trailing", "oversize", "duplicate", "valid"} {
|
|
15
|
+
t.Run(kind, func(t *testing.T) {
|
|
16
|
+
server, client := supervisorSocketPair(t)
|
|
17
|
+
defer server.Close()
|
|
18
|
+
defer client.Close()
|
|
19
|
+
// Legacy server starts its receive clock before the caller's full hash.
|
|
20
|
+
if err := server.SetDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
|
|
21
|
+
t.Fatal(err)
|
|
22
|
+
}
|
|
23
|
+
done := make(chan struct{})
|
|
24
|
+
go func() {
|
|
25
|
+
defer close(done)
|
|
26
|
+
switch kind {
|
|
27
|
+
case "silent":
|
|
28
|
+
return
|
|
29
|
+
case "late-attestation":
|
|
30
|
+
time.Sleep(1100 * time.Millisecond)
|
|
31
|
+
client.Write(frame)
|
|
32
|
+
case "buffered-large":
|
|
33
|
+
large := req
|
|
34
|
+
large.Data = json.RawMessage(`{"padding":"` + strings.Repeat("a", 8192) + `"}`)
|
|
35
|
+
raw, _ := json.Marshal(large)
|
|
36
|
+
client.Write(raw)
|
|
37
|
+
case "empty-eof":
|
|
38
|
+
case "delayed-attestation":
|
|
39
|
+
time.Sleep(150 * time.Millisecond)
|
|
40
|
+
client.Write(frame)
|
|
41
|
+
case "partial":
|
|
42
|
+
client.Write([]byte("{"))
|
|
43
|
+
time.Sleep(200 * time.Millisecond)
|
|
44
|
+
case "drip":
|
|
45
|
+
for n := 0; n < 8; n++ {
|
|
46
|
+
if _, e := client.Write([]byte(" ")); e != nil {
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
time.Sleep(30 * time.Millisecond)
|
|
50
|
+
}
|
|
51
|
+
case "trailing":
|
|
52
|
+
client.Write(append(frame, []byte(`{}`)...))
|
|
53
|
+
case "oversize":
|
|
54
|
+
client.Write(append(frame, []byte(strings.Repeat(" ", MaxControlBytes))...))
|
|
55
|
+
case "duplicate":
|
|
56
|
+
client.Write([]byte(`{"op":"grants","op":"grants","nonce":"` + req.Nonce + `","data":{}}`))
|
|
57
|
+
default:
|
|
58
|
+
client.Write(frame)
|
|
59
|
+
}
|
|
60
|
+
client.CloseWrite()
|
|
61
|
+
}()
|
|
62
|
+
started := time.Now()
|
|
63
|
+
got, code := receiveSupervisorRequest(server)
|
|
64
|
+
elapsed := time.Since(started)
|
|
65
|
+
server.Close()
|
|
66
|
+
client.Close()
|
|
67
|
+
<-done
|
|
68
|
+
if kind == "valid" || kind == "delayed-attestation" || kind == "buffered-large" {
|
|
69
|
+
if code != "" || got.Nonce != req.Nonce {
|
|
70
|
+
t.Fatalf("valid delayed/buffered frame refused: %s", code)
|
|
71
|
+
}
|
|
72
|
+
} else if code == "" {
|
|
73
|
+
t.Fatal("invalid/stalled frame accepted")
|
|
74
|
+
}
|
|
75
|
+
if kind == "silent" && (elapsed < 900*time.Millisecond || elapsed > 1500*time.Millisecond) {
|
|
76
|
+
t.Fatalf("first-byte bound: %s", elapsed)
|
|
77
|
+
}
|
|
78
|
+
if (kind == "partial" || kind == "drip") && elapsed > 180*time.Millisecond {
|
|
79
|
+
t.Fatalf("frame deadline was extended: %s", elapsed)
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
func TestSupervisorFrameBudgetAlsoBoundsLegacyReply(t *testing.T) {
|
|
86
|
+
// Keep the synchronous pipe here: an unread small Unix socket reply fits in
|
|
87
|
+
// the kernel buffer and would not exercise the bounded blocked-write path.
|
|
88
|
+
server, client := net.Pipe()
|
|
89
|
+
defer server.Close()
|
|
90
|
+
defer client.Close()
|
|
91
|
+
// A watchdog protects the test if reply writes accidentally lose their bound.
|
|
92
|
+
server.SetWriteDeadline(time.Now().Add(2 * time.Second))
|
|
93
|
+
req := supervisorRequest{Op: "admit", Nonce: strings.Repeat("b", 64)}
|
|
94
|
+
frame, _ := json.Marshal(req)
|
|
95
|
+
sent := make(chan struct{})
|
|
96
|
+
go func() { defer close(sent); time.Sleep(150 * time.Millisecond); client.Write(frame) }()
|
|
97
|
+
if _, code := receiveSupervisorRequest(server); code != "" {
|
|
98
|
+
t.Fatal(code)
|
|
99
|
+
}
|
|
100
|
+
<-sent
|
|
101
|
+
started := time.Now()
|
|
102
|
+
_, err := server.Write([]byte(`{"ok":true}`))
|
|
103
|
+
elapsed := time.Since(started)
|
|
104
|
+
if e, ok := err.(net.Error); !ok || !e.Timeout() || elapsed < 70*time.Millisecond || elapsed > 350*time.Millisecond {
|
|
105
|
+
t.Fatalf("unbounded/expired legacy reply: %s %v", elapsed, err)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -6,7 +6,6 @@ import (
|
|
|
6
6
|
"encoding/hex"
|
|
7
7
|
"encoding/json"
|
|
8
8
|
"errors"
|
|
9
|
-
"io"
|
|
10
9
|
"net"
|
|
11
10
|
"os"
|
|
12
11
|
"os/exec"
|
|
@@ -57,21 +56,39 @@ func (c *ownedLinuxChild) signal(s syscall.Signal) error {
|
|
|
57
56
|
return syscall.Kill(c.process.Pid, s)
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
type supervisorRequest struct {
|
|
61
|
-
Process Process `json:"process"`
|
|
62
|
-
Op string `json:"op"`
|
|
63
|
-
Nonce string `json:"nonce"`
|
|
64
|
-
}
|
|
65
|
-
|
|
66
59
|
// The thread creating the child must remain alive: PDEATHSIG is tied to that
|
|
67
60
|
// Linux thread, not merely the supervisor's thread group / Go process.
|
|
68
61
|
func superviseLinux(c Client, binary string) error {
|
|
69
62
|
runtime.LockOSThread()
|
|
70
63
|
defer runtime.UnlockOSThread()
|
|
71
64
|
r, err := readRecord(c.StateDir, 0)
|
|
72
|
-
if err != nil || !r.Enabled || r.Inventory != c.Expected {
|
|
65
|
+
if err != nil || !r.Enabled || r.Inventory != c.Expected || r.Lifecycle == nil || r.Lifecycle.Phase != "running" {
|
|
66
|
+
return errTrust
|
|
67
|
+
}
|
|
68
|
+
lease, err := acquireLifetime(c, r.Lifecycle)
|
|
69
|
+
if err != nil {
|
|
70
|
+
return err
|
|
71
|
+
}
|
|
72
|
+
processLifetime = lease
|
|
73
|
+
// Recheck under the witness: repair may have fenced between the first
|
|
74
|
+
// approval read and lock acquisition. No child exists before this point.
|
|
75
|
+
current, err := readRecord(c.StateDir, 0)
|
|
76
|
+
if err != nil || !current.Enabled || current.Inventory != r.Inventory || current.Lifecycle == nil || current.Lifecycle.Epoch != r.Lifecycle.Epoch || current.Lifecycle.Phase != "running" {
|
|
77
|
+
return errTrust
|
|
78
|
+
}
|
|
79
|
+
o, err := openUnitObserver(context.Background(), c.Expected)
|
|
80
|
+
if err != nil {
|
|
81
|
+
return err
|
|
82
|
+
}
|
|
83
|
+
defer o.conn.Close()
|
|
84
|
+
if o.gate.binding != r.Lifecycle.Binding {
|
|
73
85
|
return errTrust
|
|
74
86
|
}
|
|
87
|
+
watcher, cancelWatcher := context.WithCancel(context.Background())
|
|
88
|
+
defer cancelWatcher()
|
|
89
|
+
go o.watch(watcher)
|
|
90
|
+
epoch := r.Lifecycle.Epoch
|
|
91
|
+
defer persistObserverDiagnostic(c, epoch, o.gate)
|
|
75
92
|
identity, err := inspectSupervisor(os.Getpid(), c.Expected)
|
|
76
93
|
if err != nil {
|
|
77
94
|
return err
|
|
@@ -90,6 +107,7 @@ func superviseLinux(c Client, binary string) error {
|
|
|
90
107
|
return err
|
|
91
108
|
}
|
|
92
109
|
cmd := exec.Command(binary, "serve-child")
|
|
110
|
+
cmd.ExtraFiles = []*os.File{lease}
|
|
93
111
|
cmd.Env = []string{"PATH=/usr/sbin:/usr/bin:/sbin:/bin", "SYNOPKGLAND_PARENT=" + strconv.Itoa(os.Getpid())}
|
|
94
112
|
// Go sets prctl before exec and rechecks the parent immediately afterward.
|
|
95
113
|
cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGKILL}
|
|
@@ -97,10 +115,114 @@ func superviseLinux(c Client, binary string) error {
|
|
|
97
115
|
return err
|
|
98
116
|
}
|
|
99
117
|
child := &ownedLinuxChild{process: cmd.Process}
|
|
118
|
+
cohort := newOperationCohort(c.Expected, epoch, child.process.Pid, o.gate, func() bool { return !child.reaped })
|
|
119
|
+
defer func() {
|
|
120
|
+
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
|
121
|
+
defer cancel()
|
|
122
|
+
_ = cohort.drain(ctx, time.Second)
|
|
123
|
+
_ = stopChild(ctx, child, time.Second)
|
|
124
|
+
}()
|
|
125
|
+
var grants *supervisorGrants
|
|
126
|
+
var grantRepo *FileGrantRepository
|
|
127
|
+
defer func() {
|
|
128
|
+
if grantRepo != nil {
|
|
129
|
+
grantRepo.Close()
|
|
130
|
+
}
|
|
131
|
+
}()
|
|
132
|
+
// M1 Start first observes the health handshake, then finalizeStart clears
|
|
133
|
+
// residual under policy.lock. Pin S3's COMPLETE approval only after that
|
|
134
|
+
// handoff; constructing against residual=true would permanently fence it.
|
|
135
|
+
initializeGrants := func() {
|
|
136
|
+
if c.Expected.Protocol != DataProtocol || grants != nil || !o.gate.allow(time.Now()) {
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
approval, e := readRecord(c.StateDir, 0)
|
|
140
|
+
if e != nil || !approval.Enabled || approval.Inventory != c.Expected || approval.Lifecycle == nil || approval.Lifecycle.Epoch != epoch || approval.Lifecycle.Phase != "running" {
|
|
141
|
+
o.gate.fence("grant-approval-unavailable")
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
if approval.Residual {
|
|
145
|
+
return
|
|
146
|
+
} // health-only handshake; no grant authority yet
|
|
147
|
+
var code Code
|
|
148
|
+
grants, grantRepo, code = openSupervisorGrants(c, binary, cohort)
|
|
149
|
+
if code != "" {
|
|
150
|
+
o.gate.fence("grant-authority-unavailable")
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
fenceRetryExhausted := false
|
|
100
154
|
// No cmd.Wait goroutine: reaping and signalling are serialized below.
|
|
101
155
|
for {
|
|
102
|
-
|
|
103
|
-
|
|
156
|
+
current, readErr := readRecord(c.StateDir, 0)
|
|
157
|
+
if readErr != nil || current.Lifecycle == nil || current.Lifecycle.Epoch != epoch {
|
|
158
|
+
o.gate.fence("approval-unavailable")
|
|
159
|
+
} else if !current.Enabled || current.Lifecycle.Phase != "running" {
|
|
160
|
+
o.gate.fence("admin-stop")
|
|
161
|
+
}
|
|
162
|
+
initializeGrants()
|
|
163
|
+
// Reload verification denies requests without retiring this epoch.
|
|
164
|
+
if o.gate.fenced(time.Now()) {
|
|
165
|
+
if grants != nil {
|
|
166
|
+
grants.authority.Fence()
|
|
167
|
+
}
|
|
168
|
+
cohort.deny()
|
|
169
|
+
// NB policy.lock keeps the owner loop and admin stop responsive. No
|
|
170
|
+
// graceful stop before the irreversible durable fence transaction.
|
|
171
|
+
err := errBusy
|
|
172
|
+
if !fenceRetryExhausted {
|
|
173
|
+
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
|
174
|
+
err = retryCohortPolicy(ctx, func() error {
|
|
175
|
+
return fenceRecord(c, epoch, o.gate.reason(), o.gate.observerDiagnostic(epoch).Fence.Detail)
|
|
176
|
+
})
|
|
177
|
+
cancel()
|
|
178
|
+
}
|
|
179
|
+
if err == nil {
|
|
180
|
+
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
|
181
|
+
err = cohort.drain(ctx, time.Second)
|
|
182
|
+
if err == nil {
|
|
183
|
+
err = stopChild(ctx, child, time.Second)
|
|
184
|
+
}
|
|
185
|
+
cancel()
|
|
186
|
+
if err != nil {
|
|
187
|
+
return err
|
|
188
|
+
}
|
|
189
|
+
if err = l.Close(); err != nil {
|
|
190
|
+
return err
|
|
191
|
+
}
|
|
192
|
+
p, e := readProcess(c.RunDir, 0)
|
|
193
|
+
if e != nil || p != identity {
|
|
194
|
+
return errTrust
|
|
195
|
+
}
|
|
196
|
+
if err = cleanRuntime(c, true); err != nil {
|
|
197
|
+
return err
|
|
198
|
+
}
|
|
199
|
+
q, err := cohort.proof()
|
|
200
|
+
if err != nil {
|
|
201
|
+
return err
|
|
202
|
+
}
|
|
203
|
+
// Completion is quiescence proof, published after close/reap/unlink.
|
|
204
|
+
ctx, cancel = context.WithTimeout(context.Background(), time.Second)
|
|
205
|
+
defer cancel()
|
|
206
|
+
return retryCohortPolicy(ctx, func() error { return completeRecord(c, epoch, identity, q) })
|
|
207
|
+
}
|
|
208
|
+
if !errors.Is(err, errBusy) {
|
|
209
|
+
return err
|
|
210
|
+
}
|
|
211
|
+
// Budget expiry parks the fenced owner, retaining the lifetime
|
|
212
|
+
// witness. Do not exit (PDEATHSIG), poll/signal canceled children,
|
|
213
|
+
// or restart automatic retries. An explicit root stop retries below.
|
|
214
|
+
fenceRetryExhausted = true
|
|
215
|
+
}
|
|
216
|
+
if !fenceRetryExhausted {
|
|
217
|
+
if err := cohort.poll(); err != nil {
|
|
218
|
+
return err
|
|
219
|
+
}
|
|
220
|
+
if done, err := child.exited(); err != nil {
|
|
221
|
+
return err
|
|
222
|
+
} else if done && cohort.started > 0 {
|
|
223
|
+
o.gate.fence("helper-exited")
|
|
224
|
+
continue
|
|
225
|
+
}
|
|
104
226
|
}
|
|
105
227
|
l.SetDeadline(time.Now().Add(20 * time.Millisecond))
|
|
106
228
|
conn, err := l.AcceptUnix()
|
|
@@ -110,21 +232,70 @@ func superviseLinux(c Client, binary string) error {
|
|
|
110
232
|
}
|
|
111
233
|
return err
|
|
112
234
|
}
|
|
113
|
-
conn.SetDeadline(time.Now().Add(3 * time.Second))
|
|
114
235
|
peer, err := peerCredentials(conn)
|
|
115
236
|
if err != nil || peer.Uid != 0 {
|
|
116
237
|
conn.Close()
|
|
117
238
|
continue
|
|
118
239
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
240
|
+
req, code := receiveSupervisorRequest(conn)
|
|
241
|
+
if code != "" || req.Process != identity {
|
|
242
|
+
conn.Close()
|
|
243
|
+
continue
|
|
244
|
+
}
|
|
245
|
+
if req.Op == "grants" {
|
|
246
|
+
initializeGrants()
|
|
247
|
+
conn.SetDeadline(time.Now().Add(3 * time.Second))
|
|
248
|
+
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
|
249
|
+
res := dispatchSupervisorGrant(ctx, grants, operationPeer{int(peer.Pid), peer.Uid}, req)
|
|
250
|
+
cancel()
|
|
251
|
+
json.NewEncoder(conn).Encode(res)
|
|
123
252
|
conn.Close()
|
|
253
|
+
if grants != nil {
|
|
254
|
+
grants.authority.mu.Lock()
|
|
255
|
+
fenced := grants.authority.fenced
|
|
256
|
+
grants.authority.mu.Unlock()
|
|
257
|
+
if fenced {
|
|
258
|
+
o.gate.fence("grant-authority-fenced")
|
|
259
|
+
}
|
|
260
|
+
}
|
|
124
261
|
continue
|
|
125
262
|
}
|
|
263
|
+
if req.Op == "admit" {
|
|
264
|
+
current, e := readRecord(c.StateDir, 0)
|
|
265
|
+
allowed := e == nil && current.Enabled && current.Inventory == c.Expected && current.Lifecycle != nil && current.Lifecycle.Epoch == epoch && current.Lifecycle.Phase == "running" && !child.reaped && int(peer.Pid) == child.process.Pid
|
|
266
|
+
readiness := "fenced"
|
|
267
|
+
if allowed {
|
|
268
|
+
readiness = o.gate.readiness(time.Now())
|
|
269
|
+
}
|
|
270
|
+
res := Response{Inventory: c.Expected, Nonce: req.Nonce, OK: readiness == "ready"}
|
|
271
|
+
if !res.OK {
|
|
272
|
+
res.Error = readiness
|
|
273
|
+
}
|
|
274
|
+
json.NewEncoder(conn).Encode(res)
|
|
275
|
+
conn.Close()
|
|
276
|
+
continue
|
|
277
|
+
}
|
|
278
|
+
conn.SetDeadline(time.Now().Add(3 * time.Second))
|
|
126
279
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
|
127
|
-
err =
|
|
280
|
+
err = nil
|
|
281
|
+
if c.Expected.Protocol == DataProtocol || cohort.started > 0 || fenceRetryExhausted {
|
|
282
|
+
if grants != nil {
|
|
283
|
+
grants.authority.Fence()
|
|
284
|
+
}
|
|
285
|
+
cohort.deny()
|
|
286
|
+
fenceCtx, fenceCancel := context.WithTimeout(ctx, time.Second)
|
|
287
|
+
err = retryCohortPolicy(fenceCtx, func() error { return fenceRecord(c, epoch, "admin-stop") })
|
|
288
|
+
fenceCancel()
|
|
289
|
+
}
|
|
290
|
+
if err == nil {
|
|
291
|
+
err = cohort.drain(ctx, time.Second)
|
|
292
|
+
}
|
|
293
|
+
if err == nil {
|
|
294
|
+
err = stopChild(ctx, child, time.Second)
|
|
295
|
+
}
|
|
296
|
+
if err == nil {
|
|
297
|
+
_, err = cohort.proof()
|
|
298
|
+
}
|
|
128
299
|
cancel()
|
|
129
300
|
// Kernel process-exit fd cleanup is not ordered: close the listener
|
|
130
301
|
// before ACK, so connection EOF cannot race a still-listening socket.
|