Enforce declared visual subclass field contracts before native effects
Verify Tessera GUI / verify (push) Failing after 7m46s
Verify Tessera GUI / verify (push) Failing after 7m46s
This commit is contained in:
+2
-2
@@ -7,7 +7,7 @@
|
||||
| activity.rs | Bounded in-memory HTTP exchanges with marked previews and allowlisted request headers |
|
||||
| endor_host.rs | Aster compilation, fresh PUT candidates retained after successful publication, shared Console/program VM, asynchronous completion/fault boundaries, bounded execution, root cleanup and AST developer tree for function/class/member assignment nodes |
|
||||
| endor_script.rs | Batch complete inputs for Aster's Interactive parser/compiler, retain Module entry, and rebase Aster spans to the original snapshot |
|
||||
| ui_bridge.rs | Inheritable native nominal constructors with source fields, shared type method tables and bound receiver dispatch, configured unified Function classification and source annotation checks, tab registry, stable-slot insertion, source-dispatched tab reorder/drop, Page lifecycle/navigation and immutable frame extraction |
|
||||
| ui_bridge.rs | Inheritable native nominal constructors with source fields, shared type method tables and bound receiver dispatch, configured unified Function classification and source/field annotation checks with native constructor preflight, tab registry, stable-slot insertion, source-dispatched tab reorder/drop, Page lifecycle/navigation and immutable frame extraction |
|
||||
| binding.rs | Target-owned managed property bindings, weak Subscription tokens, read-only compute and borrowed dependency/output caches |
|
||||
| block.rs | Aster-managed Block/Cell/data graph, stable child slots, content-owned field storage, shared assignment, cycle validation and explicit text bindings |
|
||||
| snapshot.rs | Property and visual-method identity dependencies across shared field-storage paths, reverse parent links and cached immutable visual derivation |
|
||||
@@ -58,7 +58,7 @@ contain only immutable native data.
|
||||
Tests in api.rs execute real HTTP CRUD, persistent Console/reset/PUT isolation and a controlled queued-PUT/DELETE race
|
||||
without opening a window. Tests in endor_host.rs cover lifecycle, direct script and
|
||||
module entry, page methods, stable-slot insertion and tab drop/override/stale-target behavior, multiline inputs, original source ranges, malformed input,
|
||||
owner/task cancellation, hidden-object delivery, stale request and callback failure, entry checks, source function annotation/function identity and REPL class redefinition, budgets, failure preservation, live object identity, explicit rendering,
|
||||
owner/task cancellation, hidden-object delivery, stale request and callback failure, entry checks, source function/declared-field annotation checks, constructor side-effect prevention, shared field forwarding/function identity and REPL class redefinition, budgets, failure preservation, live object identity, explicit rendering,
|
||||
compile-before-execute behavior and stale-result invalidation. They
|
||||
run only in remote CI. Font tests in text.rs and software_renderer.rs cover real
|
||||
advances, multiline height, fractional scaling, CJK fallback, grapheme-safe fitting,
|
||||
|
||||
+5
-3
@@ -1077,7 +1077,7 @@ expose actual type relations. Types, bases, instances and native constructors li
|
||||
in the same GC graph. Ordinary source classes support `class Child: Base`, typed field
|
||||
declarations, explicit first `self` parameters, positional field construction and
|
||||
member assignment. Inherited methods bind the actual receiver; overridden methods
|
||||
are dynamically selected through self. Concrete native visual subclasses reuse real native allocators; abstract bases remain unconstructible. Explicit traits and source parameter/return annotation checks are enabled; field-write constraints and static/effect typing remain pending. Native Block/Page methods use the same type method tables and binding path.
|
||||
are dynamically selected through self. Concrete native visual subclasses reuse real native allocators; abstract bases remain unconstructible. Explicit traits and source parameter/return annotation checks are enabled; declared-field construction/write checks are enabled alongside source function checks; complete initialization and static/effect typing remain pending. Native Block/Page methods use the same type method tables and binding path.
|
||||
|
||||
Window is a host-provided managed resource: ui.window(), page.window(), page.open(window), window.pages()/id()/viewport(), resize(width,height), moveTo(x,y), setTitle(text) and focus(). Requests project to their actual native window only after successful input/candidate completion and carry the current runtime session. Resize is asynchronous and the reported viewport is authoritative; this host accepts 1..4096 logical dimensions with a native 720x480 minimum. Failed input/candidates discard pending requests and read-only rendering rejects window effects. Open Pages appear in native tab chrome, with page.title, click activation/close, Ctrl+Tab cycling and Cmd/Ctrl+W close when page keyboard focus is active. Overflow arrows reach additional pages. These operations call actual Page methods in the same VM; tab IDs are weak runtime projections and add no GC roots. The 36-logical-pixel bar reduces Page constraint height; window/ui viewport reports the full inner size and native pointer positions are translated into content coordinates. Window() now creates additional native windows in the same VM, up to 16 open resources. Page.open(window)/moveToWindow(window) preserve Page and business identity while replacing Mounts; detachToWindow() creates and returns a new Window. Dragging a tab away from its strip invokes the same method. Window.close()/secondary OS close remove Page roots, unmount, and retire the resource context; retained Pages can reopen in another live window, and closed Window resources reject viewport/resize/title/focus operations. Closing the primary OS shell exits the application. Secondary viewport inputs and frame publication use the same worker. Secondary close after callback/rendering failure uses host-only teardown without invoking source callbacks or resuming execution. After reset/discard, closing an old picture never touches a fresh VM resource with the same number; viewport inputs are also generation-scoped. A teardown failure discards the affected VM and disables remaining pictures. Native initialization/surface errors are reported rather than panicking; failed secondary creation leaves a managed resource closable from Console. Native tab reordering, existing-window drops and release-point placement use the managed methods described below. Full application-exit notifications remain pending.
|
||||
|
||||
@@ -1093,9 +1093,11 @@ Native wheel POST /events uses kind scroll with the normal window/session/layout
|
||||
|
||||
ui.after(owner,key,milliseconds,callback) returns Task. The zero-argument callback runs on the owning VM worker after at least the integer 0..86400000 ms delay and must return Unit. Idle polling can add up to 100 ms; execution load may delay delivery further. Task.cancel/active/status expose cancellation, eligibility and pending/running/completed/cancelled/failed state. One owner/key replaces the prior pending task. Owner scopes and callback captures are managed strong edges; scheduler and owner links are weak. ui is an application owner. Hidden live objects continue; Page close cancels its and its Mount tasks, even close/reopen within one input. Page movement preserves Page tasks but replaces Mounts. Window close cancels its Pages/tasks; reset/DELETE/program replacement discard old scheduler/VM and generation checks reject stale publication. Failed PUT preserves old tasks. Callback failure stops the domain and cancels remaining tasks; earlier writes do not roll back. Read-only rendering cannot schedule/cancel. Limits: 64 pending per owner, 1024 per runtime, 64 delivered per poll, 128 frames/100000 instructions per callback. Providers currently support timers; network/file providers and await are pending.
|
||||
|
||||
Source function parameter annotations are checked before the body and return annotations before returning. Object accepts any live value; Unit accepts nil; Number, String/Text and Bool match scalar kinds. Function includes source/native functions and bound methods, while callable class definitions remain Type. View is a compatibility alias for Block. Other names resolve actual Type/Trait objects in the function's globals then captured builtins at each call. The method's own class uses the receiver's actual owning definition, preserving old bound methods after REPL redefinition. Other type names are not frozen at definition. UnknownAnnotation and TypeMismatch report failures; bad returns do not roll back earlier writes. No static inference, field-write validation, override variance, generic or effect typing is provided.
|
||||
Source function parameter annotations are checked before the body and return annotations before returning. Object accepts any live value; Unit accepts nil; Number, String/Text and Bool match scalar kinds. Function includes source/native functions and bound methods, while callable class definitions remain Type. View is a compatibility alias for Block. Other names resolve actual Type/Trait objects in the function's globals then captured builtins at each call. The method's own class uses the receiver's actual owning definition, preserving old bound methods after REPL redefinition. Other type names are not frozen at definition. UnknownAnnotation and TypeMismatch report failures; bad returns do not roll back earlier writes. Declared-field construction and set_attr writes are also checked, as described below. Static inference, override variance, generic and effect typing remain pending.
|
||||
|
||||
Trait definitions Visual, EventTarget, Children and Presentable are managed nominal capabilities. ui.implement(type,capability) explicitly declares an implementation after required-method/positional-arity checks; ui.implements(type,capability) and ui.supports(value,capability) query it. Block declares Visual/EventTarget; ContainerBlock declares Children, inherited by Page. Same-name methods alone never declare an implementation. Source subclass construction and host method replacement validate inherited/affected descendant contracts. Native callable signatures are trusted; source parameter/return annotations are checked at invocation. Native signature metadata, field-write and effect checks and formal trait syntax remain pending. EventTarget requires canonical on/dispatch/onEvent arities 3/2/1 after self; native optional convenience forms remain.
|
||||
Declared fields are checked at construction and set_attr writes through the same enabled type-check switch. Native subclass fields are validated before native allocation/opening effects. Failure preserves the field; declared deletion is rejected. Inherited fields use their declaring definition/environment, the declaring class name keeps its actual identity after REPL redefinition, and other names resolve dynamically in declaration globals/builtins. Shared Block forwarding selects the current content type/storage. This does not scan old objects or revalidate all referring fields after shared-reference changes; trusted payload/storage/attach operations and complete initialization remain host responsibilities. Static/effect typing, override variance and local/captured type annotations remain pending. See examples/field-contracts.endor.
|
||||
|
||||
Trait definitions Visual, EventTarget, Children and Presentable are managed nominal capabilities. ui.implement(type,capability) explicitly declares an implementation after required-method/positional-arity checks; ui.implements(type,capability) and ui.supports(value,capability) query it. Block declares Visual/EventTarget; ContainerBlock declares Children, inherited by Page. Same-name methods alone never declare an implementation. Source subclass construction and host method replacement validate inherited/affected descendant contracts. Native callable signatures are trusted; source parameter/return annotations are checked at invocation. Native signature metadata, effect checks and formal trait syntax remain pending. EventTarget requires canonical on/dispatch/onEvent arities 3/2/1 after self; native optional convenience forms remain.
|
||||
|
||||
For a plain object explicitly implementing Presentable, present(self, window: Window): Block is invoked by ui.present(value) or ui.open(value), using the current managed Window and the same VM budget. The result must be an actual Block. Blocks pass through directly; unregistered values retain the summary fallback. Source views retain their business object via managed fields/callbacks/bindings, as in examples/presentable.endor. Viewing function definitions does not itself execute them. Rendering methods still run read-only with nominal result checks.
|
||||
|
||||
|
||||
@@ -993,6 +993,106 @@ mod tests {
|
||||
const EXAMPLE: &str = include_str!("../examples/hello.endor");
|
||||
const PAGE: &str = include_str!("../examples/page.endor");
|
||||
|
||||
#[test]
|
||||
fn checked_fields_reject_native_constructor_side_effects_and_preserve_live_values() {
|
||||
let (mut session, _) = ReplSession::load(
|
||||
include_str!("../examples/field-contracts.endor"),
|
||||
"app.main",
|
||||
1,
|
||||
210,
|
||||
)
|
||||
.unwrap();
|
||||
for invalid in [
|
||||
r#"counter.value = "wrong""#,
|
||||
r#"CounterText("bad", "wrong")"#,
|
||||
"Model(42)",
|
||||
] {
|
||||
let error = session.execute(invalid, "app.main").err().unwrap();
|
||||
assert!(error.to_string().contains("field"), "{error:#}");
|
||||
assert!(
|
||||
session.documents[&crate::window::MAIN_WINDOW]
|
||||
.frame
|
||||
.fault
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
session.execute("counter.value", "app.main").unwrap().value,
|
||||
"9"
|
||||
);
|
||||
session
|
||||
.execute("class CheckedPage: Page { count: Number }", "app.main")
|
||||
.unwrap();
|
||||
let pages = session
|
||||
.execute("ui.window().pages().count", "app.main")
|
||||
.unwrap()
|
||||
.value;
|
||||
assert!(
|
||||
session
|
||||
.execute(r#"CheckedPage("wrong")"#, "app.main")
|
||||
.is_err()
|
||||
);
|
||||
assert_eq!(
|
||||
session
|
||||
.execute("ui.window().pages().count", "app.main")
|
||||
.unwrap()
|
||||
.value,
|
||||
pages
|
||||
);
|
||||
let updated = session
|
||||
.execute("button.click()", "app.main")
|
||||
.unwrap()
|
||||
.document
|
||||
.unwrap();
|
||||
assert!(
|
||||
updated.frame.commands.iter().any(
|
||||
|command| matches!(command, RenderCommand::Text { value, .. } if value == "10")
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
session.execute("counter.value", "app.main").unwrap().value,
|
||||
"10"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checked_fields_follow_shared_block_forwarding_and_binding_writes() {
|
||||
let (mut session, _) = ReplSession::load(
|
||||
r#"
|
||||
class Numeric: TextBlock { value: Number }
|
||||
class Textual: TextBlock { value: String }
|
||||
block = Numeric("old", 9)
|
||||
alias = block
|
||||
page = Page()
|
||||
page.render(block)
|
||||
"#,
|
||||
"app.main",
|
||||
1,
|
||||
211,
|
||||
)
|
||||
.unwrap();
|
||||
session
|
||||
.execute(r#"block = Textual("new", "kept")"#, "app.main")
|
||||
.unwrap();
|
||||
assert!(session.execute("alias.value = 42", "app.main").is_err());
|
||||
assert_eq!(
|
||||
session.execute("alias.value", "app.main").unwrap().value,
|
||||
r#""kept""#
|
||||
);
|
||||
session
|
||||
.execute(r#"alias.value = "updated""#, "app.main")
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
session.execute("block.value", "app.main").unwrap().value,
|
||||
r#""updated""#
|
||||
);
|
||||
assert!(
|
||||
session
|
||||
.execute("alias.bind(\"value\", ui.viewport)", "app.main")
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn positional_insert_preserves_existing_slots_and_mounts_and_rejects_invalid_graphs() {
|
||||
let source = r#"head=TextBlock("head")
|
||||
|
||||
@@ -345,6 +345,8 @@ impl NativeCallable for NativeFactory {
|
||||
.len()
|
||||
.checked_sub(fields.len())
|
||||
.ok_or(invalid("missing subclass field arguments"))?;
|
||||
cx.store()
|
||||
.check_class_field_arguments(requested, &values[native_count..])?;
|
||||
let result = Function {
|
||||
operation: self.operation,
|
||||
owner: None,
|
||||
|
||||
Reference in New Issue
Block a user