@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,105 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"errors"
|
|
6
|
+
"os"
|
|
7
|
+
"path/filepath"
|
|
8
|
+
"strings"
|
|
9
|
+
"syscall"
|
|
10
|
+
"testing"
|
|
11
|
+
"time"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
func TestCohortPolicyRetryBusyOnlyAndBounded(t *testing.T) {
|
|
15
|
+
calls := 0
|
|
16
|
+
ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)
|
|
17
|
+
defer cancel()
|
|
18
|
+
begin := time.Now()
|
|
19
|
+
if err := retryCohortPolicy(ctx, func() error { calls++; return errBusy }); !errors.Is(err, errBusy) {
|
|
20
|
+
t.Fatal(err)
|
|
21
|
+
}
|
|
22
|
+
if calls < 2 || time.Since(begin) > time.Second {
|
|
23
|
+
t.Fatal("unbounded or missing busy retry", calls)
|
|
24
|
+
}
|
|
25
|
+
calls = 0
|
|
26
|
+
if err := retryCohortPolicy(context.Background(), func() error { calls++; return errTrust }); !errors.Is(err, errTrust) || calls != 1 {
|
|
27
|
+
t.Fatal("nonbusy refusal retried", err, calls)
|
|
28
|
+
}
|
|
29
|
+
calls = 0
|
|
30
|
+
if err := retryCohortPolicy(context.Background(), func() error {
|
|
31
|
+
calls++
|
|
32
|
+
if calls == 1 {
|
|
33
|
+
return errBusy
|
|
34
|
+
}
|
|
35
|
+
return nil
|
|
36
|
+
}); err != nil || calls != 2 {
|
|
37
|
+
t.Fatal(err, calls)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
func TestCohortFenceRetryRevalidatesUnderPolicyLock(t *testing.T) {
|
|
41
|
+
for _, change := range []string{"release", "epoch", "inventory", "stopped"} {
|
|
42
|
+
t.Run(change, func(t *testing.T) {
|
|
43
|
+
c, _ := controlFixture(t)
|
|
44
|
+
before, _ := readRecord(c.StateDir, c.Owner)
|
|
45
|
+
lock, err := os.OpenFile(filepath.Join(c.StateDir, "policy.lock"), os.O_CREATE|os.O_RDWR, 0600)
|
|
46
|
+
if err != nil {
|
|
47
|
+
t.Fatal(err)
|
|
48
|
+
}
|
|
49
|
+
defer lock.Close()
|
|
50
|
+
if err := syscall.Flock(int(lock.Fd()), syscall.LOCK_EX); err != nil {
|
|
51
|
+
t.Fatal(err)
|
|
52
|
+
}
|
|
53
|
+
attempted := make(chan struct{})
|
|
54
|
+
result := make(chan error, 1)
|
|
55
|
+
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
|
56
|
+
defer cancel()
|
|
57
|
+
go func() {
|
|
58
|
+
once := false
|
|
59
|
+
result <- retryCohortPolicy(ctx, func() error {
|
|
60
|
+
err := fenceRecord(c.Client, before.Lifecycle.Epoch, "unit-stopped")
|
|
61
|
+
if !once {
|
|
62
|
+
once = true
|
|
63
|
+
close(attempted)
|
|
64
|
+
}
|
|
65
|
+
return err
|
|
66
|
+
})
|
|
67
|
+
}()
|
|
68
|
+
<-attempted
|
|
69
|
+
r, _ := readRecord(c.StateDir, c.Owner)
|
|
70
|
+
switch change {
|
|
71
|
+
case "epoch":
|
|
72
|
+
r.Lifecycle.Epoch = strings.Repeat("e", 64)
|
|
73
|
+
case "inventory":
|
|
74
|
+
r.Inventory.Version = "9.0.0-0001"
|
|
75
|
+
case "stopped":
|
|
76
|
+
r.Lifecycle.Phase = "stopped"
|
|
77
|
+
}
|
|
78
|
+
if err := writeProtected(c.StateDir, "approval.json", r); err != nil {
|
|
79
|
+
t.Fatal(err)
|
|
80
|
+
}
|
|
81
|
+
saved, _ := os.ReadFile(filepath.Join(c.StateDir, "approval.json"))
|
|
82
|
+
if err := syscall.Flock(int(lock.Fd()), syscall.LOCK_UN); err != nil {
|
|
83
|
+
t.Fatal(err)
|
|
84
|
+
}
|
|
85
|
+
err = <-result
|
|
86
|
+
if change == "release" {
|
|
87
|
+
if err != nil {
|
|
88
|
+
t.Fatal(err)
|
|
89
|
+
}
|
|
90
|
+
current, _ := readRecord(c.StateDir, c.Owner)
|
|
91
|
+
if current.Lifecycle.Phase != "fenced" {
|
|
92
|
+
t.Fatal(current)
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
if !errors.Is(err, errTrust) {
|
|
96
|
+
t.Fatal("changed authority retried/accepted", err)
|
|
97
|
+
}
|
|
98
|
+
after, _ := os.ReadFile(filepath.Join(c.StateDir, "approval.json"))
|
|
99
|
+
if string(after) != string(saved) {
|
|
100
|
+
t.Fatal("changed authority overwritten")
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"fmt"
|
|
6
|
+
"strings"
|
|
7
|
+
"syscall"
|
|
8
|
+
"testing"
|
|
9
|
+
"time"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
type operationFixture struct {
|
|
13
|
+
childFixture
|
|
14
|
+
stopped bool
|
|
15
|
+
pending bool
|
|
16
|
+
stuck bool
|
|
17
|
+
leases int
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
func (f *operationFixture) chunk(n uint32) error { f.pending = true; f.leases++; return nil }
|
|
21
|
+
func (f *operationFixture) idle() (bool, error) { return !f.pending, nil }
|
|
22
|
+
func (f *operationFixture) stopRelay() {
|
|
23
|
+
f.stopped = true
|
|
24
|
+
if !f.stuck {
|
|
25
|
+
f.pending = false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
func (f *operationFixture) relayStopped() bool { return f.stopped && !f.pending }
|
|
29
|
+
|
|
30
|
+
func cohortFixture(t *testing.T) (*operationCohort, *NativeProvider, SessionCarriers, NativeActor, operationBinding, *[]*operationFixture) {
|
|
31
|
+
t.Helper()
|
|
32
|
+
p, _, _, carrier, now := nativeFixture()
|
|
33
|
+
actor, code := p.Resolve(context.Background(), carrier)
|
|
34
|
+
if code != "" {
|
|
35
|
+
t.Fatal(code)
|
|
36
|
+
}
|
|
37
|
+
i := Inventory{Package: "Fixture", Version: "1.0.0-0001", Protocol: 2, PayloadDigest: strings.Repeat("d", 64), RegistryDigest: strings.Repeat("e", 64)}
|
|
38
|
+
gate := newAdmission(Binding{Boot: "boot", Install: "install"})
|
|
39
|
+
gate.observe(gate.binding, 1, true, now)
|
|
40
|
+
children := new([]*operationFixture)
|
|
41
|
+
c := newOperationCohort(i, strings.Repeat("f", 64), 42, gate, func() bool { return true })
|
|
42
|
+
c.now = func() time.Time { return now }
|
|
43
|
+
c.startChild = func(a NativeActor, b operationBinding) (operationProcess, error) {
|
|
44
|
+
f := &operationFixture{childFixture: childFixture{exitOn: syscall.SIGTERM}}
|
|
45
|
+
*children = append(*children, f)
|
|
46
|
+
return f, nil
|
|
47
|
+
}
|
|
48
|
+
b := operationBinding{Inventory: i, Epoch: c.epoch, OperationID: fmt.Sprintf("%064x", 1), Nonce: fmt.Sprintf("%064x", 2), GrantID: strings.Repeat("1", 64), GrantRevision: 1}
|
|
49
|
+
return c, p, carrier, actor, b, children
|
|
50
|
+
}
|
|
51
|
+
func TestCohortPeerBindingActorReplayAndLimits(t *testing.T) {
|
|
52
|
+
for _, name := range []string{"peer", "uid", "inventory", "epoch", "zero-actor", "expired-actor", "root", "groups", "nonce", "revision"} {
|
|
53
|
+
t.Run(name, func(t *testing.T) {
|
|
54
|
+
c, p, carrier, a, b, children := cohortFixture(t)
|
|
55
|
+
peer := operationPeer{PID: 42, UID: 0}
|
|
56
|
+
switch name {
|
|
57
|
+
case "peer":
|
|
58
|
+
peer.PID = 43
|
|
59
|
+
case "uid":
|
|
60
|
+
peer.UID = 1
|
|
61
|
+
case "inventory":
|
|
62
|
+
b.Inventory.RegistryDigest = strings.Repeat("0", 64)
|
|
63
|
+
case "epoch":
|
|
64
|
+
b.Epoch = strings.Repeat("0", 64)
|
|
65
|
+
case "zero-actor":
|
|
66
|
+
a = NativeActor{}
|
|
67
|
+
case "expired-actor":
|
|
68
|
+
p.now = func() time.Time { return c.now().Add(3 * time.Second) }
|
|
69
|
+
case "root":
|
|
70
|
+
a.account.UID = 0
|
|
71
|
+
case "groups":
|
|
72
|
+
a.account.Groups = nil
|
|
73
|
+
case "nonce":
|
|
74
|
+
b.Nonce = "bad"
|
|
75
|
+
case "revision":
|
|
76
|
+
b.GrantRevision = 0
|
|
77
|
+
}
|
|
78
|
+
if c.start(context.Background(), peer, p, carrier, a, b) == "" || len(*children) != 0 {
|
|
79
|
+
t.Fatal("invalid work started")
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
c, p, carrier, a, b, children := cohortFixture(t)
|
|
84
|
+
if code := c.start(context.Background(), operationPeer{42, 0}, p, carrier, a, b); code != "" {
|
|
85
|
+
t.Fatal(code)
|
|
86
|
+
}
|
|
87
|
+
if code := c.start(context.Background(), operationPeer{42, 0}, p, carrier, a, b); code != ErrReplay {
|
|
88
|
+
t.Fatal(code)
|
|
89
|
+
}
|
|
90
|
+
b.OperationID = fmt.Sprintf("%064x", 3)
|
|
91
|
+
b.Nonce = fmt.Sprintf("%064x", 4)
|
|
92
|
+
if code := c.start(context.Background(), operationPeer{42, 0}, p, carrier, a, b); code != "" {
|
|
93
|
+
t.Fatal(code)
|
|
94
|
+
}
|
|
95
|
+
b.OperationID = fmt.Sprintf("%064x", 5)
|
|
96
|
+
b.Nonce = fmt.Sprintf("%064x", 6)
|
|
97
|
+
if code := c.start(context.Background(), operationPeer{42, 0}, p, carrier, a, b); code != ErrBusy || len(*children) != 2 {
|
|
98
|
+
t.Fatal(code)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
func TestCohortChunkFenceAndCompletion(t *testing.T) {
|
|
102
|
+
c, p, carrier, a, b, children := cohortFixture(t)
|
|
103
|
+
peer := operationPeer{42, 0}
|
|
104
|
+
if code := c.start(context.Background(), peer, p, carrier, a, b); code != "" {
|
|
105
|
+
t.Fatal(code)
|
|
106
|
+
}
|
|
107
|
+
if _, err := c.proof(); err == nil {
|
|
108
|
+
t.Fatal("live cohort completed")
|
|
109
|
+
}
|
|
110
|
+
if code := c.chunk(context.Background(), peer, p, carrier, b, MaxChunkBytes); code != "" {
|
|
111
|
+
t.Fatal(code)
|
|
112
|
+
}
|
|
113
|
+
if code := c.chunk(context.Background(), peer, p, carrier, b, 1); code != ErrBusy {
|
|
114
|
+
t.Fatal(code)
|
|
115
|
+
}
|
|
116
|
+
c.gate.fence("fixture")
|
|
117
|
+
if code := c.chunk(context.Background(), peer, p, carrier, b, 1); code != ErrFenced {
|
|
118
|
+
t.Fatal(code)
|
|
119
|
+
}
|
|
120
|
+
if len((*children)[0].signals) != 0 {
|
|
121
|
+
t.Fatal("signal preceded durable fence/drain")
|
|
122
|
+
}
|
|
123
|
+
if err := c.drain(context.Background(), time.Millisecond); err != nil {
|
|
124
|
+
t.Fatal(err)
|
|
125
|
+
}
|
|
126
|
+
q, err := c.proof()
|
|
127
|
+
if err != nil || q.Started != 1 || q.Reaped != 1 || !q.RelaysStopped {
|
|
128
|
+
t.Fatal(q, err)
|
|
129
|
+
}
|
|
130
|
+
if !(*children)[0].stopped {
|
|
131
|
+
t.Fatal("relay survived")
|
|
132
|
+
}
|
|
133
|
+
if code := c.start(context.Background(), peer, p, carrier, a, b); code != ErrFenced {
|
|
134
|
+
t.Fatal(code)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
func TestCohortUnknownReapAndBlockedRelayNeverComplete(t *testing.T) {
|
|
138
|
+
for _, kind := range []string{"ECHILD", "relay"} {
|
|
139
|
+
t.Run(kind, func(t *testing.T) {
|
|
140
|
+
c, p, carrier, a, b, children := cohortFixture(t)
|
|
141
|
+
if code := c.start(context.Background(), operationPeer{42, 0}, p, carrier, a, b); code != "" {
|
|
142
|
+
t.Fatal(code)
|
|
143
|
+
}
|
|
144
|
+
f := (*children)[0]
|
|
145
|
+
if kind == "ECHILD" {
|
|
146
|
+
f.err = syscall.ECHILD
|
|
147
|
+
} else {
|
|
148
|
+
f.stuck = true
|
|
149
|
+
f.pending = true
|
|
150
|
+
}
|
|
151
|
+
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Millisecond)
|
|
152
|
+
defer cancel()
|
|
153
|
+
if c.drain(ctx, time.Millisecond) == nil {
|
|
154
|
+
t.Fatal("unknown quiescence accepted")
|
|
155
|
+
}
|
|
156
|
+
if _, err := c.proof(); err == nil {
|
|
157
|
+
t.Fatal("invalid proof")
|
|
158
|
+
}
|
|
159
|
+
if kind == "ECHILD" && len(f.signals) != 0 {
|
|
160
|
+
t.Fatal("foreign child signalled")
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
func TestCohortRevalidationCancelsWithoutGrantRollback(t *testing.T) {
|
|
166
|
+
c, p, carrier, a, b, children := cohortFixture(t)
|
|
167
|
+
peer := operationPeer{42, 0}
|
|
168
|
+
if code := c.start(context.Background(), peer, p, carrier, a, b); code != "" {
|
|
169
|
+
t.Fatal(code)
|
|
170
|
+
}
|
|
171
|
+
p.accounts.(*fakeLocalAccount).value.Groups = []uint32{999}
|
|
172
|
+
if code := c.chunk(context.Background(), peer, p, carrier, b, 1); code != ErrStale {
|
|
173
|
+
t.Fatal(code)
|
|
174
|
+
}
|
|
175
|
+
if !(*children)[0].stopped {
|
|
176
|
+
t.Fatal("invalid identity left relay live")
|
|
177
|
+
}
|
|
178
|
+
if code := c.chunk(context.Background(), peer, p, carrier, b, 1); code != ErrCanceled {
|
|
179
|
+
t.Fatal(code)
|
|
180
|
+
}
|
|
181
|
+
if c.drain(context.Background(), time.Millisecond) != nil {
|
|
182
|
+
t.Fatal("drain failed")
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
func TestCohortPackageLimitGrantDrainAndReplayRetention(t *testing.T) {
|
|
187
|
+
c, p, carrier, a, b, children := cohortFixture(t)
|
|
188
|
+
peer := operationPeer{42, 0}
|
|
189
|
+
bindings := []operationBinding{}
|
|
190
|
+
for n := 0; n < 4; n++ {
|
|
191
|
+
subject := fmt.Sprintf("%064x", 100+n/2)
|
|
192
|
+
p.accounts.(*fakeLocalAccount).value.Principal.SubjectRef = subject
|
|
193
|
+
a, code := p.Resolve(context.Background(), carrier)
|
|
194
|
+
if code != "" {
|
|
195
|
+
t.Fatal(code)
|
|
196
|
+
}
|
|
197
|
+
b.OperationID = fmt.Sprintf("%064x", 10+n)
|
|
198
|
+
b.Nonce = fmt.Sprintf("%064x", 20+n)
|
|
199
|
+
b.GrantID = fmt.Sprintf("%064x", 30+n/2)
|
|
200
|
+
if code := c.start(context.Background(), peer, p, carrier, a, b); code != "" {
|
|
201
|
+
t.Fatal(code)
|
|
202
|
+
}
|
|
203
|
+
bindings = append(bindings, b)
|
|
204
|
+
}
|
|
205
|
+
p.accounts.(*fakeLocalAccount).value.Principal.SubjectRef = fmt.Sprintf("%064x", 500)
|
|
206
|
+
a, code := p.Resolve(context.Background(), carrier)
|
|
207
|
+
if code != "" {
|
|
208
|
+
t.Fatal(code)
|
|
209
|
+
}
|
|
210
|
+
b.OperationID = fmt.Sprintf("%064x", 99)
|
|
211
|
+
b.Nonce = fmt.Sprintf("%064x", 98)
|
|
212
|
+
if code := c.start(context.Background(), peer, p, carrier, a, b); code != ErrBusy {
|
|
213
|
+
t.Fatal(code)
|
|
214
|
+
}
|
|
215
|
+
if err := c.cancelGrant(context.Background(), bindings[0].GrantID, 1); err != nil {
|
|
216
|
+
t.Fatal(err)
|
|
217
|
+
}
|
|
218
|
+
if len(c.operations) != 2 || !(*children)[0].reaped || !(*children)[1].reaped || (*children)[2].stopped {
|
|
219
|
+
t.Fatal("per-grant drain affected wrong cohort")
|
|
220
|
+
}
|
|
221
|
+
// A completed ID remains burned even when slots become available.
|
|
222
|
+
if code := c.start(context.Background(), peer, p, carrier, a, bindings[0]); code != ErrReplay {
|
|
223
|
+
t.Fatal(code)
|
|
224
|
+
}
|
|
225
|
+
if err := c.drain(context.Background(), time.Millisecond); err != nil {
|
|
226
|
+
t.Fatal(err)
|
|
227
|
+
}
|
|
228
|
+
q, err := c.proof()
|
|
229
|
+
if err != nil || q.Reaped != 4 {
|
|
230
|
+
t.Fatal(q, err)
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
func TestCohortChunkBoundsAndForeignBinding(t *testing.T) {
|
|
234
|
+
for _, kind := range []string{"zero", "large", "total", "foreign", "helper-dead"} {
|
|
235
|
+
t.Run(kind, func(t *testing.T) {
|
|
236
|
+
c, p, carrier, a, b, _ := cohortFixture(t)
|
|
237
|
+
peer := operationPeer{42, 0}
|
|
238
|
+
if code := c.start(context.Background(), peer, p, carrier, a, b); code != "" {
|
|
239
|
+
t.Fatal(code)
|
|
240
|
+
}
|
|
241
|
+
n := uint32(1)
|
|
242
|
+
want := ErrLimit
|
|
243
|
+
switch kind {
|
|
244
|
+
case "zero":
|
|
245
|
+
n = 0
|
|
246
|
+
case "large":
|
|
247
|
+
n = MaxChunkBytes + 1
|
|
248
|
+
case "total":
|
|
249
|
+
c.operations[b.OperationID].bytes = MaxBoundedBytes
|
|
250
|
+
case "foreign":
|
|
251
|
+
b.GrantRevision++
|
|
252
|
+
want = ErrDenied
|
|
253
|
+
case "helper-dead":
|
|
254
|
+
c.helperLive = func() bool { return false }
|
|
255
|
+
want = ErrDenied
|
|
256
|
+
}
|
|
257
|
+
if code := c.chunk(context.Background(), peer, p, carrier, b, n); code != want {
|
|
258
|
+
t.Fatal(code)
|
|
259
|
+
}
|
|
260
|
+
})
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
func TestCohortAdmissionOrdersObserverFence(t *testing.T) {
|
|
264
|
+
c, p, carrier, a, b, _ := cohortFixture(t)
|
|
265
|
+
// Fence delivered during native lookup must win before spawn.
|
|
266
|
+
p.accounts.(*fakeLocalAccount).after = func() { c.gate.fence("native-race") }
|
|
267
|
+
if code := c.start(context.Background(), operationPeer{42, 0}, p, carrier, a, b); code != ErrFenced {
|
|
268
|
+
t.Fatal(code)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
func TestCohortExpiredOperationStopsRelay(t *testing.T) {
|
|
273
|
+
c, p, carrier, a, b, children := cohortFixture(t)
|
|
274
|
+
peer := operationPeer{42, 0}
|
|
275
|
+
if code := c.start(context.Background(), peer, p, carrier, a, b); code != "" {
|
|
276
|
+
t.Fatal(code)
|
|
277
|
+
}
|
|
278
|
+
c.operations[b.OperationID].admittedAt = c.now().Add(-BoundedTimeout)
|
|
279
|
+
if code := c.chunk(context.Background(), peer, p, carrier, b, 1); code != ErrTimeout || !(*children)[0].stopped {
|
|
280
|
+
t.Fatal(code)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
func TestCohortReplayWindowFullDoesNotEvict(t *testing.T) {
|
|
284
|
+
c, p, carrier, a, b, _ := cohortFixture(t)
|
|
285
|
+
for n := 0; n < MaxReplayEntries; n++ {
|
|
286
|
+
c.seen[fmt.Sprintf("op:%064x", n+1000)] = true
|
|
287
|
+
c.seen[fmt.Sprintf("nonce:%064x", n+2000)] = true
|
|
288
|
+
}
|
|
289
|
+
if code := c.start(context.Background(), operationPeer{42, 0}, p, carrier, a, b); code != ErrBusy {
|
|
290
|
+
t.Fatal(code)
|
|
291
|
+
}
|
|
292
|
+
if len(c.seen) != 2*MaxReplayEntries {
|
|
293
|
+
t.Fatal("replay history evicted")
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
func TestCohortPartialBootstrapRetainsChildUntilReaped(t *testing.T) {
|
|
297
|
+
c, p, carrier, a, b, children := cohortFixture(t)
|
|
298
|
+
factory := c.startChild
|
|
299
|
+
c.startChild = func(a NativeActor, b operationBinding) (operationProcess, error) {
|
|
300
|
+
child, _ := factory(a, b)
|
|
301
|
+
return child, ErrDenied
|
|
302
|
+
}
|
|
303
|
+
if code := c.start(context.Background(), operationPeer{42, 0}, p, carrier, a, b); code != ErrCleanupRequired {
|
|
304
|
+
t.Fatal(code)
|
|
305
|
+
}
|
|
306
|
+
if len(c.operations) != 1 || !(*children)[0].stopped {
|
|
307
|
+
t.Fatal("partial child lost")
|
|
308
|
+
}
|
|
309
|
+
if _, err := c.proof(); err == nil {
|
|
310
|
+
t.Fatal("unreaped child completed")
|
|
311
|
+
}
|
|
312
|
+
if c.drain(context.Background(), time.Millisecond) != nil {
|
|
313
|
+
t.Fatal("drain failed")
|
|
314
|
+
}
|
|
315
|
+
q, err := c.proof()
|
|
316
|
+
if err != nil || q.Reaped != 1 {
|
|
317
|
+
t.Fatal(q, err)
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
func TestCohortCompletionArtifactRejectsIncompleteProof(t *testing.T) {
|
|
322
|
+
for _, q := range []CohortCompletion{{Started: 2, Reaped: 1, RelaysStopped: true}, {Started: 2, Reaped: 2}, {Started: 0, Reaped: 0, RelaysStopped: true}, {Started: MaxReplayEntries + 1, Reaped: MaxReplayEntries + 1, RelaysStopped: true}} {
|
|
323
|
+
c, f := controlFixture(t)
|
|
324
|
+
r := Record{Inventory: c.Expected, Enabled: true, Lifecycle: testLifecycle("fenced")}
|
|
325
|
+
record(t, c.Client, r)
|
|
326
|
+
if err := cleanRuntime(c.Client, true); err != nil {
|
|
327
|
+
t.Fatal(err)
|
|
328
|
+
}
|
|
329
|
+
if completeRecord(c.Client, r.Lifecycle.Epoch, f.current, &q) == nil {
|
|
330
|
+
t.Fatal("invalid cohort completed", q)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
func TestCohortCompletionArtifactRoundTrip(t *testing.T) {
|
|
336
|
+
c, f := controlFixture(t)
|
|
337
|
+
r := Record{Inventory: c.Expected, Enabled: true, Lifecycle: testLifecycle("fenced")}
|
|
338
|
+
record(t, c.Client, r)
|
|
339
|
+
if err := cleanRuntime(c.Client, true); err != nil {
|
|
340
|
+
t.Fatal(err)
|
|
341
|
+
}
|
|
342
|
+
q := CohortCompletion{Started: 2, Reaped: 2, RelaysStopped: true}
|
|
343
|
+
if err := completeRecord(c.Client, r.Lifecycle.Epoch, f.current, &q); err != nil {
|
|
344
|
+
t.Fatal(err)
|
|
345
|
+
}
|
|
346
|
+
current, err := readRecord(c.StateDir, c.Owner)
|
|
347
|
+
if err != nil {
|
|
348
|
+
t.Fatal(err)
|
|
349
|
+
}
|
|
350
|
+
proof, err := completionRecord(c.Client, current)
|
|
351
|
+
if err != nil || proof.Cohort == nil || *proof.Cohort != q {
|
|
352
|
+
t.Fatal(proof, err)
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
func TestCohortIdleOperationDeadlineCancelsBeforeNewLease(t *testing.T) {
|
|
357
|
+
c, p, carrier, a, b, children := cohortFixture(t)
|
|
358
|
+
if code := c.start(context.Background(), operationPeer{42, 0}, p, carrier, a, b); code != "" {
|
|
359
|
+
t.Fatal(code)
|
|
360
|
+
}
|
|
361
|
+
admitted := c.now()
|
|
362
|
+
c.now = func() time.Time { return admitted.Add(BoundedTimeout) }
|
|
363
|
+
if err := c.poll(); err != nil {
|
|
364
|
+
t.Fatal(err)
|
|
365
|
+
}
|
|
366
|
+
if !(*children)[0].stopped || len((*children)[0].signals) == 0 {
|
|
367
|
+
t.Fatal("idle operation survived deadline")
|
|
368
|
+
}
|
|
369
|
+
if _, err := c.proof(); err == nil {
|
|
370
|
+
t.Fatal("signal is not quiescence")
|
|
371
|
+
}
|
|
372
|
+
}
|