Skip to content

Preserve initialized source data in TypeScript input witnesses - #570

Open
CaelmBleidd wants to merge 1 commit into
caelmbleidd/ts-original-input-witnessesfrom
caelmbleidd/ts-initial-global-bindings
Open

CaelmBleidd wants to merge 1 commit into
caelmbleidd/ts-original-input-witnessesfrom
caelmbleidd/ts-initial-global-bindings

Conversation

@CaelmBleidd

@CaelmBleidd CaelmBleidd commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Concrete entry witnesses currently omit source static fields and module data. Reading those values from the final heap is also incorrect after the target mutates an initializer-created object or array. This change retains a persistent heap view after natural initialization and resolves each touched source data binding from that view, using the same identity cache as the original receiver and arguments.

For example, a static object initialized with value = 31 and changed to 92 during the target now resolves to 31 in the entry environment and 92 in the current environment. Later natural initializers update earlier owners' baseline until user code first observes environment data; initializer-internal accesses do not create target-input bindings.

Depends on #561. Review this PR before the concrete Calls candidate consumer (#568).

The materialization boundary is explicit:

  • resolveInputs requests source environment data by default; callers can explicitly request original roots only with resolveEnvironment = false.
  • Existing resolve callers retain their previous inputs/result contract; complete environment resolution is opt-in there.
  • Incomplete initializers, interleaved lazy initialization after a user data access, conflicting allocated input aliases across memory views, callable/private restoration, and sparse initialized arrays report TsUnsupportedEnvironmentWitnessException. Dense arrays and aliases between captured static values are supported.
  • Metadata capture failures are recorded without changing program execution. The witness resolver reports them later, allowing a consumer to retain a partial roots-only candidate with a diagnostic.

No symbolic state/constraint graph is serialized. These persistent memory views remain in RAM; the downstream consumer writes concrete values.

Validation: 19 selected tests pass (9 new environment regressions, 2 original-input resolver regressions, 3 Globals, 3 StaticFieldTypedWrite, 2 StaticInitializationMarker), with zero skipped or failed tests. Strict TS main/test detekt passes with zero issues. The tests cover initialized primitive/object/dense-array values before and after mutation, module reassignment, alias identity, first lazy initialization, cross-initializer mutation, explicit sparse/interleaved rejection, recording failures that preserve normal returned states, legacy result conversion, and stopped initializers that retain explicit partial roots. Broad suites are left to CI. Native experiment replay and persistence costs are measured in the dependent consumer work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant