semantifold 0.4.0 → 0.5.0

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 (42) hide show
  1. package/README.md +5 -2
  2. package/build/index.d.ts +12 -8
  3. package/build/index.d.ts.map +1 -1
  4. package/build/index.js +10 -7
  5. package/build/src/backends/android.d.ts +49 -0
  6. package/build/src/backends/android.d.ts.map +1 -0
  7. package/build/src/backends/android.js +1274 -0
  8. package/build/src/backends/identifiers.d.ts.map +1 -1
  9. package/build/src/backends/identifiers.js +7 -1
  10. package/build/src/backends/kotlin.d.ts +10 -0
  11. package/build/src/backends/kotlin.d.ts.map +1 -1
  12. package/build/src/backends/kotlin.js +11 -9
  13. package/build/src/backends/program.d.ts +6 -4
  14. package/build/src/backends/program.d.ts.map +1 -1
  15. package/build/src/backends/program.js +5 -4
  16. package/build/src/backends/shared.d.ts.map +1 -1
  17. package/build/src/backends/shared.js +17 -1
  18. package/build/src/backends/writer.d.ts +21 -1
  19. package/build/src/backends/writer.d.ts.map +1 -1
  20. package/build/src/backends/writer.js +25 -2
  21. package/build/src/language-registry.d.ts.map +1 -1
  22. package/build/src/language-registry.js +11 -1
  23. package/build/src/semantic/types.d.ts +182 -2
  24. package/build/src/semantic/types.d.ts.map +1 -1
  25. package/build/src/semantic/types.js +44 -2
  26. package/docs/android.md +79 -0
  27. package/docs/architecture.md +2 -0
  28. package/docs/ios.md +1 -1
  29. package/docs/language-support.md +8 -1
  30. package/docs/source-maps.md +2 -0
  31. package/docs/specification.md +5 -0
  32. package/docs/testing.md +15 -0
  33. package/index.js +9 -6
  34. package/package.json +1 -1
  35. package/src/backends/android.js +1370 -0
  36. package/src/backends/identifiers.js +6 -0
  37. package/src/backends/kotlin.js +11 -8
  38. package/src/backends/program.js +4 -3
  39. package/src/backends/shared.js +19 -0
  40. package/src/backends/writer.js +27 -2
  41. package/src/language-registry.js +10 -0
  42. package/src/semantic/types.js +46 -1
package/docs/ios.md CHANGED
@@ -36,7 +36,7 @@ const artifactSet = generateProgramArtifactSet({
36
36
 
37
37
  `generateArtifactSet` accepts the same application fields for one semantic module and normalizes it to one project module. Both routes validate the entire semantic graph before rendering. The source registry accepts provenance from every registered frontend language, including compatible Dart modules, while the supported semantics remain exactly the Tasks 001–004 Swift subset from Task 022: typed scalar values, typed locals/assignment, the closed scalar operators, nested statement blocks/conditionals, exact two-argument scalar-return functions, resolved calls, and deterministic text output. Task 010 owns project modules, source ownership, imports, exports, and dependency order. iOS adds no parser rule or semantic node for SwiftUI, application lifecycle, capture, configuration, resources, signing, or Apple APIs.
38
38
 
39
- Program-shaped application dispatch is limited to program-capable application targets, currently only `ios`. The separate Wasm application backend remains available through the single-module `generateArtifactSet` route and is rejected with `UNSUPPORTED_ROLE` when requested through `generateProgramArtifactSet`; a program object is never passed to that module backend.
39
+ Program-shaped application dispatch is limited to program-capable application targets, currently `ios` and `android`. The separate Wasm application backend remains available through the single-module `generateArtifactSet` route and is rejected with `UNSUPPORTED_ROLE` when requested through `generateProgramArtifactSet`; a program object is never passed to that module backend.
40
40
 
41
41
  Unsupported source or caller-supplied IR produces a located `SemantifoldDiagnostic` with `UNSUPPORTED_CAPABILITY` and target `ios`. The backend never embeds Ruby, invokes a Ruby runtime from the app, translates through JavaScript, emulates dynamic Ruby behavior, or discovers sources/packages.
42
42
 
@@ -22,8 +22,9 @@ The immutable registry is authoritative for both dispatch and discovery:
22
22
  | `dart` | yes | yes | no | no | no | yes | no | no | no | no | no | no | no | no | no | no | multiple | yes | rich + v3 | parse, generate, restore, compile, validate, execute (`dart`) |
23
23
  | `wasm` | no | no | yes | yes | no | no | no | no | no | no | no | no | no | no | no | no | multiple | no | rich text + v3 + byte ranges | generate, validate, instantiate, execute (`wasm-validate`, `node`, `chromium`) |
24
24
  | `ios` | no | no | no | yes | no | no | no | no | no | no | no | no | no | no | no | no | multiple | no | rich text + v3 + byte ranges | generate (Apple acceptance deferred) |
25
+ | `android` | no | no | no | yes | no | no | no | no | no | no | no | no | no | no | no | no | multiple | no | rich text + v3 + byte ranges | generate, compile, validate, instantiate, execute (`android`, TensorBuzz KVM) |
25
26
 
26
- `languageCapabilities` exposes all sixteen records as frozen data, including `features.generalFunctionsAndCalls`, `features.immutableCollections`, `features.optionalValues`, `features.orderedListIteration`, `features.orderedMapIteration`, `features.conditionControlledLoops`, `features.referenceClasses`, `features.effectfulCapabilitiesAndResources`, `features.closedRecords`, `features.typedErrors`, and `features.typeParametersAndGenerics`. A role or semantic feature is not inferred from another role: browser Wasm has binary/application backends without a frontend or text backend, and the `ios` record has only its application backend. Neither has a source round trip, any semantic-feature flag, or general interoperability role. `supportedLanguages` is the derived list of fourteen records with both frontend and text generation. C#, Go, and C return two text artifacts; Rust and Dart return three; Wasm returns one binary and three text artifacts; iOS returns a deterministic multi-artifact SwiftUI/Xcode project model. Their callers use `generateArtifactSet()`; the legacy single-artifact APIs reject unavailable roles with `UNSUPPORTED_ROLE`.
27
+ `languageCapabilities` exposes all seventeen records as frozen data, including `features.generalFunctionsAndCalls`, `features.immutableCollections`, `features.optionalValues`, `features.orderedListIteration`, `features.orderedMapIteration`, `features.conditionControlledLoops`, `features.referenceClasses`, `features.effectfulCapabilitiesAndResources`, `features.closedRecords`, `features.typedErrors`, and `features.typeParametersAndGenerics`. A role or semantic feature is not inferred from another role: browser Wasm has binary/application backends without a frontend or text backend, while `ios` and `android` have only application backends. None has a source round trip or general interoperability role; Android retains the Kotlin/JVM Tasks 001–004 function subset while adding resolved Task 010 module linkage in its application shell. `supportedLanguages` is the derived list of fourteen records with both frontend and text generation. C#, Go, and C return two text artifacts; Rust and Dart return three; Wasm returns one binary and three text artifacts; iOS and Android return deterministic multi-artifact application projects. Their callers use `generateArtifactSet()`; the legacy single-artifact APIs reject unavailable roles with `UNSUPPORTED_ROLE`.
27
28
 
28
29
  ## Task 026 iOS application generation
29
30
 
@@ -31,6 +32,12 @@ The `ios` registry row means implemented deterministic generation/provenance; ma
31
32
 
32
33
  Generation validates the whole semantic graph and closed application configuration before returning deterministic captured Swift, a synthetic SwiftUI shell, unsigned project/configuration/test files, exact caller assets, and a versioned ownership/provenance manifest. Output/resource paths use a closed portable ASCII alphabet without restricting Unicode semantic source or generated text. No public materializer is shipped; the atomic no-replace and descriptor-relative no-follow contract requires a separately authorized native boundary. Linux proves Ruby-to-generated-Swift output and packed generator behavior; macOS/Xcode/Apple SDK/XCTest/XCUIAutomation/iOS Simulator behavior is not yet qualified. The complete contract and exclusions are in [iOS application target](ios.md).
33
34
 
35
+ ## Task 028 Android application generation
36
+
37
+ The `android` registry row is an application-only target over the independent Kotlin semantic capability profile. A closed request accepts one module or Task 010 project, optional normalized identity/version fields, and checksum-bound allowlisted resources/assets. It returns a byte-identical project under `generated/android-app` with mapped semantic Kotlin, a resettable output sink, one no-permission launcher Activity, one accessibility-important native TextView, build/tests, and a versioned ownership/toolchain/provenance manifest. Unknown configuration or filesystem/materialization controls, unsafe paths, unsupported resource qualifiers, SDK drift, collisions, and unsupported semantic nodes fail before output.
38
+
39
+ The generated build declares only exact non-transitive `testImplementation("junit:junit:4.13.2")` and `testRuntimeOnly("org.hamcrest:hamcrest-core:1.3")`; Kotlin's implicit stdlib dependency is disabled and no library enters the application runtime classpath. Official tool/cache preparation is online, but lint, unit, application APK, instrumentation APK, dependency inspection, and APK leakage checks execute with Gradle offline. TensorBuzz's `/dev/kvm` lane performs two fresh accelerated API-35 emulator boots with exact labelled-text and lifecycle assertions. No local software-emulator fallback, public writer, signing/store route, permission, service, Compose, WebView, NDK/JNI, source runtime, or platform channel exists. See [Android application target](android.md).
40
+
34
41
  ## Task 025 core expanded-language acceptance
35
42
 
36
43
  Python, C#, C, C++, Rust, Swift, Kotlin/JVM, and Go share one data-driven Tasks 001–004 acceptance gate. Their five base/scalar/local/operator/statement fixtures normalize to the same location-neutral semantic corpus; the pre-existing `select`/`choose` spelling difference is treated as a reserved-word adaptation only, not different behavior. Each backend generates, reparses, and runs the complete operator profile through its real registered toolchain. Python and Swift emit one source file; C++ emits one source file; C# and C emit two-file projects; Rust emits `Cargo.toml`, `Cargo.lock`, and `src/main.rs`; Kotlin emits mapped `Program.kt` with runnable-JAR metadata; and Go emits `go.mod` plus `main.go`.
@@ -126,6 +126,8 @@ Dart's `bin/program.dart` maps function names, parameter and local types/names,
126
126
 
127
127
  The iOS project manifest adds an application-specific provenance index without widening the generic mapping schemas. Mapped per-module semantic Swift retains the ordinary rich/v3 chain to its original Task 010 sources, including Ruby. Synthetic project, SwiftUI, runtime, test, configuration, and base asset-catalog files carry explicit source-free reasons. `SemantifoldIosProject` version 1 records renderer-owned configuration-field citations by manifest pointer and causal output ranges, exact caller asset representation/media type/SHA-256, source hashes and participating Swift artifacts, complete ordered owned paths, and exclusions. Its nested `SemantifoldIosSemanticProgram` version 1 section preserves caller-order source identities/ownership/hashes, dependency-order module IDs and dependencies, generated namespaces/artifacts, and the selected entry module/function linkage. Binary assets retain byte provenance across their exact full content. See [iOS application target](ios.md).
128
128
 
129
+ The Android project uses the same separation without sharing platform syntax with iOS. Every per-module semantic Kotlin artifact has authoritative rich/v3 mappings to all Task 010 source identities and filenames. Gradle, manifest, Activity, lifecycle, layout, resources, runtime, and test artifacts are synthetic or configuration-derived. `SemantifoldAndroidProject` version 1 records field-owned output ranges, exact input and output hashes, fixed-root ownership/exclusions, semantic module/dependency/source/entry linkage, and exact toolchain pins. Binary caller inputs retain full byte provenance. See [Android application target](android.md).
130
+
129
131
  ## Source Map v3 and directives
130
132
 
131
133
  `artifact.sourceMap` exists for all single-text target artifacts and mapped multi-artifact text outputs; browser Wasm additionally has the external binary projection described above. Maps are generated with `@jridgewell/gen-mapping`, while lookup, import, artifact validation, and independent test decoding use `@jridgewell/trace-mapping`. Semantifold does not hand-code VLQ or tracing. Text artifact validation requires dense `sources`, `names`, and optional `sourcesContent` arrays, canonical standard segments, valid indexes, and equality with the authoritative rich mapping projection. The v3 map contains deterministic `file`, `sources`, `sourcesContent`, `names`, and `mappings` fields.
@@ -0,0 +1,5 @@
1
+ # Application artifact specification
2
+
3
+ Application targets are target-only registry roles over semantic IR. They consume exactly one semantic module or one complete Task 010 program, validate their entire configuration/capability/path graph before rendering, and return one immutable in-memory `GeneratedArtifactSet`. Platform lifecycle, UI, build, resource, signing, and host syntax never enter semantic nodes.
4
+
5
+ The delivered Android profile is specified in [Android application target](android.md). Its fixed `generated/android-app` ownership root, closed input records, mapped semantic Kotlin, synthetic native Activity/view, no-permission manifest, toolchain pins, offline build, exact JUnit/Hamcrest test-only exception, and KVM emulator proof are normative. The partial Apple profile remains specified separately in [iOS application target](ios.md).
package/docs/testing.md CHANGED
@@ -469,6 +469,21 @@ Transactional create-only directory materialization is deferred. Node's public f
469
469
 
470
470
  These are not Apple platform acceptance. Per the 2026-09-14 owner direction to defer OSX work, no local or TensorBuzz command runs `xcodebuild`, downloads an Apple runtime, boots/installs/launches an iOS Simulator, configures signing, or executes XCTest/XCUIAutomation. AC07 and AC12–AC14 remain deferred, missing prerequisites may not be skipped to green, and no fake acceptance spec or manufactured TensorBuzz lane is permitted. The [iOS application target](ios.md) records the precise partial status.
471
471
 
472
+ ## Task028 Android application acceptance
473
+
474
+ Run the Android generation, private materialization, toolchain contract, and packed-consumer specs individually. The first three are local and do not install or invoke an emulator:
475
+
476
+ ```sh
477
+ npx velocious-test spec/android-application.spec.js
478
+ npx velocious-test spec/android-materialization.spec.js
479
+ npx velocious-test spec/android-toolchain-contract.spec.js
480
+ npx velocious-test spec/android-packed-consumer.spec.js
481
+ ```
482
+
483
+ Generation coverage validates multi-module/Unicode capture, mappings, configuration causality, deterministic fixed-root ownership, manifest/UI/dependency shape, resources/assets, collisions, and preflight diagnostics. Materialization is repository-private acceptance support: it requires an empty mode-0700 non-symlink directory, creates files exclusively, verifies checksum readback, and is neither exported nor packed. The packed proof uses clean public-registry npm install/ci and strict TypeScript consumption.
484
+
485
+ TensorBuzz's Android lane runs `scripts/bootstrap-android.sh` online to checksum and prefetch only the qualified official toolchain/cache, including the exact Kotlin 2.2.10 compiler distribution used as a compile-only tool input while the Gradle stdlib dependency stays disabled. `scripts/accept-android.sh` then creates a fresh project and runs lint, JUnit, application/instrumentation assembly, dependency inspection, and APK leakage checks with `--offline`. It requires an empty application runtime graph; the unit-test graph must contain exactly non-transitive JUnit 4.13.2 at implementation scope and Hamcrest Core 1.3 at runtime scope because the JUnit runner loads Hamcrest before test code. Neither dependency nor Kotlin runtime implementation namespaces may appear in the app APK. `scripts/android-emulator-acceptance.sh` requires usable `/dev/kvm`, forces acceleration, installs/launches/asserts exact base64-encoded UTF-8 output through platform instrumentation, captures UI XML/screenshots, destroys the emulator, and repeats on a fresh boot. Missing tools/cache/KVM are infrastructure failures, never skips. Do not run this emulator script locally without KVM or substitute software emulation.
486
+
472
487
  ## Task022 Swift acceptance
473
488
 
474
489
  Swift generation returns exactly one mapped `program.swift`. Focused frontend/backend specs cover all five Tasks001–004 fixtures, parser recovery, excluded syntax, malformed IR, target identifiers, compile-time-known signed-64-bit overflow, deterministic artifacts, rich/V3 provenance, exact helper validation, generated reparse, every Swift-to-original-five runtime route, and one original-five-to-Swift route per profile. Original-five execution invokes real PHP, Ruby, Node, TypeScript/Node, and Java compiler/runtime commands; unavailable tools fail.
package/index.js CHANGED
@@ -97,8 +97,9 @@ export function generateArtifact(input) {
97
97
  * @param {import("./src/semantic/types.js").BackendLanguage} input.language - Registered program target.
98
98
  * @param {import("./src/semantic/types.js").SemanticProgram} input.program - Complete resolved program.
99
99
  * @param {"text" | "application"} [input.role] - Explicit role; omitted preserves text generation.
100
- * @param {import("./src/semantic/types.js").IosApplicationConfigurationInput} [input.configuration] - iOS application configuration.
101
- * @param {import("./src/semantic/types.js").IosApplicationAssetInput[]} [input.assets] - Exact iOS caller assets.
100
+ * @param {import("./src/semantic/types.js").IosApplicationConfigurationInput | import("./src/semantic/types.js").AndroidApplicationConfigurationInput} [input.configuration] - Application configuration.
101
+ * @param {import("./src/semantic/types.js").IosApplicationAssetInput[] | import("./src/semantic/types.js").AndroidApplicationInputFile[]} [input.assets] - Exact caller assets.
102
+ * @param {import("./src/semantic/types.js").AndroidApplicationInputFile[]} [input.resources] - Exact Android caller resources.
102
103
  * @returns {import("./src/semantic/types.js").GeneratedArtifactSet} Complete generated set.
103
104
  */
104
105
  export function generateProgramArtifactSet(input) {
@@ -115,8 +116,9 @@ export function generateProgramArtifactSet(input) {
115
116
  * @param {"none" | "external" | "inline"} [input.mapDirective] - JavaScript-family map directive.
116
117
  * @param {string} [input.sourceMapFilename] - External map filename.
117
118
  * @param {{filename: string, content: string, language?: import("./src/semantic/types.js").SemanticLanguage}[]} [input.sources] - Original sources.
118
- * @param {import("./src/semantic/types.js").IosApplicationConfigurationInput} [input.configuration] - iOS application configuration.
119
- * @param {import("./src/semantic/types.js").IosApplicationAssetInput[]} [input.assets] - Exact iOS caller assets.
119
+ * @param {import("./src/semantic/types.js").IosApplicationConfigurationInput | import("./src/semantic/types.js").AndroidApplicationConfigurationInput} [input.configuration] - Application configuration.
120
+ * @param {import("./src/semantic/types.js").IosApplicationAssetInput[] | import("./src/semantic/types.js").AndroidApplicationInputFile[]} [input.assets] - Exact caller assets.
121
+ * @param {import("./src/semantic/types.js").AndroidApplicationInputFile[]} [input.resources] - Exact Android caller resources.
120
122
  * @returns {import("./src/semantic/types.js").GeneratedArtifactSet} Complete generated set.
121
123
  */
122
124
  export function generateArtifactSet(input) {
@@ -127,7 +129,7 @@ export function generateArtifactSet(input) {
127
129
  message: "Artifact-set generation requires a request object."
128
130
  })
129
131
  }
130
- const {assets, configuration, filename, language, mapDirective, module, role = "text", sourceMapFilename, sources} = input
132
+ const {assets, configuration, filename, language, mapDirective, module, resources, role = "text", sourceMapFilename, sources} = input
131
133
 
132
134
  if (typeof language != "string" || language.length == 0) {
133
135
  throw new SemantifoldDiagnostic({
@@ -219,5 +221,6 @@ export function generateArtifactSet(input) {
219
221
  const registryRole = role == "binary" ? "binaryBackend" : "applicationBackend"
220
222
  const backend = languageRegistry.resolve(language, registryRole, module?.location)
221
223
 
222
- return constructArtifactSet(backend({assets, configuration, filename, language, mapDirective, module, sourceMapFilename, sources}))
224
+ return constructArtifactSet(backend(language == "android" ? input :
225
+ {assets, configuration, filename, language, mapDirective, module, resources, sourceMapFilename, sources}))
223
226
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semantifold",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Language-neutral semantic code analysis, transformation, generation, and execution toolkit",
5
5
  "type": "module",
6
6
  "main": "build/index.js",