Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/source-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jobs:
sudo apt-get install --no-install-recommends -y \
build-essential cmake ninja-build python3 pandoc \
libffi-dev libtinfo-dev libx11-dev zlib1g-dev libzstd-dev \
libsqlite3-dev libpq-dev postgresql-16
libsqlite3-dev libpq-dev postgresql-16 \
libgtk-4-1 xvfb xauth libxtst6 dbus-daemon
if [ "$NIL_CI_LLVM" = ON ]; then
sudo apt-get install --no-install-recommends -y llvm-18-dev
fi
Expand Down
52 changes: 52 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ if(BUILD_TESTING)
add_test(NAME nil.database-runtime COMMAND $<TARGET_FILE:ny_database_runtime_tests>)
set_tests_properties(nil.database-runtime PROPERTIES LABELS "database;runtime" SKIP_RETURN_CODE 77 TIMEOUT 60)

add_executable(nil_ui_runtime_tests tests/ui_runtime_tests.cpp)
target_link_libraries(nil_ui_runtime_tests PRIVATE nilruntime Threads::Threads)
target_include_directories(nil_ui_runtime_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/nilcompiler/src")
target_compile_features(nil_ui_runtime_tests PRIVATE cxx_std_17)
add_test(NAME nil.ui-runtime COMMAND $<TARGET_FILE:nil_ui_runtime_tests>)
set_tests_properties(nil.ui-runtime PROPERTIES LABELS "ui;runtime" TIMEOUT 30)
add_executable(nil_ui_lifecycle_tests tests/ui_lifecycle_tests.cpp)
target_link_libraries(nil_ui_lifecycle_tests PRIVATE nilcompiler_core nilruntime ${CMAKE_DL_LIBS})
target_compile_features(nil_ui_lifecycle_tests PRIVATE cxx_std_17)

add_executable(ny_native_owned_tests tests/native_owned_tests.cpp)
target_link_libraries(ny_native_owned_tests PRIVATE nilruntime Threads::Threads)
target_include_directories(ny_native_owned_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/nilcompiler/src")
Expand Down Expand Up @@ -433,6 +443,39 @@ if(BUILD_TESTING)
# test suite when testing was explicitly enabled.
find_package(Python3 3.8 REQUIRED COMPONENTS Interpreter)
if(Python3_Interpreter_FOUND)
find_program(NIL_UI_XVFB NAMES Xvfb DOC "Optional Xvfb for isolated desktop UI tests")
add_test(NAME nil.ui-display
COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/tools/ui_display_contract.py"
--xvfb "${NIL_UI_XVFB}"
--tester $<TARGET_FILE:niltest> --compiler $<TARGET_FILE:nilcompiler>
--interpreter $<TARGET_FILE:nilinterpreter>
--sdk "${CMAKE_CURRENT_SOURCE_DIR}/nilstd/src"
--source "${CMAKE_CURRENT_SOURCE_DIR}/tests/ui/gtk_desktop.matrix"
--interaction-source "${CMAKE_CURRENT_SOURCE_DIR}/tests/ui/gtk_interaction.matrix"
--provider-test $<TARGET_FILE:nil_ui_runtime_tests>
--lifecycle-test $<TARGET_FILE:nil_ui_lifecycle_tests>
--llvm "${NIL_ENABLE_LLVM}")
set_tests_properties(nil.ui-display PROPERTIES LABELS "ui;routes" SKIP_RETURN_CODE 77 TIMEOUT 240)
add_test(NAME nil.ui-intrinsic-contract
COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/tools/ui_intrinsic_contract.py"
--compiler $<TARGET_FILE:nilcompiler> --interpreter $<TARGET_FILE:nilinterpreter>
--llvm "${NIL_ENABLE_LLVM}")
set_tests_properties(nil.ui-intrinsic-contract PROPERTIES LABELS "ui;routes;typecheck" TIMEOUT 180)
add_test(NAME matrix.consider-block-contract
COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/matrix/consider_block_contract.py"
--compiler $<TARGET_FILE:nilcompiler> --interpreter $<TARGET_FILE:nilinterpreter>
--tester $<TARGET_FILE:niltest> --llvm "${NIL_ENABLE_LLVM}")
set_tests_properties(matrix.consider-block-contract PROPERTIES LABELS "matrix;routes" TIMEOUT 120)
set(NIL_UI_TEST_ROUTES vm)
if(NIL_ENABLE_LLVM)
set(NIL_UI_TEST_ROUTES all)
endif()
add_test(NAME nil.ui-models
COMMAND $<TARGET_FILE:niltest> run
--compiler $<TARGET_FILE:nilcompiler> --interpreter $<TARGET_FILE:nilinterpreter>
--target ${NIL_UI_TEST_ROUTES} --filter nil.std.ui.models
"${CMAKE_CURRENT_SOURCE_DIR}/nilstd/src/ui/models.matrix")
set_tests_properties(nil.ui-models PROPERTIES LABELS "ui;routes" TIMEOUT 60)
set(NY_IDENTITY_TEST_ARGUMENTS)
foreach(tool IN ITEMS nilcompiler nilinterpreter nilassembler nillinker nillsp nildebugger nilschema nilagent nilbuild niltest)
if(TARGET ${tool})
Expand Down Expand Up @@ -1916,6 +1959,15 @@ if(BUILD_TESTING)
--expected-exit 0
--routes all
)
foreach(nil_enum_language IN ITEMS ny matrix)
add_ny_route_test(
nil.routes.enum-assignment-context-${nil_enum_language}
--source "${CMAKE_CURRENT_SOURCE_DIR}/tests/language/enum-assignment-context.${nil_enum_language}"
--expected-stdout "${CMAKE_CURRENT_SOURCE_DIR}/tests/language/enum-assignment-context.stdout"
--expected-exit 0 --routes all
--compiler-arg=--sdk-path
--compiler-arg=${CMAKE_CURRENT_SOURCE_DIR}/nilstd/src)
endforeach()
add_ny_route_test(
ny.routes.native-rejects-unknown-nominal-signature
--source "${CMAKE_CURRENT_SOURCE_DIR}/tests/language/native-unknown-nominal-signature.ny"
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ The framework includes:
workspace snapshot. Compiler-resolved source bindings support Go to Definition
for local variables, parameters and imported functions across both languages.
Certified local variables also support references and checked rename.
- **Tests beside code.** `niltest` discovers compiler-checked test declarations,
annotated functions, and suites in Ny and Matrix. Inline test regions can
check a function's local state. Cases run in isolated VM or native processes
and appear in VS Code's Test Explorer. See the
[testing guide](docs/tools/testing.md).
- **Desktop applications.** The Matrix-authored
[`nil.std.ui`](docs/standard-library/ui.md) provides windows, layout containers,
standard controls, typed events, and explicit model synchronization. Its first
backend uses the optional GTK 4 runtime on Linux, on both execution routes.
- **Aperture runtime diagnostics.** Memory profiles record runtime allocations,
frees, retained storage, peaks and source locations for VM and native programs.
Saved JSON reports support inspection and automated analysis. See
Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ command-line help, and executable tests as bugs.
- [Standard-library status](standard-library/index.md) — layout, maturity, and
what is deliberately outside the core library.
- [NILData](standard-library/nildata.md) — structured data, JSON interchange and explicit NyData migration.
- [Tests beside code](tools/testing.md) — co-located suites, inline checks and VM/native execution.
- [Desktop UI](standard-library/ui.md) — Matrix windows, layouts, controls and typed events.
- [Examples](../examples/README.md) — small examples tied to repository fixtures.
- [Matrix](../matrix/README.md) — prose-oriented frontend, syntax, and examples.
- [Ny](../ny/README.md) — systems-language frontend and reference entry point.
Expand Down
73 changes: 73 additions & 0 deletions docs/design/NIL-0025-matrix-desktop-ui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# NIL-0025: Matrix desktop UI

Status: initial Linux desktop profile.

## Purpose

Provide a standard application UI library authored in Matrix, usable from Ny
and Matrix through the same VM and native runtime. The public library and
provider code use the repository's MIT license. GTK remains an optional system
dependency under its own license; the SDK does not redistribute it.

The earlier `packages/ny.ui.mimic` and `nilaix` experiments are not the
implementation base. Their simulated or incomplete providers cannot establish
desktop behavior. The new library lives under `nilstd/src/ui` with the public
identity `nil.std.ui`.

## Boundaries

Matrix owns typed Window, Widget, EventKind and Event values, constructors,
checked operations, event decoding, and text/flag model synchronization. A
small versioned `ui.v1.*` intrinsic boundary carries only Boolean, integer,
text, and the standard Result type. The checker, VM and LLVM backend validate
this ABI; a similarly named user enum is not an interchangeable Result.

The shared C++ runtime loads GTK 4 through its public opaque-pointer ABI on
Linux. Loading is optional and does not require toolkit development headers.
It never fabricates successful windows when a provider or display is missing.
Creating a window returns Result.Error with the reason in that case.

GTK callbacks enqueue copied events; they do not invoke arbitrary language
function pointers. `poll-event` returns Result of Option of Event: absence is
an empty queue, and failure is an error. Close requests are events which the
application can accept by explicitly closing the window. Programmatic setters
suppress change events, so explicit model synchronization cannot recursively
feed itself. This boundary leaves room for a future checked callback API.

## Resources

Each runtime context owns its window tree and snapshots. Handles are checked
identities, not addresses. Closing a window invalidates its children and queued
snapshots; cross-context and stale handles fail. Snapshot data is copied into
Matrix values and released even when decoding fails. VM completion, faults,
reset and native invocation completion release the context's resources.

The provider enforces its creation thread and one GTK thread per process.
Widget, window, text, event and snapshot counts are bounded. Text is valid UTF-8
without embedded NUL; Boolean properties accept only zero or one. Grid
placement rejects overlap and invalid parentage. Application code owns the
event loop and can use ordinary runtime timing primitives between polls.

## Verification and scope

Pure models have co-located niltest cases. Provider tests cover error paths,
resource lifetimes and toolkit state. An isolated authenticated Xvfb display
hosts the actual GTK windows for VM/native tests. XTest drives entry typing and
keyboard activation; a window-manager close message verifies close requests.
The harness never targets the developer's desktop. Missing Xvfb is an explicit
test skip, not desktop evidence.

The initial controls are row/column/grid layouts, labels, buttons, entries and
checkboxes, with common sizing, spacing, margins, visibility and sensitivity.
This is a foundation for application development. Declarative NILData views,
menus, dialogs, tree/table models, styling, richer bindings, accessibility
audits, application packaging and additional OS providers remain follow-up
work. GTK supplies native text rendering and control behavior; those features
must receive focused evidence before broader cross-platform claims.

## Public version presentation

Examples and public UI may display the generation as **NIL²**, followed by
NIL³, NIL⁴ and later generations. Plain-text surfaces can use `NIL^2`.
This presentation is separate from the Execute-format numeric release and
artifact identity in `VERSION`; this change does not cut or renumber a release.
1 change: 1 addition & 0 deletions docs/design/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ not assigned architecture identifiers.
| NIL-0022 | [Incremental project builds and NILData configuration](NIL-0022-incremental-project-builds.md) | Implemented initial local project graph and target scheduling profile |
| NIL-0023 | [Dynamic values and Boolean vocabulary](NIL-0023-dynamic-values-and-booleans.md) | Implemented |
| NIL-0024 | [Tests alongside source](NIL-0024-colocated-testing.md) | Implemented initial unit/integration profile |
| NIL-0025 | [Matrix desktop UI](NIL-0025-matrix-desktop-ui.md) | Initial Linux GTK 4 desktop profile |
| NIL-0093 | [Executable context is artifact self-description](NIL-0093-executable-context.md) | Implemented within the documented inspection profile |

## Retained Ny feature references
Expand Down
19 changes: 14 additions & 5 deletions docs/standard-library/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Standard-library status

Ny and Matrix share `nilstd`, one standard library compiled to NIL. Its active
Ny and Matrix sources form 17 logical SDK modules, including `prelude`.
Ny and Matrix sources form 18 logical SDK modules, including `prelude`.
Support remains evidence-scoped. Focused fixtures exercise `nilstd` and `nillib`
through textual/binary NIL, bundles, LLVM JIT and AOT, and standalone
assembler/linker pipelines. Local SDK qualification records the exact source
Expand Down Expand Up @@ -31,7 +31,7 @@ averaging, nonfinite compatibility behavior and numerical accuracy limits.

```text
nilstd/
src/ Ny and Matrix sources organized as 17 logical modules
src/ Ny and Matrix sources organized as 18 logical modules
native/ 14 preserved C and C++ interoperability shims
tests/ 8 preserved design-era library tests
experimental/ 65 quarantined Ny sources excluded from the SDK
Expand All @@ -43,7 +43,7 @@ remain aliases of the same module identities.

The active logical modules are `prelude` and `nil.std.core`, `collections`,
`datetime`, `db`, `diagnostics`, `io`, `math`, `net`, `nildata`, `reflection`, `runtime`,
`security`, `system`, `testing`, `text`, and `threading`. Quarantine is broader than parser
`security`, `system`, `testing`, `text`, `threading`, and `ui`. Quarantine is broader than parser
failure: an experimental source may compile yet still lack complete language
semantics, an executable provider, or behavioral evidence.

Expand All @@ -57,8 +57,8 @@ nillib/ matching strictly compiled binary NIL modules
For every source under `nilstd/path/module` (`.ny`, `.matrix`, or `.mat`), a complete SDK contains
`nillib/path/module.nil`. `manifest.json` records both inventories and hashes.

First-party engine and UI experiments are intentionally separate from the core
library:
The active [desktop UI library](ui.md) lives in `nilstd/src/ui` and is authored
in Matrix. The earlier engine and UI experiments remain separate:

```text
packages/ny.engine/
Expand All @@ -78,6 +78,15 @@ them in test blocks makes them test-only. See the
[co-located testing guide](../tools/testing.md) for language syntax, discovery,
execution routes, and editor integration.

## Desktop UI

`nil.std.ui` supplies checked windows, rows, columns, grids, labels, buttons,
text entries, and checkboxes. Copied typed events and explicit text/flag models
keep application logic in Matrix; the shared runtime owns native resources.
The initial provider uses GTK 4 on Linux and returns an explanatory error when
the optional provider or a display is unavailable. See the [UI reference](ui.md)
and [NIL² counter application](../../examples/projects/nil2-counter).

## NILData

`nil.std.nildata` provides checked, versioned data loading and serialization,
Expand Down
Loading
Loading