@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,273 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"crypto/rand"
|
|
6
|
+
"encoding/hex"
|
|
7
|
+
"io"
|
|
8
|
+
"net"
|
|
9
|
+
"slices"
|
|
10
|
+
"time"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
func validDeliveryEpoch(i Inventory, epoch string) Code {
|
|
14
|
+
if !i.Valid() || i.Protocol != DataProtocol {
|
|
15
|
+
return ErrIncompatible
|
|
16
|
+
}
|
|
17
|
+
if !digestPattern.MatchString(epoch) {
|
|
18
|
+
return ErrInvalid
|
|
19
|
+
}
|
|
20
|
+
return ""
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func newOperationTickets(i Inventory, epoch string) (*operationTickets, Code) {
|
|
24
|
+
if c := validDeliveryEpoch(i, epoch); c != "" {
|
|
25
|
+
return nil, c
|
|
26
|
+
}
|
|
27
|
+
return &operationTickets{inventory: i, epoch: epoch, now: time.Now, random: rand.Reader, issued: map[string]issuedOperationTicket{}}, ""
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func deliveryActorCode(a NativeActor, now time.Time) Code {
|
|
31
|
+
if !a.valid || !a.account.Enabled || a.UID() == 0 || a.GID() == 0 {
|
|
32
|
+
return ErrDenied
|
|
33
|
+
}
|
|
34
|
+
if a.Principal().Kind != "local" {
|
|
35
|
+
return ErrUnsupported
|
|
36
|
+
}
|
|
37
|
+
if !allReferences(a.Principal().SubjectRef, a.Principal().InstanceRef, a.SessionRef()) || a.account.Groups == nil {
|
|
38
|
+
return ErrSuspended
|
|
39
|
+
}
|
|
40
|
+
if !nativeFresh(a.account.CheckedAt, now) {
|
|
41
|
+
return ErrStale
|
|
42
|
+
}
|
|
43
|
+
return ""
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// issue is called only after trusted native/App/ACL observation, never in
|
|
47
|
+
// response to caller identity claims. It does not grant filesystem admission.
|
|
48
|
+
// A caller ticket is refused; the returned control contains a CSPRNG ticket
|
|
49
|
+
// bound to that exact decoded request, including its argument bytes.
|
|
50
|
+
func (t *operationTickets) issue(ctx context.Context, actor NativeActor, request DataRequest) (DataRequest, Code) {
|
|
51
|
+
if t == nil {
|
|
52
|
+
return DataRequest{}, ErrUnavailable
|
|
53
|
+
}
|
|
54
|
+
t.mu.Lock()
|
|
55
|
+
defer t.mu.Unlock()
|
|
56
|
+
if t.closed || t.now == nil || t.random == nil || t.issued == nil {
|
|
57
|
+
return DataRequest{}, ErrUnavailable
|
|
58
|
+
}
|
|
59
|
+
if code := nativeContextCode(ctx); code != "" {
|
|
60
|
+
return DataRequest{}, code
|
|
61
|
+
}
|
|
62
|
+
if code := deliveryActorCode(actor, t.now()); code != "" {
|
|
63
|
+
return DataRequest{}, code
|
|
64
|
+
}
|
|
65
|
+
if request.Inventory != t.inventory || request.Epoch != t.epoch {
|
|
66
|
+
return DataRequest{}, ErrStale
|
|
67
|
+
}
|
|
68
|
+
if request.Ticket != "" {
|
|
69
|
+
return DataRequest{}, ErrInvalid
|
|
70
|
+
}
|
|
71
|
+
full := len(t.issued)-t.streamIssued >= MaxReplayEntries
|
|
72
|
+
if request.Op == ActionReadStream || request.Op == ActionWriteStream {
|
|
73
|
+
full = t.streamIssued >= MaxStreamReplayEntries
|
|
74
|
+
}
|
|
75
|
+
if full {
|
|
76
|
+
return DataRequest{}, ErrBusy
|
|
77
|
+
}
|
|
78
|
+
// Validate before drawing randomness. The temporary reference is never used
|
|
79
|
+
// as a credential or published; syntax validation requires a ticket-shaped ID.
|
|
80
|
+
request.Ticket = t.epoch
|
|
81
|
+
if code := validateOperationRequest(request, t.writes); code != "" {
|
|
82
|
+
return DataRequest{}, code
|
|
83
|
+
}
|
|
84
|
+
if !request.Op.ReadOnly() && !t.writes.allows(request.Op) {
|
|
85
|
+
return DataRequest{}, ErrUnsupported
|
|
86
|
+
}
|
|
87
|
+
var token [32]byte
|
|
88
|
+
if _, err := io.ReadFull(t.random, token[:]); err != nil {
|
|
89
|
+
return DataRequest{}, ErrUnavailable
|
|
90
|
+
}
|
|
91
|
+
if code := nativeContextCode(ctx); code != "" {
|
|
92
|
+
return DataRequest{}, code
|
|
93
|
+
}
|
|
94
|
+
now := t.now()
|
|
95
|
+
if code := deliveryActorCode(actor, now); code != "" {
|
|
96
|
+
return DataRequest{}, code
|
|
97
|
+
}
|
|
98
|
+
request.Ticket = hex.EncodeToString(token[:])
|
|
99
|
+
if _, exists := t.issued[request.Ticket]; exists {
|
|
100
|
+
return DataRequest{}, ErrUnavailable
|
|
101
|
+
}
|
|
102
|
+
request.Args = slices.Clone(request.Args)
|
|
103
|
+
binding := TicketBinding{Inventory: request.Inventory, Epoch: request.Epoch, SubjectRef: actor.Principal().SubjectRef, SessionRef: actor.SessionRef(), Action: request.Op, GrantID: request.GrantID, GrantRevision: request.GrantRevision, OperationID: request.OperationID, Nonce: request.Nonce, Ticket: request.Ticket, RequestDigest: request.Digest(), ExpiresAt: now.Add(IntentTTL)}
|
|
104
|
+
if binding.RequestDigest == "" {
|
|
105
|
+
return DataRequest{}, ErrInvalid
|
|
106
|
+
}
|
|
107
|
+
t.issued[request.Ticket] = issuedOperationTicket{binding: binding, principal: actor.Principal()}
|
|
108
|
+
if request.Op == ActionReadStream || request.Op == ActionWriteStream {
|
|
109
|
+
t.streamIssued++
|
|
110
|
+
}
|
|
111
|
+
return request, ""
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// consume burns only an exact issued control. S3 must still freshly revalidate
|
|
115
|
+
// native/App/ACL/continuity and consume its own admission history under its gate.
|
|
116
|
+
// An admission failure may burn this ticket; retries require a new ticket.
|
|
117
|
+
func (t *operationTickets) consume(ctx context.Context, actor NativeActor, request DataRequest) (TicketBinding, Code) {
|
|
118
|
+
if t == nil {
|
|
119
|
+
return TicketBinding{}, ErrUnavailable
|
|
120
|
+
}
|
|
121
|
+
t.mu.Lock()
|
|
122
|
+
defer t.mu.Unlock()
|
|
123
|
+
if t.closed || t.now == nil || t.issued == nil {
|
|
124
|
+
return TicketBinding{}, ErrUnavailable
|
|
125
|
+
}
|
|
126
|
+
if code := nativeContextCode(ctx); code != "" {
|
|
127
|
+
return TicketBinding{}, code
|
|
128
|
+
}
|
|
129
|
+
now := t.now()
|
|
130
|
+
if code := deliveryActorCode(actor, now); code != "" {
|
|
131
|
+
return TicketBinding{}, code
|
|
132
|
+
}
|
|
133
|
+
if code := validateOperationRequest(request, t.writes); code != "" {
|
|
134
|
+
return TicketBinding{}, code
|
|
135
|
+
}
|
|
136
|
+
issued, ok := t.issued[request.Ticket]
|
|
137
|
+
if !ok {
|
|
138
|
+
return TicketBinding{}, ErrDenied
|
|
139
|
+
}
|
|
140
|
+
b := issued.binding
|
|
141
|
+
if actor.Principal() != issued.principal || actor.SessionRef() != b.SessionRef || request.Digest() != b.RequestDigest {
|
|
142
|
+
return TicketBinding{}, ErrDenied
|
|
143
|
+
}
|
|
144
|
+
if issued.used {
|
|
145
|
+
return TicketBinding{}, ErrReplay
|
|
146
|
+
}
|
|
147
|
+
if !now.Before(b.ExpiresAt) {
|
|
148
|
+
return TicketBinding{}, ErrExpired
|
|
149
|
+
}
|
|
150
|
+
if b.ExpiresAt.Sub(now) > IntentTTL {
|
|
151
|
+
return TicketBinding{}, ErrStale
|
|
152
|
+
}
|
|
153
|
+
issued.used = true
|
|
154
|
+
t.issued[request.Ticket] = issued
|
|
155
|
+
return b, ""
|
|
156
|
+
}
|
|
157
|
+
func (t *operationTickets) close() {
|
|
158
|
+
if t == nil {
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
t.mu.Lock()
|
|
162
|
+
defer t.mu.Unlock()
|
|
163
|
+
t.closed = true
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
func newOutputHandoff(i Inventory, epoch string) (*outputHandoff, Code) {
|
|
167
|
+
if code := validDeliveryEpoch(i, epoch); code != "" {
|
|
168
|
+
return nil, code
|
|
169
|
+
}
|
|
170
|
+
return &outputHandoff{inventory: i, epoch: epoch, now: time.Now, entries: map[string]operationOutput{}}, ""
|
|
171
|
+
}
|
|
172
|
+
func validOutputBinding(b operationBinding, i Inventory, epoch string) bool {
|
|
173
|
+
return b.Inventory == i && b.Epoch == epoch && allReferences(b.OperationID, b.Nonce, b.GrantID) && b.GrantRevision > 0
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// register takes ownership even on rejection. Caller must have authenticated
|
|
177
|
+
// the fixed owned peer and associated this endpoint with the admitted request.
|
|
178
|
+
// Never call this with a browser-supplied operation binding or remote address.
|
|
179
|
+
func (h *outputHandoff) register(b operationBinding, conn net.Conn) (code Code) {
|
|
180
|
+
if conn == nil {
|
|
181
|
+
return ErrInvalid
|
|
182
|
+
}
|
|
183
|
+
defer func() {
|
|
184
|
+
if code != "" {
|
|
185
|
+
conn.Close()
|
|
186
|
+
}
|
|
187
|
+
}()
|
|
188
|
+
if h == nil {
|
|
189
|
+
return ErrUnavailable
|
|
190
|
+
}
|
|
191
|
+
h.mu.Lock()
|
|
192
|
+
defer h.mu.Unlock()
|
|
193
|
+
if h.closed || h.now == nil || h.entries == nil {
|
|
194
|
+
return ErrUnavailable
|
|
195
|
+
}
|
|
196
|
+
if !validOutputBinding(b, h.inventory, h.epoch) {
|
|
197
|
+
return ErrDenied
|
|
198
|
+
}
|
|
199
|
+
if _, ok := h.entries[b.OperationID]; ok {
|
|
200
|
+
return ErrReplay
|
|
201
|
+
}
|
|
202
|
+
if len(h.entries) >= MaxReplayEntries {
|
|
203
|
+
return ErrBusy
|
|
204
|
+
}
|
|
205
|
+
now := h.now()
|
|
206
|
+
if now.IsZero() {
|
|
207
|
+
return ErrUnavailable
|
|
208
|
+
}
|
|
209
|
+
h.entries[b.OperationID] = operationOutput{binding: b, conn: conn, expires: now.Add(BoundedTimeout)}
|
|
210
|
+
return ""
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// take transfers ownership to S2. All net.Conn.Close calls occur after dropping
|
|
214
|
+
// the handoff lock. Close/timeout here is not child-reap or Q evidence.
|
|
215
|
+
func (h *outputHandoff) take(b operationBinding) (net.Conn, Code) {
|
|
216
|
+
if h == nil {
|
|
217
|
+
return nil, ErrUnavailable
|
|
218
|
+
}
|
|
219
|
+
h.mu.Lock()
|
|
220
|
+
if h.closed || h.now == nil || h.entries == nil {
|
|
221
|
+
h.mu.Unlock()
|
|
222
|
+
return nil, ErrUnavailable
|
|
223
|
+
}
|
|
224
|
+
entry, ok := h.entries[b.OperationID]
|
|
225
|
+
if !validOutputBinding(b, h.inventory, h.epoch) || !ok || entry.binding != b {
|
|
226
|
+
h.mu.Unlock()
|
|
227
|
+
return nil, ErrDenied
|
|
228
|
+
}
|
|
229
|
+
if entry.taken {
|
|
230
|
+
h.mu.Unlock()
|
|
231
|
+
return nil, ErrReplay
|
|
232
|
+
}
|
|
233
|
+
if now := h.now(); now.IsZero() || !now.Before(entry.expires) || entry.expires.Sub(now) > BoundedTimeout {
|
|
234
|
+
conn := entry.conn
|
|
235
|
+
entry.conn = nil
|
|
236
|
+
entry.taken = true
|
|
237
|
+
h.entries[b.OperationID] = entry
|
|
238
|
+
h.mu.Unlock()
|
|
239
|
+
if conn != nil {
|
|
240
|
+
conn.Close()
|
|
241
|
+
}
|
|
242
|
+
return nil, ErrExpired
|
|
243
|
+
}
|
|
244
|
+
if entry.conn == nil {
|
|
245
|
+
h.mu.Unlock()
|
|
246
|
+
return nil, ErrUnavailable
|
|
247
|
+
}
|
|
248
|
+
conn := entry.conn
|
|
249
|
+
entry.conn = nil
|
|
250
|
+
entry.taken = true
|
|
251
|
+
h.entries[b.OperationID] = entry
|
|
252
|
+
h.mu.Unlock()
|
|
253
|
+
return conn, ""
|
|
254
|
+
}
|
|
255
|
+
func (h *outputHandoff) close() {
|
|
256
|
+
if h == nil {
|
|
257
|
+
return
|
|
258
|
+
}
|
|
259
|
+
h.mu.Lock()
|
|
260
|
+
h.closed = true
|
|
261
|
+
var pending []net.Conn
|
|
262
|
+
for id, entry := range h.entries {
|
|
263
|
+
if entry.conn != nil {
|
|
264
|
+
pending = append(pending, entry.conn)
|
|
265
|
+
entry.conn = nil
|
|
266
|
+
h.entries[id] = entry
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
h.mu.Unlock()
|
|
270
|
+
for _, conn := range pending {
|
|
271
|
+
conn.Close()
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"fmt"
|
|
6
|
+
"io"
|
|
7
|
+
"net"
|
|
8
|
+
"slices"
|
|
9
|
+
"strings"
|
|
10
|
+
"sync"
|
|
11
|
+
"testing"
|
|
12
|
+
"time"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
func deliveryFixture(t *testing.T) (*operationTickets, NativeActor, DataRequest, time.Time) {
|
|
16
|
+
t.Helper()
|
|
17
|
+
provider, _, _, carriers, now := nativeFixture()
|
|
18
|
+
actor, code := provider.Resolve(context.Background(), carriers)
|
|
19
|
+
if code != "" {
|
|
20
|
+
t.Fatal(code)
|
|
21
|
+
}
|
|
22
|
+
request, _, _ := validRequestAndTicket(t)
|
|
23
|
+
request.Ticket = ""
|
|
24
|
+
tickets, code := newOperationTickets(request.Inventory, request.Epoch)
|
|
25
|
+
if code != "" {
|
|
26
|
+
t.Fatal(code)
|
|
27
|
+
}
|
|
28
|
+
tickets.now = func() time.Time { return now }
|
|
29
|
+
return tickets, actor, request, now
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
func TestOperationTicketsServerIssuedAndCompleteBinding(t *testing.T) {
|
|
33
|
+
tickets, actor, request, _ := deliveryFixture(t)
|
|
34
|
+
issued, code := tickets.issue(context.Background(), actor, request)
|
|
35
|
+
if code != "" || !digestPattern.MatchString(issued.Ticket) {
|
|
36
|
+
t.Fatal(code, issued.Ticket)
|
|
37
|
+
}
|
|
38
|
+
original := issued
|
|
39
|
+
issued.Args = slices.Clone(issued.Args)
|
|
40
|
+
issued.Args[0] = ' '
|
|
41
|
+
if _, code = tickets.consume(context.Background(), actor, issued); code == "" {
|
|
42
|
+
t.Fatal("changed arguments accepted")
|
|
43
|
+
}
|
|
44
|
+
proof, code := tickets.consume(context.Background(), actor, original)
|
|
45
|
+
if code != "" || proof.Ticket != original.Ticket || proof.RequestDigest != original.Digest() || proof.SubjectRef != actor.Principal().SubjectRef || proof.SessionRef != actor.SessionRef() {
|
|
46
|
+
t.Fatal(code, proof)
|
|
47
|
+
}
|
|
48
|
+
if _, code = tickets.consume(context.Background(), actor, original); code != ErrReplay {
|
|
49
|
+
t.Fatal("replay", code)
|
|
50
|
+
}
|
|
51
|
+
if _, code = tickets.consume(context.Background(), actor, request); code == "" {
|
|
52
|
+
t.Fatal("missing ticket accepted")
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
func TestOperationTicketsRejectUnknownProofAndEverySubstitution(t *testing.T) {
|
|
57
|
+
mutations := []struct {
|
|
58
|
+
name string
|
|
59
|
+
mutate func(*DataRequest, *NativeActor)
|
|
60
|
+
}{
|
|
61
|
+
{"inventory", func(r *DataRequest, a *NativeActor) { r.Inventory.Version = "9.0.0-9999" }},
|
|
62
|
+
{"epoch", func(r *DataRequest, a *NativeActor) { r.Epoch = strings.Repeat("a", 64) }},
|
|
63
|
+
{"grant", func(r *DataRequest, a *NativeActor) { r.GrantID = strings.Repeat("a", 64) }},
|
|
64
|
+
{"revision", func(r *DataRequest, a *NativeActor) { r.GrantRevision++ }},
|
|
65
|
+
{"operation", func(r *DataRequest, a *NativeActor) { r.OperationID = strings.Repeat("a", 64) }},
|
|
66
|
+
{"nonce", func(r *DataRequest, a *NativeActor) { r.Nonce = strings.Repeat("a", 64) }},
|
|
67
|
+
{"ticket", func(r *DataRequest, a *NativeActor) { r.Ticket = strings.Repeat("a", 64) }},
|
|
68
|
+
{"session", func(r *DataRequest, a *NativeActor) { a.sessionRef = strings.Repeat("a", 64) }},
|
|
69
|
+
{"instance", func(r *DataRequest, a *NativeActor) { a.account.Principal.InstanceRef = strings.Repeat("a", 64) }},
|
|
70
|
+
{"unknown actor", func(r *DataRequest, a *NativeActor) { *a = NativeActor{} }},
|
|
71
|
+
}
|
|
72
|
+
for _, m := range mutations {
|
|
73
|
+
t.Run(m.name, func(t *testing.T) {
|
|
74
|
+
tickets, actor, request, _ := deliveryFixture(t)
|
|
75
|
+
issued, code := tickets.issue(context.Background(), actor, request)
|
|
76
|
+
if code != "" {
|
|
77
|
+
t.Fatal(code)
|
|
78
|
+
}
|
|
79
|
+
badActor := actor
|
|
80
|
+
bad := issued
|
|
81
|
+
m.mutate(&bad, &badActor)
|
|
82
|
+
if _, code = tickets.consume(context.Background(), badActor, bad); code == "" {
|
|
83
|
+
t.Fatal("substitution accepted")
|
|
84
|
+
}
|
|
85
|
+
if _, code = tickets.consume(context.Background(), actor, issued); code != "" {
|
|
86
|
+
t.Fatal("rejection burned valid ticket", code)
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
tickets, actor, request, now := deliveryFixture(t)
|
|
91
|
+
unknown := actor
|
|
92
|
+
unknown.account.Principal.InstanceRef = ""
|
|
93
|
+
if _, code := tickets.issue(context.Background(), unknown, request); code == "" {
|
|
94
|
+
t.Fatal("unknown incarnation")
|
|
95
|
+
}
|
|
96
|
+
unknown = actor
|
|
97
|
+
unknown.account.Groups = nil
|
|
98
|
+
if _, code := tickets.issue(context.Background(), unknown, request); code == "" {
|
|
99
|
+
t.Fatal("unknown groups")
|
|
100
|
+
}
|
|
101
|
+
tickets.now = func() time.Time { return now.Add(NativeProofFreshness + time.Nanosecond) }
|
|
102
|
+
if _, code := tickets.issue(context.Background(), actor, request); code != ErrStale {
|
|
103
|
+
t.Fatal("stale native proof", code)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
func TestOperationTicketsBoundsExpiryCancelAndClose(t *testing.T) {
|
|
108
|
+
tickets, actor, request, now := deliveryFixture(t)
|
|
109
|
+
bad := request
|
|
110
|
+
bad.Ticket = strings.Repeat("f", 64)
|
|
111
|
+
if _, code := tickets.issue(context.Background(), actor, bad); code != ErrInvalid {
|
|
112
|
+
t.Fatal("caller chose ticket", code)
|
|
113
|
+
}
|
|
114
|
+
issued, code := tickets.issue(context.Background(), actor, request)
|
|
115
|
+
if code != "" {
|
|
116
|
+
t.Fatal(code)
|
|
117
|
+
}
|
|
118
|
+
ctx, cancel := context.WithCancel(context.Background())
|
|
119
|
+
cancel()
|
|
120
|
+
if _, code = tickets.consume(ctx, actor, issued); code != ErrCanceled {
|
|
121
|
+
t.Fatal(code)
|
|
122
|
+
}
|
|
123
|
+
tickets.now = func() time.Time { return now.Add(IntentTTL) }
|
|
124
|
+
actor.account.CheckedAt = now.Add(IntentTTL)
|
|
125
|
+
if _, code = tickets.consume(context.Background(), actor, issued); code != ErrExpired {
|
|
126
|
+
t.Fatal(code)
|
|
127
|
+
}
|
|
128
|
+
tickets.now = func() time.Time { return now }
|
|
129
|
+
actor.account.CheckedAt = now
|
|
130
|
+
for len(tickets.issued) < MaxReplayEntries {
|
|
131
|
+
if _, code = tickets.issue(context.Background(), actor, request); code != "" {
|
|
132
|
+
t.Fatal(code)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if _, code = tickets.issue(context.Background(), actor, request); code != ErrBusy {
|
|
136
|
+
t.Fatal("capacity evicted expired ticket", code)
|
|
137
|
+
}
|
|
138
|
+
tickets.close()
|
|
139
|
+
if _, code = tickets.issue(context.Background(), actor, request); code != ErrUnavailable {
|
|
140
|
+
t.Fatal(code)
|
|
141
|
+
}
|
|
142
|
+
var absent *operationTickets
|
|
143
|
+
if _, code = absent.consume(context.Background(), actor, issued); code != ErrUnavailable {
|
|
144
|
+
t.Fatal(code)
|
|
145
|
+
}
|
|
146
|
+
if _, code = newOperationTickets(Inventory{}, request.Epoch); code == "" {
|
|
147
|
+
t.Fatal("invalid inventory")
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
func TestOperationTicketsRandomFailureCollisionAndConcurrentUse(t *testing.T) {
|
|
152
|
+
tickets, actor, request, _ := deliveryFixture(t)
|
|
153
|
+
tickets.random = strings.NewReader("")
|
|
154
|
+
if _, code := tickets.issue(context.Background(), actor, request); code != ErrUnavailable {
|
|
155
|
+
t.Fatal(code)
|
|
156
|
+
}
|
|
157
|
+
tickets.random = strings.NewReader(strings.Repeat("x", 64))
|
|
158
|
+
issued, code := tickets.issue(context.Background(), actor, request)
|
|
159
|
+
if code != "" {
|
|
160
|
+
t.Fatal(code)
|
|
161
|
+
}
|
|
162
|
+
if _, code = tickets.issue(context.Background(), actor, request); code != ErrUnavailable {
|
|
163
|
+
t.Fatal("collision replaced ticket", code)
|
|
164
|
+
}
|
|
165
|
+
results := make(chan Code, 16)
|
|
166
|
+
var wg sync.WaitGroup
|
|
167
|
+
for i := 0; i < 16; i++ {
|
|
168
|
+
wg.Add(1)
|
|
169
|
+
go func() { defer wg.Done(); _, c := tickets.consume(context.Background(), actor, issued); results <- c }()
|
|
170
|
+
}
|
|
171
|
+
wg.Wait()
|
|
172
|
+
close(results)
|
|
173
|
+
success := 0
|
|
174
|
+
for c := range results {
|
|
175
|
+
if c == "" {
|
|
176
|
+
success++
|
|
177
|
+
} else if c != ErrReplay {
|
|
178
|
+
t.Fatal(c)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if success != 1 {
|
|
182
|
+
t.Fatal("single use", success)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
func outputFixture(t *testing.T) (*outputHandoff, operationBinding, time.Time) {
|
|
187
|
+
t.Helper()
|
|
188
|
+
r, _, now := validRequestAndTicket(t)
|
|
189
|
+
h, c := newOutputHandoff(r.Inventory, r.Epoch)
|
|
190
|
+
if c != "" {
|
|
191
|
+
t.Fatal(c)
|
|
192
|
+
}
|
|
193
|
+
h.now = func() time.Time { return now }
|
|
194
|
+
b := operationBinding{r.Inventory, r.Epoch, r.OperationID, r.Nonce, r.GrantID, r.GrantRevision}
|
|
195
|
+
return h, b, now
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
func TestOutputHandoffExactBindingAndSingleUse(t *testing.T) {
|
|
199
|
+
h, b, _ := outputFixture(t)
|
|
200
|
+
writer, reader := net.Pipe()
|
|
201
|
+
defer reader.Close()
|
|
202
|
+
if c := h.register(b, writer); c != "" {
|
|
203
|
+
t.Fatal(c)
|
|
204
|
+
}
|
|
205
|
+
bad := b
|
|
206
|
+
bad.Nonce = strings.Repeat("a", 64)
|
|
207
|
+
if out, c := h.take(bad); c != ErrDenied || out != nil {
|
|
208
|
+
t.Fatal("substitution", c)
|
|
209
|
+
}
|
|
210
|
+
out, c := h.take(b)
|
|
211
|
+
if c != "" || out != writer {
|
|
212
|
+
t.Fatal(c)
|
|
213
|
+
}
|
|
214
|
+
defer out.Close()
|
|
215
|
+
if out, c := h.take(b); c != ErrReplay || out != nil {
|
|
216
|
+
t.Fatal(c)
|
|
217
|
+
}
|
|
218
|
+
h.close() // transferred endpoint belongs to S2; Close cannot steal it.
|
|
219
|
+
done := make(chan error, 1)
|
|
220
|
+
go func() { _, err := writer.Write([]byte("ok")); done <- err }()
|
|
221
|
+
reader.SetReadDeadline(time.Now().Add(time.Second))
|
|
222
|
+
buf := make([]byte, 2)
|
|
223
|
+
if _, err := io.ReadFull(reader, buf); err != nil || string(buf) != "ok" {
|
|
224
|
+
t.Fatal(err)
|
|
225
|
+
}
|
|
226
|
+
if err := <-done; err != nil {
|
|
227
|
+
t.Fatal(err)
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
func TestOutputHandoffUnknownExpiredDuplicateClosed(t *testing.T) {
|
|
232
|
+
for _, name := range []string{"expired", "duplicate", "closed", "invalid"} {
|
|
233
|
+
t.Run(name, func(t *testing.T) {
|
|
234
|
+
h, b, now := outputFixture(t)
|
|
235
|
+
w, r := net.Pipe()
|
|
236
|
+
defer r.Close()
|
|
237
|
+
switch name {
|
|
238
|
+
case "expired":
|
|
239
|
+
if c := h.register(b, w); c != "" {
|
|
240
|
+
t.Fatal(c)
|
|
241
|
+
}
|
|
242
|
+
h.now = func() time.Time { return now.Add(BoundedTimeout) }
|
|
243
|
+
if out, c := h.take(b); c != ErrExpired || out != nil {
|
|
244
|
+
t.Fatal(c)
|
|
245
|
+
}
|
|
246
|
+
case "duplicate":
|
|
247
|
+
old, oldReader := net.Pipe()
|
|
248
|
+
defer oldReader.Close()
|
|
249
|
+
defer h.close()
|
|
250
|
+
if c := h.register(b, old); c != "" {
|
|
251
|
+
t.Fatal(c)
|
|
252
|
+
}
|
|
253
|
+
if c := h.register(b, w); c != ErrReplay {
|
|
254
|
+
t.Fatal(c)
|
|
255
|
+
}
|
|
256
|
+
case "closed":
|
|
257
|
+
h.close()
|
|
258
|
+
if c := h.register(b, w); c != ErrUnavailable {
|
|
259
|
+
t.Fatal(c)
|
|
260
|
+
}
|
|
261
|
+
case "invalid":
|
|
262
|
+
b.Epoch = ""
|
|
263
|
+
if c := h.register(b, w); c == "" {
|
|
264
|
+
t.Fatal("invalid binding accepted")
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
r.SetReadDeadline(time.Now().Add(time.Second))
|
|
268
|
+
if _, err := r.Read(make([]byte, 1)); err != io.EOF {
|
|
269
|
+
t.Fatal("refused connection leaked", err)
|
|
270
|
+
}
|
|
271
|
+
})
|
|
272
|
+
}
|
|
273
|
+
h, b, _ := outputFixture(t)
|
|
274
|
+
if out, c := h.take(b); c != ErrDenied || out != nil {
|
|
275
|
+
t.Fatal("unknown output", c)
|
|
276
|
+
}
|
|
277
|
+
if c := h.register(b, nil); c != ErrInvalid {
|
|
278
|
+
t.Fatal("nil transport", c)
|
|
279
|
+
}
|
|
280
|
+
var absent *outputHandoff
|
|
281
|
+
if out, c := absent.take(b); c != ErrUnavailable || out != nil {
|
|
282
|
+
t.Fatal(c)
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
func TestOutputHandoffCapAndClosePending(t *testing.T) {
|
|
287
|
+
h, b, _ := outputFixture(t)
|
|
288
|
+
for i := 0; i < MaxReplayEntries; i++ {
|
|
289
|
+
x := b
|
|
290
|
+
x.OperationID = fmt.Sprintf("%064x", i+100)
|
|
291
|
+
w, r := net.Pipe()
|
|
292
|
+
r.Close()
|
|
293
|
+
if c := h.register(x, w); c != "" {
|
|
294
|
+
t.Fatal(c)
|
|
295
|
+
}
|
|
296
|
+
out, c := h.take(x)
|
|
297
|
+
if c != "" {
|
|
298
|
+
t.Fatal(c)
|
|
299
|
+
}
|
|
300
|
+
out.Close()
|
|
301
|
+
}
|
|
302
|
+
w, r := net.Pipe()
|
|
303
|
+
defer r.Close()
|
|
304
|
+
if c := h.register(b, w); c != ErrBusy {
|
|
305
|
+
t.Fatal("history evicted", c)
|
|
306
|
+
}
|
|
307
|
+
h, b, _ = outputFixture(t)
|
|
308
|
+
w, r = net.Pipe()
|
|
309
|
+
defer r.Close()
|
|
310
|
+
if c := h.register(b, w); c != "" {
|
|
311
|
+
t.Fatal(c)
|
|
312
|
+
}
|
|
313
|
+
h.close()
|
|
314
|
+
h.close()
|
|
315
|
+
if out, c := h.take(b); c != ErrUnavailable || out != nil {
|
|
316
|
+
t.Fatal(c)
|
|
317
|
+
}
|
|
318
|
+
r.SetReadDeadline(time.Now().Add(time.Second))
|
|
319
|
+
if _, err := r.Read(make([]byte, 1)); err != io.EOF {
|
|
320
|
+
t.Fatal(err)
|
|
321
|
+
}
|
|
322
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"net"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// Root-only S1/S5 seam. It must establish App authorization, native ACL,
|
|
9
|
+
// grant-owner/scope continuity and a server-issued single-use ticket bound to
|
|
10
|
+
// the COMPLETE decoded control and actor/session. It is not installed by S3;
|
|
11
|
+
// nil always refuses work. No caller continuity/actor/admin fields are accepted.
|
|
12
|
+
type GrantOperationValidator interface {
|
|
13
|
+
ValidateOperation(context.Context, NativeActor, DataRequest, Grant) (GrantUseValidation, Code)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type GrantUseValidation struct {
|
|
17
|
+
Binding ContinuityBinding
|
|
18
|
+
Continuous bool
|
|
19
|
+
Ticket TicketBinding
|
|
20
|
+
root readOnlyRootWitness // trusted in-memory epoch pin; never caller JSON
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Fixed internal supervisor services. There is no package/plugin injection or
|
|
24
|
+
// caller executable. S3 production leaves unproved native/ACL adapters nil.
|
|
25
|
+
type supervisorGrantServices struct {
|
|
26
|
+
writes writeGates
|
|
27
|
+
writeIntents writeIntentStore
|
|
28
|
+
native *NativeProvider
|
|
29
|
+
consent ConsentValidator
|
|
30
|
+
operations GrantOperationValidator
|
|
31
|
+
output func(operationBinding) (net.Conn, Code)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// GrantDrainProof is S2's bounded receipt for one grant. Reaped counts require
|
|
35
|
+
// actual owned-child Wait4 AND stopped relay/closed private descriptors. Bytes
|
|
36
|
+
// count admitted effects; they do not assert rollback or bytes already sent.
|
|
37
|
+
type GrantDrainProof struct {
|
|
38
|
+
Key GrantDrainKey `json:"key"`
|
|
39
|
+
Started uint64 `json:"started"`
|
|
40
|
+
Reaped uint64 `json:"reaped"`
|
|
41
|
+
WriteOperations uint64 `json:"writeOperations,omitempty"`
|
|
42
|
+
BytesWritten uint64 `json:"bytesWritten,omitempty"`
|
|
43
|
+
WriteEffectsUnknown bool `json:"writeEffectsUnknown,omitempty"`
|
|
44
|
+
PublishedOperations uint64 `json:"publishedOperations,omitempty"`
|
|
45
|
+
CommittedOperations uint64 `json:"committedOperations,omitempty"`
|
|
46
|
+
AdmittedBytes uint64 `json:"admittedBytes"`
|
|
47
|
+
}
|