@synopackageland/cli 0.49.1 → 0.50.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +10 -0
  3. package/dist/build-spk/generator.js +3 -3
  4. package/dist/build-spk/reproducible-archive.js +3 -1
  5. package/dist/ctl/ai-tools.d.ts +11 -1
  6. package/dist/ctl/ai-tools.js +4 -4
  7. package/dist/ctl/cli.d.ts +8 -1
  8. package/dist/ctl/cli.js +54 -5
  9. package/dist/ctl/descriptor.d.ts +15 -2
  10. package/dist/ctl/descriptor.js +9 -4
  11. package/dist/ctl/diagnostics.d.ts +16 -0
  12. package/dist/ctl/diagnostics.js +11 -0
  13. package/dist/ctl/flows.js +2 -0
  14. package/dist/ctl/input.d.ts +5 -3
  15. package/dist/ctl/input.js +3 -3
  16. package/dist/ctl/native-auth-command.d.ts +9 -0
  17. package/dist/ctl/native-auth-command.js +103 -0
  18. package/dist/ctl/native-executor.d.ts +16 -0
  19. package/dist/ctl/native-executor.js +187 -0
  20. package/dist/ctl/native-file-types.d.ts +16 -0
  21. package/dist/ctl/native-file-types.js +57 -0
  22. package/dist/ctl/native-files.d.ts +13 -0
  23. package/dist/ctl/native-files.js +115 -0
  24. package/dist/ctl/native-metadata.d.ts +10 -0
  25. package/dist/ctl/native-metadata.js +50 -0
  26. package/dist/ctl/native-paths.d.ts +4 -0
  27. package/dist/ctl/native-paths.js +65 -0
  28. package/dist/ctl/native-protocol.d.ts +21 -0
  29. package/dist/ctl/native-protocol.js +150 -0
  30. package/dist/ctl/native-registry.d.ts +8 -0
  31. package/dist/ctl/native-registry.js +182 -0
  32. package/dist/ctl/native-schemas.d.ts +7 -0
  33. package/dist/ctl/native-schemas.js +25 -0
  34. package/dist/ctl/native-store.d.ts +67 -0
  35. package/dist/ctl/native-store.js +342 -0
  36. package/dist/ctl/native-transfers.d.ts +13 -0
  37. package/dist/ctl/native-transfers.js +331 -0
  38. package/dist/ctl/native-transport.d.ts +30 -0
  39. package/dist/ctl/native-transport.js +148 -0
  40. package/dist/ctl/native-types.d.ts +15 -0
  41. package/dist/ctl/native-types.js +1 -0
  42. package/dist/ctl/registry.d.ts +5 -4
  43. package/dist/ctl/registry.js +12 -1
  44. package/dist/ctl/service.d.ts +34 -1
  45. package/dist/ctl/service.js +122 -1
  46. package/dist/ctl/windows-acl.d.ts +39 -0
  47. package/dist/ctl/windows-acl.js +80 -0
  48. package/dist/ctl/windows-prompt.d.ts +5 -0
  49. package/dist/ctl/windows-prompt.js +119 -0
  50. package/dist/ctl/windows-sddl.d.ts +20 -0
  51. package/dist/ctl/windows-sddl.js +162 -0
  52. package/dist/ctl/windows-security-helper.d.ts +7 -0
  53. package/dist/ctl/windows-security-helper.js +88 -0
  54. package/dist/ctl/windows-security.d.ts +10 -0
  55. package/dist/ctl/windows-security.js +95 -0
  56. package/dist/ctl/windows-tools.d.ts +11 -0
  57. package/dist/ctl/windows-tools.js +23 -0
  58. package/dist/error-registry.js +15 -0
  59. package/dist/generated/native-http.d.ts +189 -0
  60. package/dist/generated/native-http.js +1 -0
  61. package/dist/nas/store.d.ts +3 -1
  62. package/dist/nas/store.js +6 -3
  63. package/dist/nas/transport.d.ts +1 -0
  64. package/dist/native-http-schema/descriptor.schema.json +242 -0
  65. package/dist/native-http-schema/inventory.schema.json +121 -0
  66. package/dist/native-http-schema/registry.schema.json +872 -0
  67. package/dist/native-http-schema/source.json +1 -0
  68. package/dist/runtime/sdk-source.d.ts +1 -1
  69. package/dist/runtime/sdk-source.js +1 -1
  70. package/dist/spk/extract.d.ts +6 -0
  71. package/dist/spk/extract.js +39 -0
  72. package/dist/standalone/api-description.d.ts +2 -5
  73. package/dist/standalone/build.js +5 -1
  74. package/dist/standalone/compose-errors.js +5 -0
  75. package/dist/standalone/daemon.js +1 -0
  76. package/dist/standalone/inspect-spk.js +23 -37
  77. package/dist/standalone/install-ports.js +2 -1
  78. package/dist/standalone/lifecycle.js +9 -2
  79. package/dist/standalone/manifest.d.ts +1 -0
  80. package/dist/standalone/manifest.js +22 -5
  81. package/dist/standalone/native-http-inspect.d.ts +9 -0
  82. package/dist/standalone/native-http-inspect.js +43 -0
  83. package/dist/standalone/native-http.d.ts +31 -0
  84. package/dist/standalone/native-http.js +120 -0
  85. package/dist/standalone/native-layout.js +2 -0
  86. package/dist/standalone/operation-registry.d.ts +2 -7
  87. package/dist/standalone/operation-registry.js +3 -0
  88. package/dist/standalone/spk.d.ts +1 -0
  89. package/dist/standalone/spk.js +15 -1
  90. package/package.json +3 -2
  91. package/schema/dsm-api-contract.json +8 -7
  92. package/skills/SKILL.md +2 -2
  93. package/skills/reference/compose.md +21 -0
  94. package/skills/reference/ctl.md +229 -0
  95. package/skills/reference/daemon-mode.md +1 -1
  96. package/skills/reference/upstream-fork.md +5 -2
@@ -0,0 +1,120 @@
1
+ import { readFileSync, mkdtempSync, writeFileSync, rmSync, existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { tmpdir } from 'node:os';
4
+ import { sdkSource, SDK_MODULE } from '../runtime/sdk-source.js';
5
+ import { goChildEnv } from '../runtime/go-env.js';
6
+ import { goBuildEnv } from '../build-spk/dsm-arch.js';
7
+ import { identityGatewayConfig, gatewayEntryPolicyDigest } from './identity-gateway.js';
8
+ import { validateNativeArtifacts, HTTP_INVENTORY_FILE, digest } from '../ctl/native-metadata.js';
9
+ import { validateNativeRegistry } from '../ctl/native-registry.js';
10
+ import { registryFile, readRegistry, writeGenerated, registryReference, registryTools } from '../ctl/registry.js';
11
+ export function nativeSdk(m) {
12
+ if (!m.identityGateway?.sdk || !m.identityGateway.ingress)
13
+ throw Error('CTL_NATIVE_SDK_REQUIRED: native HTTP requires protected same-origin gateway ingress.');
14
+ const sdk = sdkSource(m.identityGateway.sdk);
15
+ for (const name of ['registry', 'descriptor', 'inventory']) {
16
+ const path = join(sdk.goDir, 'api/nativehttp/schema', name + '.schema.json');
17
+ if (!existsSync(path) || digest(JSON.parse(readFileSync(path, 'utf8'))) !== digest(JSON.parse(readFileSync(new URL(`../../dist/native-http-schema/${name}.schema.json`, import.meta.url), 'utf8'))))
18
+ throw Error('CTL_NATIVE_SDK_REQUIRED: use SDK after 0.51.1, containing native HTTP v3, matching this CLI.');
19
+ }
20
+ return sdk;
21
+ }
22
+ export function nativeBuildConfig(m) { return { package: { id: m.package, version: m.spkVersion, displayName: m.displayname }, aliases: m.ctl?.aliases ?? [m.package.toLowerCase()], provenance: { developedBy: m.ctl?.developedBy ?? 'unknown', generator: 'synopkgland-cli' }, backend: m.compose ? 'compose' : 'native', transport: 'native-http', gateway: JSON.parse(identityGatewayConfig(m)) }; }
23
+ export function validateNativeManifest(m) {
24
+ if (Object.keys(m.capabilities).some(name => name !== 'composeMounts') || !['binary', 'go'].includes(m.backend.kind))
25
+ throw Error('CTL_NATIVE_BACKEND_CONFLICT: metadata-only native HTTP cannot replace SDK business capabilities or bridge runtimes; keep their RPC transport.');
26
+ if (m.uninstall?.purge.exec === 'ui/cgi/api.cgi')
27
+ throw Error('CTL_NATIVE_BACKEND_CONFLICT: use a separate package uninstall executable with metadata-only native HTTP.');
28
+ nativeSdk(m);
29
+ const registry = readRegistry(registryFile(m.root, m.ctl.registry));
30
+ if (registry.version !== 3)
31
+ throw Error('CTL_NATIVE_REGISTRY_INVALID: native-http requires v3.');
32
+ const config = nativeBuildConfig(m), g = config.gateway;
33
+ if (g.access === 'public' || g.upstream_access === 'public' || g.entry === 'policy')
34
+ throw Error('CTL_NATIVE_REGISTRY_INVALID: native HTTP cannot bypass DSM entry.');
35
+ validateNativeRegistry(registry, { basePath: g.ingress_path, upstreamAuthPaths: g.upstream_auth_paths ?? [], entry: m.entry ?? 'policy' });
36
+ }
37
+ export async function generateNativeOperations(m, run, check = false) {
38
+ validateNativeManifest(m);
39
+ const sdk = nativeSdk(m), config = nativeBuildConfig(m), work = mkdtempSync(join(tmpdir(), 'synopkgland-native-metadata-'));
40
+ try {
41
+ const file = join(work, 'config.json');
42
+ writeFileSync(file, JSON.stringify(config));
43
+ const response = await run('go', ['run', './api/nativehttp/cmd/export', '-registry', registryFile(m.root, m.ctl.registry), '-config', file], { cwd: sdk.goDir, env: goChildEnv({ ...process.env, GOOS: undefined, GOARCH: undefined, GOARM: undefined, CGO_ENABLED: '0' }), capture: true });
44
+ if (response.status !== 0)
45
+ throw Error('CTL_NATIVE_EXPORT_FAILED: SDK native HTTP metadata export failed.');
46
+ let artifacts;
47
+ try {
48
+ const raw = JSON.parse(response.stdout ?? '');
49
+ artifacts = validateNativeArtifacts(raw.descriptor, raw.inventory);
50
+ }
51
+ catch {
52
+ throw Error('CTL_NATIVE_EXPORT_FAILED: invalid SDK metadata export.');
53
+ }
54
+ if (artifacts.descriptor.payload.entryPolicyDigest !== gatewayEntryPolicyDigest(config.gateway) || digest(artifacts.descriptor.payload.package) !== digest(config.package))
55
+ throw Error('CTL_NATIVE_EXPORT_FAILED: resolved metadata mismatch.');
56
+ const registry = readRegistry(registryFile(m.root, m.ctl.registry));
57
+ if (digest(registry) !== artifacts.descriptor.payload.registrySha256)
58
+ throw Error('CTL_NATIVE_REGISTRY_CHANGED: registry changed during metadata export.');
59
+ const write = (name, value) => writeGenerated(join(m.root, 'generated', name), JSON.stringify(value, null, 2) + '\n', check);
60
+ write('synopkgland-api.json', artifacts.descriptor);
61
+ write(HTTP_INVENTORY_FILE, artifacts.inventory);
62
+ write('ctl.json', { commands: artifacts.descriptor.payload.commands });
63
+ write('tools.json', { tools: registryTools(registry) });
64
+ write('routes.json', artifacts.inventory.bindings);
65
+ writeGenerated(join(m.root, 'generated', 'operations.md'), registryReference(registry), check);
66
+ return { description: artifacts.descriptor, inventory: artifacts.inventory, registry: Object.fromEntries(Object.entries(artifacts.inventory.bindings).map(([name, b]) => [name, b.permission])) };
67
+ }
68
+ finally {
69
+ rmSync(work, { recursive: true, force: true });
70
+ }
71
+ }
72
+ /** Fixed SDK metadata-only CGI; no App business routes are linked. */
73
+ export function metadataCgiSource(pkg, entry, sha256) {
74
+ return `package main
75
+ import (
76
+ "encoding/json"
77
+ "fmt"
78
+ "net/http/cgi"
79
+ "os"
80
+ "path/filepath"
81
+ "${SDK_MODULE}/api/nativehttp"
82
+ "${SDK_MODULE}/dsm"
83
+ )
84
+ func main() {
85
+ root := "/var/packages/${pkg}/target"
86
+ // Bind the packaged descriptor to the CGI build before constructing its handler.
87
+ raw, err := os.ReadFile(filepath.Join(root,"synopkgland-api.json"))
88
+ if err != nil { os.Exit(1) }
89
+ if err := check(raw); err != nil { os.Exit(1) }
90
+ auth, err := dsm.NewEntryGate(dsm.NewAuthenticator(),${JSON.stringify(entry)},${JSON.stringify(pkg)},"/var/packages/${pkg}/var")
91
+ if err != nil { os.Exit(1) }
92
+ handler, err := nativehttp.NewDescriptionHandler(auth,filepath.Join(root,"synopkgland-api.json"),filepath.Join(root,"${HTTP_INVENTORY_FILE}"))
93
+ if err != nil { os.Exit(1) }
94
+ if err = cgi.Serve(handler); err != nil { os.Exit(1) }
95
+ }
96
+ ` + `\n// The SDK's JCS hash is the build pin; raw formatting is deliberately irrelevant.
97
+ func check(raw []byte) error {
98
+ return checkDescription(raw,${JSON.stringify(sha256)})
99
+ }
100
+ `;
101
+ }
102
+ export async function buildNativeMetadataCgi(m, arch, work, run, description) {
103
+ const sdk = nativeSdk(m), source = join(work, 'native-metadata.go'), out = join(work, `native-metadata-${arch}.cgi`);
104
+ writeFileSync(source, metadataCgiSource(m.package, m.entry ?? '', description.sha256) + `\n` + checkSource);
105
+ // Build in the pinned SDK module; source is CLI-owned and uses only exported SDK APIs.
106
+ const result = await run('go', ['build', '-trimpath', '-buildvcs=false', '-ldflags', `-s -w -buildid= -X ${SDK_MODULE}/api.expectedEntryMode=${m.entry ?? ''}`, '-o', out, source], { cwd: sdk.goDir, env: goChildEnv({ ...process.env, ...goBuildEnv(arch) }) });
107
+ if (result.status !== 0 || !existsSync(out))
108
+ throw Error('CTL_NATIVE_CGI_BUILD_FAILED: SDK metadata CGI compilation failed.');
109
+ return out;
110
+ }
111
+ const checkSource = `
112
+ func checkDescription(raw []byte, expected string) error {
113
+ var d map[string]json.RawMessage
114
+ if err := json.Unmarshal(raw,&d); err != nil { return err }
115
+ delete(d,"sha256")
116
+ unsigned, err := json.Marshal(d); if err != nil { return err }
117
+ actual, err := nativehttp.Digest(unsigned); if err != nil { return err }
118
+ if actual != expected { return fmt.Errorf("packaged metadata changed") }; return nil
119
+ }
120
+ `;
@@ -360,6 +360,8 @@ export async function buildNativeLayout(options) {
360
360
  fail('INFO anchor collides with an INFO field');
361
361
  writeFileSync(join(stage, 'INFO'), info.map(([k, v]) => `${k}="${v.replace(/([\\"$`])/g, '\\$1')}"\n`).join(''));
362
362
  writeFileSync(join(stage, 'native-layout.json'), JSON.stringify({ format: 1, arch, dependencies: m.dependencies ?? { packages: [] }, binaries: binaries.map(({ path, linkage }) => ({ path, linkage })), files, ...(m.layout.anchors ? { anchors: m.layout.anchors } : {}), ...(m.portal ? { portal: m.portal } : {}) }));
363
+ for (const name of ['INFO', 'native-layout.json'])
364
+ chmodSync(join(stage, name), 0o644);
363
365
  const output = join(outDir, `${m.package}-${version}-${arch}.spk`);
364
366
  await createReproducibleTar(stage, output, { rejectSecrets: true });
365
367
  return output;
@@ -1,13 +1,8 @@
1
1
  import { type Descriptor } from '../ctl/descriptor.js';
2
2
  import { type StandaloneManifest } from './manifest.js';
3
3
  import type { CommandRunner } from './build.js';
4
+ import { type NativeArtifacts } from './native-http.js';
4
5
  export declare function operationRegistry(m: StandaloneManifest): import("../ctl/registry.js").OperationRegistry;
5
6
  export declare function registryDescriptor(m: StandaloneManifest, registry?: import("../ctl/registry.js").OperationRegistry): Descriptor;
6
7
  /** Generation writes metadata only. The exporter constructs routes without running handlers. */
7
- export declare function generateOperations(m: StandaloneManifest, run: CommandRunner, check?: boolean, bridgeMethods?: string[]): Promise<{
8
- description: Descriptor;
9
- registry: {
10
- 'identity.session'?: string | undefined;
11
- 'identity.logout'?: string | undefined;
12
- };
13
- }>;
8
+ export declare function generateOperations(m: StandaloneManifest, run: CommandRunner, check?: boolean, bridgeMethods?: string[]): Promise<NativeArtifacts>;
@@ -6,6 +6,7 @@ import { makeDescriptor, validateDescriptor, flowMethods } from '../ctl/descript
6
6
  import { readApiPermissions, API_PERMISSIONS_FILE } from './api-permissions.js';
7
7
  import { sdkBackend } from './manifest.js';
8
8
  import { describeApiRoutes } from './api-description.js';
9
+ import { generateNativeOperations } from './native-http.js';
9
10
  export function operationRegistry(m) {
10
11
  if (!m.ctl?.registry)
11
12
  throw Error('CTL_REGISTRY_REQUIRED: declare ctl.registry with a synopkgland.api v2 spec.');
@@ -30,6 +31,8 @@ export function registryDescriptor(m, registry = operationRegistry(m)) {
30
31
  }
31
32
  /** Generation writes metadata only. The exporter constructs routes without running handlers. */
32
33
  export async function generateOperations(m, run, check = false, bridgeMethods) {
34
+ if (m.ctl?.transport === 'native-http')
35
+ return generateNativeOperations(m, run, check);
33
36
  const source = operationRegistry(m);
34
37
  const registry = structuredClone(source);
35
38
  if (m.backend.kind === 'binary' || m.compose)
@@ -30,6 +30,7 @@ export interface AssembleOptions {
30
30
  portalText?: PortalCatalogs;
31
31
  apiRegistry?: Record<string, string>;
32
32
  apiDescription?: import("../ctl/descriptor.js").Descriptor;
33
+ httpInventory?: import('../ctl/native-types.js').NativeInventory;
33
34
  }
34
35
  /**
35
36
  * Packs an unsigned Standalone Package SPK. DSM runs installation/lifecycle
@@ -1,3 +1,5 @@
1
+ import { validateNativeArtifacts, digest } from '../ctl/native-metadata.js';
2
+ import { gatewayEntryPolicyDigest } from './identity-gateway.js';
1
3
  import { renderMobileAssets } from './mobile.js';
2
4
  import { requireDaemonNoFileActivation } from "./daemon-nofile.js";
3
5
  import { gatewayIngressOwnershipSupported } from './gateway-ingress.js';
@@ -74,6 +76,16 @@ export class StandaloneBuildError extends Error {
74
76
  */
75
77
  export async function assembleStandaloneSpk(options) {
76
78
  const { manifest } = options;
79
+ if (manifest.ctl?.enabled && manifest.ctl.transport === 'native-http') {
80
+ if (!options.apiDescription || !options.httpInventory || !options.cgiPath)
81
+ throw new StandaloneBuildError('CTL_NATIVE_METADATA_REQUIRED', 'Native HTTP requires its descriptor, inventory and metadata CGI.');
82
+ const { descriptor, inventory } = validateNativeArtifacts(options.apiDescription, options.httpInventory);
83
+ const gateway = JSON.parse(identityGatewayConfig(manifest));
84
+ if (descriptor.payload.entryPolicyDigest !== gatewayEntryPolicyDigest(gateway) || descriptor.payload.package.id !== manifest.package || descriptor.payload.package.version !== manifest.spkVersion || inventory.basePath !== gateway.ingress_path || digest(inventory.upstreamAuthPaths) !== digest(gateway.upstream_auth_paths))
85
+ throw new StandaloneBuildError('CTL_NATIVE_METADATA_MISMATCH', 'Native metadata differs from the resolved package gateway.');
86
+ }
87
+ else if (options.apiDescription?.version === 3 || options.httpInventory)
88
+ throw new StandaloneBuildError('CTL_NATIVE_METADATA_MISMATCH', 'Native metadata requires explicit native-http transport.');
77
89
  requireDaemonNoFileActivation(manifest.daemon?.nofile);
78
90
  const staging = mkdtempSync(join(tmpdir(), "syno-standalone-spk-"));
79
91
  try {
@@ -115,6 +127,8 @@ export async function assembleStandaloneSpk(options) {
115
127
  writeUiTexts(uiRoot, appTitle(manifest), manifest.console);
116
128
  if (options.apiDescription)
117
129
  writeFile(join(staging, "package", "synopkgland-api.json"), JSON.stringify(options.apiDescription) + "\n");
130
+ if (options.httpInventory)
131
+ writeFile(join(staging, 'package', 'synopkgland-http-inventory.json'), JSON.stringify(options.httpInventory) + '\n');
118
132
  const cgiTarget = join(staging, "package", CGI_PAYLOAD_PATH);
119
133
  mkdirSync(dirname(cgiTarget), { recursive: true });
120
134
  if (options.cgiPath) {
@@ -273,7 +287,7 @@ export async function assembleStandaloneSpk(options) {
273
287
  ...(manifest.integrations ? { integrations: manifest.integrations } : {}),
274
288
  ...(manifest.lifecycleTimeouts ? { lifecycleTimeouts: manifest.lifecycleTimeouts } : {}),
275
289
  ...("timeoutSeconds" in manifest.backend && manifest.backend.timeoutSeconds ? { operationSeconds: manifest.backend.timeoutSeconds } : {}),
276
- ...(options.apiDescription ? { ctl: { hash: options.apiDescription.sha256, registry: options.apiRegistry } } : {}),
290
+ ...(options.apiDescription ? { ctl: { hash: options.apiDescription.sha256, registry: options.apiRegistry, ...(options.httpInventory ? { transport: 'native-http', inventorySha256: options.apiDescription.payload.inventorySha256, sdk: manifest.identityGateway.sdk } : {}) } } : {}),
277
291
  backend: manifest.backend.kind,
278
292
  ...(gatewayAdmissionPolicy(manifest.identityGateway, manifest.entry) ? { provider_only_oidc: gatewayAdmissionPolicy(manifest.identityGateway, manifest.entry) } : {}),
279
293
  ...(manifest.identityGateway && gatewayExternalAccess(manifest.identityGateway)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.49.1",
3
+ "version": "0.50.1",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,7 +25,7 @@
25
25
  ],
26
26
  "scripts": {
27
27
  "check:docs": "node --test scripts/check-doc-versions.test.mjs && node scripts/check-doc-versions.mjs",
28
- "build": "rm -rf dist && tsc",
28
+ "build": "rm -rf dist && node scripts/prepare-native-http.mjs && tsc",
29
29
  "test": "npm run build && node --import tsx --import ./test/helpers/strict-dsm-setup.ts --test --test-concurrency=${SYNOPKGLAND_GATE_JOBS:-3} test/*.test.ts test/ctl/*.test.ts",
30
30
  "test:glossary": "node --test scripts/test/glossary-drift.test.mjs",
31
31
  "test:scripts": "node --test scripts/test/gate.test.mjs scripts/test/release.test.mjs scripts/test/pack-docker.test.mjs scripts/test/npm-pack.test.mjs scripts/test/executor-bump.test.mjs scripts/test/smoke-exports.test.mjs scripts/test/parallel.test.mjs scripts/test/scaffold-matrix.test.mjs scripts/test/frontend-deps.test.mjs scripts/test/docker-gate.test.mjs scripts/test/gate-plan.test.mjs scripts/test/gates.test.mjs && python3 scripts/test/npm-publish.py",
@@ -44,6 +44,7 @@
44
44
  "commander": "^13.1.0",
45
45
  "esbuild": "^0.28.2",
46
46
  "json-canonicalize": "^3.0.1",
47
+ "koffi": "3.3.7",
47
48
  "re2js": "2.9.1",
48
49
  "tar": "^7.4.3",
49
50
  "yaml": "^2.7.0"
@@ -1113,17 +1113,18 @@
1113
1113
  "build-spk/share-combobox.ts": "797cd3eea347e7fe57946f9584f725d6faef79fe9c56b690e1199ea7489fa973",
1114
1114
  "build-spk/share-validation.ts": "a51b160cea9bea096e6efb45879abbf6d0dfecf21c761dca7cd06647d44cef62",
1115
1115
  "cli.ts": "d45c74e012a6953ad17cd0135f97f3ba98b37d4ff8b2fb60ef0a894f15ce0d64",
1116
- "ctl/cli.ts": "a582aff3a048c14884b4ffae03efdb50142ca7d769feae97f0f9b0d11d66d6da",
1116
+ "ctl/cli.ts": "97d218069c6fac42f64573c68c354d7a0e549ca2900b9d8b2935c9786bc5d11d",
1117
1117
  "ctl/external.ts": "f66490ded838f934a0cf373f284418d4d02441edc8c8365066fc45b898ba81dc",
1118
- "ctl/flows.ts": "76a7b8c2e3991687e693797b7e02aae5c7e35d9a2f07220f1d223354c38e3469",
1119
- "ctl/service.ts": "c5bb01257db9f65f31db3fcd3d0b78c4a84a967cb96de43fa587934ea175826c",
1118
+ "ctl/flows.ts": "0f35d03176655bfe1d1df5d02ea36199e05973634dffcc6710112b7c8ce78b7e",
1119
+ "ctl/native-transport.ts": "83a1f8b1fd7b4470d0d34d5244d799e09bf36f528d5e46f67c337336f3f1c774",
1120
+ "ctl/service.ts": "2510f00072b202216d51dc436d4fd9d871bbf8487c2ba40723057e67be680db1",
1120
1121
  "deploy/deploy.ts": "3f593232e8e95d029f1389d16a13127baf51ef1f381211d8be2fde5c46759f1b",
1121
1122
  "deploy/identity.ts": "4822596d8b6e170f8aa4293bd877eb27bc549cb16f720b364e543d8037bd8071",
1122
1123
  "deploy/plan.ts": "1f772811ca963bdf863462a256d8e810c151e096a55a91a753bd5bf855921536",
1123
1124
  "deploy/spk-version.ts": "407a79491ffac8d00ecb9b056ab0b352e08bf6142871fa46f302fd217f98fc24",
1124
1125
  "e2e/certificates.ts": "e9801e5f4d326d31c3c281e5106f34138493e26cd7f0ad2b1dd3f6a566832389",
1125
1126
  "e2e/dsm.ts": "66c9b3f6d907a8069202c5f88f13f8051c07b099de66d3ebce5de51c6374201f",
1126
- "error-registry.ts": "ca7e717532a97d1bcd3a27018c2f036e8b19691338679f2651e49cf7e19e6e57",
1127
+ "error-registry.ts": "91f2de89bf98750a09fce54420e3a25e3527980be175ed704890a520181f1dc9",
1127
1128
  "host/catalog-install.ts": "df27409d835a901658dae7c2048c9028c2dc886e17575fe9189e88ae705c0fd2",
1128
1129
  "host/compose-project-recovery.ts": "c76efa505f8ba14f50a8705b63d0f9f8a022b70505fe6a5f5976146afae17532",
1129
1130
  "host/container-pull.ts": "d85314dd265f7609ab1fda87e23cce0fa81165baeeaf79a792d7bb6dc10338e3",
@@ -1143,16 +1144,16 @@
1143
1144
  "nas/connection.ts": "e7a2eafda8fa04203c70449ff3836795adaccb3c57bc86bc1458887e424783ad",
1144
1145
  "nas/credentials.ts": "14e539d2e6d257fcaa1ebde254ae82f1794db4122c77bdfaf22da1aed7b24843",
1145
1146
  "nas/http.ts": "00464e38218d2fe0c7185c910a4c1c796a1451996edd19aa34e5193919c57b4a",
1146
- "nas/store.ts": "b9c5c4d670afd3d63723c27c8271470e3af8a69afb9b3910297caafa747298e4",
1147
+ "nas/store.ts": "3ec3cb463ab5d0eb2a465bcbaf433285644ae40a443370605e337ed4ec0f9272",
1147
1148
  "nas/timeouts.ts": "4cc1347243b43af404a7e46603395768cb45c634b2e1c199e9f1a446f1ab45cb",
1148
1149
  "nas/transfers.ts": "e80ded3a930543fff499888dcfcf9dbc00017f34810478bd33f2fe16cc5a699d",
1149
- "nas/transport.ts": "3d6ac6d58903544d2158c518be88b186f1642ef1e7039f782b3d5d4614e540a3",
1150
+ "nas/transport.ts": "92f05f173aa7441fce27b43d2f84eef00828e3f343d543353a2f090cb091df13",
1150
1151
  "runtime/executor-scope-task.ts": "f8717a424b9f29323e4a5720eef5688db42e2caa14c70489641907c758b3a39b",
1151
1152
  "runtime/executor-tasks.ts": "017a58d65686b8e90f17c6a18ad3923b3e1c7b3b68ce6ea23db3bd0f8f066f18",
1152
1153
  "runtime/operation-budget.ts": "126a43530d9c659f2667ba10b2c7f718373f1e6a3b97374c2eaa8b75b942ce06",
1153
1154
  "runtime/sdk-timeouts.ts": "1b56ac9717d10d604b110120149e363b5bcb57218796acf98a64b6b4fba68339",
1154
1155
  "standalone/install-ports.ts": "1b317071803f127b600a5324ac7952d28db9910af25210f139bbf430a3c135ee",
1155
- "standalone/manifest.ts": "09682c938fb308df95c2da0dfac88578c54237b9fb38b98d0a950f9da4f0407b",
1156
+ "standalone/manifest.ts": "1183c92dc97520393289757ec6ba7884c94c2e0d7e44f322dace54f88b6d644d",
1156
1157
  "standalone/portal-window.ts": "bc0a16a73ff4de4acee5f5820dbad48c709a6c53d48670a98d8b23f9009650c9",
1157
1158
  "standalone/root-window.ts": "2b3f8f3dd1c77963d9485b16739a953ecedf2019939b4b5b608cd7ac61232231"
1158
1159
  },
package/skills/SKILL.md CHANGED
@@ -360,9 +360,9 @@ Schema 2 Compose 使用 `dsm-package.yaml` 的 `compose.files`、`compose.web`
360
360
  `identity_gateway`;不使用 file/targets/address_env 或手寫 upstream。
361
361
  省略 `ui.launch` 時預設 `new-page`,使用 SDK standalone launcher,不帶 Application Portal。
362
362
  Headless Compose 不產生 launcher。health 必須選實際 endpoint 與 2xx status;
363
- readiness 不跟隨 redirect,check 不會發 HTTP。Compose 不支援 ctl。
363
+ readiness 不跟隨 redirect,check 不會發 HTTP。Compose 的 legacy SDK RPC ctl 仍拒絕;原生 API 可明確選用 `ctl.transport: native-http`,需 matching SDK v3 metadata。
364
364
 
365
- For controlling installed Apps or designing task-level AI commands, read [reference/ctl.md](reference/ctl.md). Declare operations once in a synopkgland.api v2 registry with a required ai class; run `ctl generate`, `ctl generate --check` and `check`. Operation descriptions belong only in that registry; read the generated per-App reference. Import OSS APIs hidden and obtain explicit per-API opt-in grouped by area before exposing them. Use ctl host list, register/renew explicitly, discover all commands, and always name the host when agents may operate multiple NAS machines.
365
+ For controlling installed Apps or designing task-level AI commands, read [reference/ctl.md](reference/ctl.md). Declare operations once in a synopkgland.api v2 RPC registry or matching v3 native-http registry with a required ai class; run `ctl generate`, `ctl generate --check` and `check`. Operation descriptions belong only in that registry; read the generated per-App reference. Import OSS APIs hidden and obtain explicit per-API opt-in grouped by area before exposing them. Use ctl host list, register/renew explicitly, discover all commands, and always name the host when agents may operate multiple NAS machines. For native credentials, ask the human to run ctl auth in their own terminal; never request tokens in chat or invoke auth from an AI tool. Native tokens remain client-side, and DSM revocation does not revoke upstream tokens.
366
366
 
367
367
  ## Optional basic testing
368
368
 
@@ -40,6 +40,18 @@ No backend, dummy CGI, UI directory or helper payload is required. Omit `web`,
40
40
  architecture-specific native payloads for token/account adapters. All lifecycle
41
41
  scripts run as the package account; containers are managed by Container Manager.
42
42
 
43
+ START preflight checks Container Manager availability, share authorization and
44
+ package-owned runtime settings. It does not require Container Manager profiles:
45
+ the official STOP worker can remove them and START recreates them. Waiting for
46
+ those files before START would prevent the worker from running.
47
+
48
+ Headless STOP preserves local service cleanup failures and reports
49
+ `COMPOSE_STOP_UNCONFIRMED` for actual local teardown failure. Missing profiles
50
+ after STOP are normal and are not an error. Restart stops first and never
51
+ continues to START after a failed STOP. INSTALL and UPGRADE keep their existing
52
+ worker sequence. SDK and CLI hooks do not read or modify private profiles, and
53
+ local cleanup success does not attest that DSM later stopped actual containers.
54
+
43
55
  For external access, pin both `compose.sdk` and `identity_gateway.sdk` to
44
56
  the same release with external access support and use the gateway's
45
57
  [`external_access` policy and DSM settings entry](identity-gateway.md#external-access).
@@ -513,3 +525,12 @@ verifies planner/lock agreement and `inspect --json` reports `compose.hostUdp`.
513
525
  Rebuild with a CLI and SDK that support the declaration; older planners reject
514
526
  it. Discovery and multicast coexistence need real LAN verification; this guard
515
527
  is not a firewall and does not reserve ports or configure reuse.
528
+
529
+ ## Native HTTP ctl
530
+
531
+ Compose Apps may explicitly declare `ctl.transport: native-http` with a matching
532
+ SDK v3 registry and same-origin ingress. The SDK serves DSM-protected metadata;
533
+ the CLI calls the existing native API with a client-held App token. Legacy
534
+ Compose SDK RPC ctl stays refused. Follow [native credentials](ctl.md#native-app-credentials)
535
+ for human enrollment, per-API exposure review, scope, lifecycle and bounded flows.
536
+ Do not add a gateway business dispatcher or store user credentials on the NAS.
@@ -36,6 +36,140 @@ known alias matches. `ctl list` reports pending approvals in `data.diagnostics`.
36
36
 
37
37
  Use `host show nas` to inspect approvals/pins, `host revoke nas PackageID` to remove an App approval, `host logout nas` to retain registration, and `host remove nas --yes` to delete sessions, device token, approvals and cache. A failed NAS logout is reported independently from successful local removal.
38
38
 
39
+ ## Native App credentials
40
+
41
+ Apps may opt into `ctl.transport: native-http` with a matching SDK v3 registry.
42
+ This transport works with Compose or native backends and the App's existing
43
+ same-origin ingress. Legacy Compose SDK RPC ctl stays refused. The registry is
44
+ the only operation source; declarations cannot supply arbitrary URLs, scripts,
45
+ credential headers or browser login recipes. Keep `ctl.external` separate;
46
+ native credentials do not extend external MCP or local file authority.
47
+
48
+ The official client still requires the approved installed package/version/hash
49
+ and a fresh DSM-authenticated metadata description before native execution.
50
+ Native business HTTP uses only the App's own token. It sends no DSM cookie,
51
+ SynoToken, SDK session, Origin or trusted identity headers. Resource permissions,
52
+ expiry and revocation belong to the upstream App. DSM logout, disabled users or
53
+ revoked App entry do not revoke a raw native token used by other HTTP clients.
54
+ An App account selected by the user is not proof that it represents the DSM user.
55
+
56
+ Have the human run this in their own terminal:
57
+
58
+ ```sh
59
+ synopkgland ctl auth --host <profile> --app <package>
60
+ ```
61
+
62
+ The command shows the declared credential page and UI instructions, offers to
63
+ open that page in a browser, hides secret input, verifies the native identity and
64
+ asks before saving it in the OS keychain. The SDK never logs into the App for the
65
+ user. For header auth, copy an existing API token from the native UI. For
66
+ greader-client-login, supply the native account name and existing API password;
67
+ the client performs the fixed ClientLogin/user-info protocol and saves only the
68
+ exchanged Auth token. It never saves the API password or mints, rotates or revokes
69
+ upstream credentials. Fixed action T is obtained only for the current mutation.
70
+ That fixed action-token response alone accepts text/plain or PHP's text/html;
71
+ it must be a UTF-8 single-line token within 4 KiB (one terminal newline is allowed),
72
+ without markup (`<`), embedded whitespace or additional lines. This exception
73
+ never relaxes ClientLogin or ordinary business-response MIME checks.
74
+
75
+ Trusted human automation can use `--secret-stdin`: one token line for header
76
+ auth, or one strict JSON object with only `username` and `apiPassword` for
77
+ greader. Input is bounded and never echoed. No token/password argv or environment
78
+ option exists. **AI agents must ask the user to run ctl auth. Never ask for a token
79
+ in chat, read a secret file or run auth on the user's behalf.** Auth/reset are not
80
+ AI tools. Credential acquisition is never an ordinary operation binding.
81
+
82
+ Keychain records use service `synopkgland.ctl.native`, separate from DSM sessions.
83
+ Keys bind the registered profile name, canonical origin, DSM username, package and
84
+ auth contract digest. Same-origin profiles never fall back to each other or to an
85
+ administrator. Descriptor/version updates retain credentials only when the auth
86
+ contract is unchanged. Two DSM profiles under one OS login are not a security
87
+ boundary; use separate OS accounts for that isolation.
88
+
89
+ When the keychain is unavailable, unlock it or explicitly choose
90
+ `ctl auth --app <package> --store encrypted-file`. There is no silent fallback.
91
+ The independent passphrase is hidden, process-local and never derived from DSM
92
+ credentials. The vault uses scrypt and AES-256-GCM, bounded authenticated metadata,
93
+ private file permissions (user-only ACL on Windows), exclusive locking and atomic
94
+ replacement. Wrong passphrase, tamper, symlinks or unsafe permissions refuse
95
+ access. On Windows, inherited ACLs on the shared ctl state directory are accepted
96
+ only when its owner is the current user, Administrators, local Administrator (LA)
97
+ or SYSTEM and no other
98
+ principal has write, delete, ACL-change or ownership-change access. Ancestors
99
+ are checked separately: the exact TrustedInstaller SID is also trusted there;
100
+ inherit-only grants do not apply to that directory, and create-subdirectory
101
+ permission alone cannot replace an existing protected child. Each next directory
102
+ is checked for effective grants. These ancestor exceptions do not apply to state
103
+ or private leaves. LA/LG use Win32 identity resolution, never the current user
104
+ SID prefix. Other recognized well-known aliases remain subject to the same
105
+ untrusted-writer policy. Private native
106
+ directories and files additionally reject other principals' read access. Existing
107
+ unsafe ACLs are refused rather than rewritten; new private objects use protected
108
+ current-user ACLs. An unavailable list entry includes a bounded `auth.reason`
109
+ code (for example `windows-acl-other-user-write`), without paths, SIDs or secrets.
110
+ ACL inspection uses Win32 GetNamedSecurityInfoW through a pinned native bridge
111
+ in a Node child that waits for completion without a wall-clock timeout; Ctrl-C
112
+ can interrupt it. No PowerShell is involved. Child output remains size-bounded,
113
+ with hidden windows and piped stdio. It reads the actual owner and DACL;
114
+ icacls /save alone omits the owner. The current SID is queried once per process
115
+ with whoami. New private objects use icacls and native readback;
116
+ unknown SDDL rights, flags or ACEs fail closed. Object ACE grants are evaluated
117
+ conservatively; conditional ACEs are explicitly refused. OWNER RIGHTS follows the
118
+ validated owner. Group, audit and mandatory-label sections cannot excuse unsafe
119
+ DACL grants. Invalid descriptors include a bounded tokenKind/token/section detail
120
+ with account SIDs masked, never the full descriptor or local paths. Inspection failures include a
121
+ fixed auth.detail.category and, when available, exitCode or win32Code. Raw child
122
+ stderr is never returned. ACL phase diagnostics include elapsedMs. Windows interactive prompts enable raw mode
123
+ before displaying input and wait for the prompt write to flush. An optional
124
+ `SYNOPKGLAND_CTL_DIAGNOSTICS_FILE` records private phase/TTY metadata only, never
125
+ input values, prompt text, local paths or SIDs.
126
+ Headless encrypted-file unlock is unsupported; automation requires an OS
127
+ secret service. Actual OS availability must be verified on the target platform.
128
+ Changing storage backends requires explicit `--reset` and enrollment, which
129
+ prevents a failed migration from leaving an unindexed old secret behind.
130
+
131
+ `ctl list` reports native auth scheme, instructions, credential URL and state.
132
+ `stored` means a record was enrolled, not that it is unlocked or still valid.
133
+ After a 401, listing shows `invalid` until a verified replacement or local reset.
134
+ Listing never unlocks or probes native credentials. Help, tools and dry-run work
135
+ without a native token. Missing/locked auth in JSON, non-TTY or AI execution gives
136
+ instructions without prompting. An interactive first call can enroll, then asks
137
+ the user to rerun the original command; it never replays the original operation.
138
+ A 401 shows the cause, credential URL and App instructions before offering
139
+ "Enter a new token now? [y/N]". Declining preserves the invalid record. FreshRSS
140
+ renewal asks for the native account and API password again, exchanges and verifies
141
+ it, and stores only the exchanged token. A 403 remains a permission error.
142
+
143
+ `ctl auth --app <package>` updates an existing record without reset, retaining its
144
+ storage backend unless explicitly selected. Replacement verifies first; a failed
145
+ verification preserves the previous record. `ctl auth --reset` only deletes the
146
+ current local scope; run auth again to enroll.
147
+ `host remove` deletes all native keychain/vault records for that profile, including
148
+ old auth digests. `host logout` retains them but requires restored DSM metadata
149
+ admission. `host revoke` retains them and blocks official use until reapproval.
150
+ None of these commands revoke an upstream token. Rotate it intentionally in the
151
+ native App when upstream revocation is wanted.
152
+
153
+ | Native result | Client behavior |
154
+ | --- | --- |
155
+ | 401 | `CTL_NATIVE_AUTH_INVALID` (2); mark invalid; offer interactive renewal; never replay the request |
156
+ | 403 | `CTL_NATIVE_ACCESS_DENIED` (4); preserve credential and check native permissions |
157
+ | 503 | `CTL_NATIVE_UNAVAILABLE` (5); check API enablement/configuration |
158
+ | 3xx or login HTML | Refuse; no redirect, browser fallback or cookie reuse |
159
+ | Lost mutation request/receipt | `CTL_NATIVE_OUTCOME_UNKNOWN` (6); inspect the App before retrying |
160
+
161
+ All native requests use the shared profile TLS policy and never automatically
162
+ retry. Plans respect schema writeOnly fields and contain no auth carriers. Auth
163
+ exchange replies are private protocol input; diagnostics never echo them or raw
164
+ exception bodies. Business responses preserve their declared values without
165
+ content redaction. JSON/NDJSON/schema/projection bounds reject invalid results.
166
+ Page pagination never follows `next` URLs; cursor pagination uses only the fixed
167
+ bounded continuation token. Bound exhaustion or repeated cursor/no progress
168
+ returns `incomplete:true` and explicit continuation rather than claiming a full
169
+ result. Pagination is not an upstream snapshot guarantee. A dry-run is a request
170
+ plan; it is not a native preview. Draft AI mutations require a real read-only
171
+ preview, and writes still require human execution with `--yes`.
172
+
39
173
  Stdout defaults to JSON without a TTY. Success is {ok:true,data}; failure is {ok:false,error:{code,message,hint,allowed?}}. Multi-host output uses {ok,results:[{host,ok,data|error}]}. Follow the concrete hint and complete allowed list; do not guess another method or bypass ctl with raw HTTP. Exit codes: 2 authentication, 3 parameters/names, 4 permissions/trust, 5 App/contract, 6 network, 7 confirmation, 8 partial failure.
40
174
 
41
175
  ## Local MCP external callers
@@ -264,3 +398,98 @@ Request previews (plans, dry-run and missing-yes plans) mask schema-marked input
264
398
  Prefer `<resource> <verb>`. Common verbs are `list`, `get`, `export` (often reads), `create`, `update`, `import`, `run` (often writes), and `delete` (often destructive). Pick one synonym within an App; avoid mixing show/get/status for the same task. These are recommendations only: Apps may use domain verbs such as `pause` and `resume`.
265
399
 
266
400
  Every command must explicitly declare its required `effect`. CLI/build never infer or overwrite effect from the verb. The existing check that command effect must not be less restrictive than its bindings remains. There is no verb allowlist or new verb rejection rule.
401
+
402
+ ### Native HTTP metadata and builds
403
+
404
+ Native HTTP packaging requires a matching SDK containing native HTTP v3. The
405
+ CLI uses the SDK's `api/nativehttp/schema` resources and build-time exporter;
406
+ it has no independent schema grammar. `ctl generate` writes private
407
+ `generated/synopkgland-api.json` and
408
+ `generated/synopkgland-http-inventory.json`, plus command/tool/reference output.
409
+ `ctl generate --check` and `check` compare every generated artifact. Build compiles
410
+ a metadata-only CGI with the SDK DSM authenticator and matching entry gate;
411
+ no Go business handlers, second listener, per-user NAS store or HTTP relay is
412
+ required. The CGI serves only the fixed authenticated describe request.
413
+
414
+ The registry's full operation map, including hidden specs, participates in the
415
+ registry hash and HTTP inventory. Hidden operations stay absent from human
416
+ command selection and AI tools. The inventory includes required
417
+ `upstreamAuthPaths`; build/inspect compare them and the existing unscoped gateway
418
+ entry-policy digest to the resolved gateway config. Auth scope uses the SDK's
419
+ `authSha256`, including basePath, the entire auth declaration and entry policy.
420
+ Every artifact uses the SDK's JCS rules; explicit empty optional maps survive.
421
+ Exact features are required; unknown features never fall back to SDK RPC.
422
+
423
+ The frozen describe wire carries the descriptor. Its SDK handler validates the
424
+ private inventory before serving it. The client independently validates the
425
+ registry/auth/descriptor hashes and binding equality, and sends native requests
426
+ only to the exact declared path templates and auth endpoints. Original upstream
427
+ prefix containment and inventory hashing are additionally checked by the SDK
428
+ handler and SPK inspect. Business effects are explicitly authored: POST can be a
429
+ read and a confirmed GET can be an action. Never infer effect from the HTTP verb.
430
+
431
+ For CLI development, set `SYNOPKGLAND_SDK_DIR` to an authorized matching SDK
432
+ checkout before `npm run build` and focused native tests. The build generates
433
+ contract types and packaged schema assets directly from that checkout. Release
434
+ builds must use a published matching SDK selected by
435
+ `SYNOPKGLAND_NATIVE_HTTP_SDK_VERSION`; development checkouts are test inputs,
436
+ not release pins. Keep the release dependency open until that SDK exists.
437
+
438
+ ### Native HTTP local file flows (unreleased)
439
+
440
+ The human CLI installs `upload-http` and `download-file` through the authenticated
441
+ native transport. Both require `ai: human-only`; neither becomes an AI tool or an
442
+ external MCP file capability. Local `fileParam` / `outputParam` values never enter
443
+ the native query/body. Existing dry-run, write confirmation and fresh DSM metadata
444
+ admission still apply. These flows require the matching SDK v3 sources described
445
+ above; these changes are not included in the latest published CLI.
446
+
447
+ Multipart uploads send the declared part, optional bounded form fields and a safe
448
+ basename. PDF/PNG/JPEG require a matching signature and declared MIME. Raw uploads
449
+ accept UTF-8 OPML XML only, with a 1 MiB cap, an OPML root, and no DTD/entity
450
+ declarations. There is no XML entity resolver. The effective file limit is the
451
+ minimum of package, flow, response (downloads) and CLI hard 16 GiB limits. Form
452
+ fields are limited to 16 parts / 64 KiB and upload receipts to 64 KiB. Uploads
453
+ retain the upstream receipt/task ID; acceptance does not mean OCR completion.
454
+
455
+ Files stream with backpressure and bounded buffers. Connection/header/idle budgets
456
+ apply without a productive-stream total deadline. Interactive progress goes to
457
+ stderr; JSON stdout contains only the final receipt or error. One transfer runs
458
+ per process. Ctrl-C stops local IO and returns failure. An interrupted mutation
459
+ has `outcome_unknown`; inspect the original native task/resource before retrying.
460
+ There is no retry, resume, redirect following or implicit upstream cancellation.
461
+
462
+ Local sources require a no-follow regular-file descriptor and unchanged file
463
+ metadata through completion. Downloads use an exclusive 0600 partial on the same
464
+ filesystem, validate status/MIME/identity encoding, length and actual bytes, then
465
+ publish with an atomic no-replace hard link. Existing destinations are refused,
466
+ including symlinks; response filenames never choose the destination. Failed
467
+ transfers remove their partial. Completion returns `{bytes, sha256}` for the
468
+ received bytes, without claiming upstream authenticity. Filesystems without hard
469
+ links fail closed. A process crash can leave a hidden `.ctl-partial-*` file; it
470
+ never becomes the requested output automatically.
471
+
472
+ Ancestors are resolved once to the longest existing canonical directory before
473
+ file traversal is anchored to held descriptors. Root/current-user owned symlinks
474
+ are allowed only through safe directories: no group/world writes unless a public
475
+ directory has sticky-bit entry protection. Link targets follow the same checks.
476
+ Source/output leaves still refuse symlinks. Native credential state uses the same
477
+ ancestor policy, while the ctl and native directories themselves remain no-follow,
478
+ current-user owned and 0700, with the existing private-file checks retained.
479
+ This implementation uses Linux descriptor-relative filesystem aliases; macOS has
480
+ an equivalent implementation path pending platform verification. Unsupported
481
+ platforms, including Windows, fail closed before native IO rather than falling
482
+ back to unsafe path-based writes. Linux fixtures cover source changes, publication
483
+ races, truncated streams, disk-full, cancellation and slow sparse transfers.
484
+
485
+
486
+ ### Empty native mutation acknowledgements (unreleased)
487
+
488
+ An explicitly authored write/destructive operation can accept an empty declared
489
+ 204, or an empty declared 200 with Content-Length 0, without Content-Type. The
490
+ client verifies that the body really is empty, requires identity encoding and
491
+ returns `{ok: true, status}`. The receipt must satisfy the declared result schema;
492
+ there is no representation to project. Nonempty replies still require their
493
+ declared MIME and decoder. Read operations receive no such exception. This is an
494
+ HTTP acknowledgement, not proof of the final App state: run the App's declared
495
+ readback command as usual. No mutation is replayed or synthetic readback added.
@@ -41,7 +41,7 @@ cache an upper bound and measure it filled.
41
41
  These numbers come from Studio Office. Use them as an example of what
42
42
  to measure, not as a budget.
43
43
 
44
- - **CGI cost per request.** On a DS SA3400 with 25 Apps, every Studio call
44
+ - **CGI cost per request.** On a measured NAS with 25 Apps, every Studio call
45
45
  spent 100–140 ms before the handler did any work: process start, the DSM
46
46
  sign-in check (`authenticate.cgi`), the App Privileges check and schema
47
47
  checks. Recompiling App definitions on each request took about 70% of
@@ -61,7 +61,9 @@ Cover common reads and writes through existing native APIs, including the main
61
61
  UI tasks; `status` and `service status` alone are incomplete. Keep upstream code
62
62
  unchanged and run adapters as the package account. Report unsupported transports
63
63
  or synchronous-only long operations for discussion; do not invent App features
64
- or bypass the current Compose ctl restriction.
64
+ or bypass the legacy Compose RPC restriction. For an existing native API, opt into
65
+ matching v3 native-http metadata and client-side credentials; read the native
66
+ credential contract in [ctl.md](ctl.md#native-app-credentials).
65
67
 
66
68
  ## Container: official image and a matching source tag
67
69
 
@@ -257,7 +259,8 @@ with both init flags, or fill `compose.web.health` before check/build. No guesse
257
259
  `/` + 200. Readiness **does not follow redirects**: a 302 to a dashboard/login is
258
260
  unhealthy even if its destination is 200. A favicon/robots probe proves HTTP
259
261
  availability only; verify database setup and full readiness separately. `check`
260
- is static, not an HTTP or UID/storage probe. Compose ctl is rejected at check;
262
+ is static, not an HTTP or UID/storage probe. Legacy Compose RPC ctl is rejected;
263
+ native-http requires a matching v3 declaration and same-origin ingress;
261
264
  dedicated origin `/` is supported, automatic subpath rewriting is not.
262
265
 
263
266
  Public npm availability does not grant anonymous Go SDK access. Obtain authorised