Skip to content

Commit 39bfefe

Browse files
committed
add statement from 1Password
1 parent 387ab4d commit 39bfefe

4 files changed

Lines changed: 296 additions & 3 deletions

File tree

refactor.html

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>ModuleRecord and friends
8+
9+
###################################################################################################
10+
11+
12+
Open this file in the browser to see the diagram rendered with working links and color coding
13+
14+
15+
(CMD/Ctrl)+Scroll to zoom in and out works
16+
17+
###################################################################################################
18+
19+
20+
21+
</title>
22+
<base target="_blank">
23+
</head>
24+
25+
<body>
26+
<div id="l">
27+
<span style="background: #ffe"><a href="https://tc39.es/proposal-source-phase-imports">proposal-source-phase-imports</a> <a href="https://github.com/tc39/proposal-source-phase-imports">[repo]</a></span>
28+
<span style="background: #fef"><a href="https://tc39.es/proposal-esm-phase-imports">proposal-esm-phase-imports</a> <a href="https://github.com/tc39/proposal-esm-phase-imports">[repo]</a></span>
29+
<span style="background: #afa">new</span>
30+
</div>
31+
<pre class="mermaid">
32+
33+
classDiagram
34+
class ModuleRecord {
35+
&lt;&lt;abstract>>
36+
[[Status]]
37+
-[[Realm]] : Realm Record
38+
+[[Container]] : Container Record
39+
[[Environment]] : Module Environment Record | EMPTY
40+
[[Namespace]] : Object | EMPTY
41+
[[SourceRecord]] : Module Source Record
42+
[[HostDefined]] : anything
43+
-[[Compartment]] : Compartment | EMPTY
44+
}
45+
link ModuleRecord "https://tc39.es/ecma262/multipage/ecmascript-language-scripts-and-modules.html#sec-abstract-module-records"
46+
47+
class CyclicModuleRecord {
48+
&lt;&lt;abstract>>
49+
[[Status]]
50+
[[EvaluationError]]
51+
[[DFSAncestorIndex]]
52+
[[RequestedModules]] : List~ModuleRequest Records~
53+
[[LoadedModules]] : List~LoadedModuleRequest Records~
54+
[[CycleRoot]]
55+
[[HasTLA]] : Boolean
56+
[[AsyncEvaluationOrder]]
57+
[[TopLevelCapability]]
58+
[[AsyncParentModules]]
59+
[[PendingAsyncDependencies]]
60+
}
61+
link CyclicModuleRecord "https://tc39.es/ecma262/multipage/ecmascript-language-scripts-and-modules.html#cyclic-module-record"
62+
63+
64+
class SourceTextModuleRecord {
65+
[[ECMAScriptCode]] : Parse Node
66+
[[Context]] : Execution Context | EMPTY
67+
[[ImportMeta]] : Object | EMPTY
68+
[[ImportEntries]] : List~ImportEntry Records~
69+
[[LocalExportEntries]] : List~ExportEntry Records~
70+
[[IndirectExportEntries]] : List~ExportEntry Records~
71+
[[StarExportEntries]] : List~ExportEntry Records~
72+
}
73+
link SourceTextModuleRecord "https://tc39.es/ecma262/multipage/ecmascript-language-scripts-and-modules.html#sourctextmodule-record"
74+
note for SourceTextModuleRecord "<a href=https://tc39.es/ecma262/multipage/ecmascript-language-scripts-and-modules.html#sec-source-text-module-record-initialize-environment>InitializeEnvironment()</a><br>to use [[ScopeCeiling]]<br>instead of realm.[[GlobalEnv]]<br>for NewModuleEnvironment(OuterEnv)<br>if [[ScopeCeiling]] not EMPTY"
75+
76+
class ScopeCeiling:::added {
77+
[[OuterEnv]] = null
78+
[[BindingObject]] handles the globalThis binding and var
79+
:
80+
inheriting from ObjectEnvironmentRecord is sufficient,
81+
but all bindings are dynamic andcould be slower than
82+
a mix of ObjectRecord and DeclarativeRecord
83+
}
84+
85+
class EnvironmentRecord {
86+
&lt;&lt;abstract>>
87+
[[OuterEnv]] : Environment Record | null
88+
}
89+
link EnvironmentRecord "https://tc39.es/ecma262/#sec-environment-records"
90+
91+
92+
93+
class DeclarativeEnvironmentRecord {
94+
}
95+
link DeclarativeEnvironmentRecord "https://tc39.es/ecma262/#sec-declarative-environment-records"
96+
97+
class ObjectEnvironmentRecord {
98+
[[BindingObject]] : Object
99+
[[IsWithEnvironment]] : Boolean
100+
}
101+
102+
class GlobalEnvironmentRecord {
103+
[[ObjectRecord]] : Object Environment Record
104+
[[GlobalThisValue]] : Object
105+
[[DeclarativeRecord]] : Declarative Environment Record
106+
[[OuterEnv]] = null
107+
}
108+
109+
class ModuleEnvironmentRecord {
110+
[[OuterEnv]] : Environment Record
111+
}
112+
link ModuleEnvironmentRecord "https://tc39.es/ecma262/#sec-module-environment-records"
113+
114+
class RealmRecord {
115+
[[AgentSignifier]]
116+
[[Intrinsics]]
117+
[[GlobalObject]] : Object
118+
[[GlobalEnv]] : Global Environment Record
119+
[[TemplateMap]]
120+
[[LoadedModules]]
121+
[[HostDefined]]
122+
}
123+
124+
class ExecutionContext {
125+
code evaluation state
126+
Function : function object | null
127+
Realm : Realm Record
128+
ScriptOrModule : Module Record | Script Record | null
129+
}
130+
link ExecutionContext "https://tc39.es/ecma262/multipage/executable-code-and-execution-contexts.html#sec-execution-contexts"
131+
note for ExecutionContext "<a href=https://tc39.es/ecma262/multipage/executable-code-and-execution-contexts.html#sec-resolvebinding>ResolveBinding()</a> consults ModuleEnvironmentRecord"
132+
133+
class ECMAScriptCodeExecutionContext {
134+
LexicalEnvironment : Environment Record
135+
VariableEnvironment : Environment Record
136+
PrivateEnvironment : PrivateEnvironment Record | null
137+
}
138+
link ECMAScriptCodeExecutionContext "https://tc39.es/ecma262/multipage/executable-code-and-execution-contexts.html#ecmascript-code-execution-context"
139+
140+
141+
ExecutionContext <|-- ECMAScriptCodeExecutionContext
142+
143+
ModuleRecord <|-- CyclicModuleRecord
144+
CyclicModuleRecord <|-- SourceTextModuleRecord
145+
EnvironmentRecord <|-- DeclarativeEnvironmentRecord
146+
EnvironmentRecord <|-- ObjectEnvironmentRecord
147+
EnvironmentRecord <|-- GlobalEnvironmentRecord
148+
DeclarativeEnvironmentRecord <|-- ModuleEnvironmentRecord
149+
150+
ModuleRecord --> RealmRecord : [[Realm]]
151+
ModuleRecord --> ModuleEnvironmentRecord : [[Environment]]
152+
SourceTextModuleRecord --> ECMAScriptCodeExecutionContext : [[Context]]
153+
ECMAScriptCodeExecutionContext --> RealmRecord : Realm
154+
RealmRecord --> GlobalEnvironmentRecord : [[GlobalEnv]]
155+
ModuleEnvironmentRecord ..> GlobalEnvironmentRecord : [[OuterEnv]]
156+
ModuleEnvironmentRecord ..> ScopeCeiling : +[[OuterEnv]]
157+
GlobalEnvironmentRecord --> ObjectEnvironmentRecord : [[ObjectRecord]]
158+
GlobalEnvironmentRecord --> DeclarativeEnvironmentRecord : [[DeclarativeRecord]]
159+
160+
ObjectEnvironmentRecord <|-- ScopeCeiling : would this suffice?
161+
162+
class AbstractModuleSource:::sourceproposal {
163+
&lt;&lt;abstract>>
164+
}
165+
link AbstractModuleSource "https://tc39.es/proposal-source-phase-imports/#sec-abstract-module-source-constructor"
166+
167+
class HostDefinedModuleSource:::sourceproposal {
168+
&lt;&lt;host-defined>>
169+
e.g. WebAssembly.Module
170+
}
171+
172+
class ModuleRequestRecord:::sourceproposal {
173+
[[Specifier]] : String
174+
[[Phase]] : source | evaluation
175+
[[Attributes]]
176+
}
177+
link ModuleRequestRecord "https://tc39.es/proposal-source-phase-imports/#sec-modulerequest-records"
178+
note for ModuleRequestRecord "<a href=https://tc39.es/proposal-esm-phase-imports/#sec-modulesourcesequal>ModuleSourcesEqual(a,b)</a> <br> compares [[HostDefined]] too. <br> could consider Compartment"
179+
180+
class ModuleSourceRecord:::esmphaseproposal {
181+
[[HostDefined]] : anything
182+
[[SourceText]] : source text | NONE
183+
[[ModuleSourceKind]] : String
184+
[[ModuleSource]] : Object | EMPTY
185+
}
186+
link ModuleSourceRecord "https://tc39.es/proposal-esm-phase-imports/#module-source-record"
187+
188+
class ModuleSource:::esmphaseproposal {
189+
[[ModuleSourceRecord]] : Module Source Record
190+
}
191+
link ModuleSource "https://tc39.es/proposal-esm-phase-imports/#sec-module-source-object"
192+
193+
194+
class Compartment:::added {
195+
[[moduleMap]]
196+
+[[ScopeCeiling]] : Object | EMPTY
197+
}
198+
199+
Compartment --> ScopeCeiling : [[ScopeCeiling]]
200+
ModuleRecord --> Compartment : +[[Compartment]]
201+
202+
AbstractModuleSource <|-- HostDefinedModuleSource
203+
AbstractModuleSource <|-- ModuleSource
204+
ModuleRecord --> ModuleSourceRecord : [[SourceRecord]]
205+
ModuleSourceRecord --> ModuleSource : [[ModuleSource]]
206+
ModuleSource --> ModuleSourceRecord : [[ModuleSourceRecord]]
207+
CyclicModuleRecord --> ModuleRequestRecord : [[RequestedModules]]
208+
209+
classDef sourceproposal fill:#ffe
210+
classDef esmphaseproposal fill:#fef
211+
classDef importhookproposal fill:#eff
212+
213+
classDef added fill:#afa
214+
215+
</pre>
216+
<script type="module">
217+
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
218+
mermaid.initialize({ startOnLoad: true, securityLevel: 'loose' });
219+
220+
setTimeout(() => {
221+
document.querySelectorAll('.mermaid svg p').forEach(p => {
222+
if (p.textContent.startsWith('+')) {
223+
p.style.background = '#afa';
224+
}
225+
if (p.textContent.startsWith('+B')) {
226+
p.style.background = '#9da';
227+
}
228+
if (p.textContent.startsWith('-')) {
229+
p.style.color = '#f00';
230+
}
231+
})
232+
233+
document.querySelectorAll('.mermaid svg .edgePaths path').forEach(path => {
234+
path.style.strokeWidth = '2px';
235+
path.addEventListener('mouseover', () => {
236+
path.style.stroke = '#f00';
237+
});
238+
path.addEventListener('mouseout', () => {
239+
path.style.stroke = '';
240+
});
241+
});
242+
243+
}, 1000);
244+
</script>
245+
<style>
246+
.mermaid {
247+
/* makes zooming in and out work */
248+
width: 200vw
249+
}
250+
#l {
251+
position: fixed;
252+
top: 0;
253+
left: 0;
254+
background: #fff8;
255+
padding: 10px;
256+
z-index: 1000;
257+
span {
258+
padding: 10px;
259+
}
260+
}
261+
a, a:visited {
262+
color: #000;
263+
}
264+
</style>
265+
266+
</body>
267+
268+
</html>

slides/1pass.png

111 KB
Loading

slides/2026-05-update.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,27 @@ TC39 Plenary 114, 2026-05-(19-21)
1818

1919
## Motivating Cases
2020

21-
No updates, other than supply-chain security concerns escalating
21+
Updates external to this proposal:
22+
23+
- Severity of supply-chain security concerns
24+
- Support from 1Password
25+
26+
---
27+
28+
![](./1pass.png)
29+
30+
---
31+
32+
> How standards help LavaMoat and us: LavaMoat currently relies on a SES shim and uses string-based evaluation and `with` statements to construct compartments. Language support for compartmentalization would provide a better foundation for these protections as the JavaScript ecosystem evolves and would minimize the compatibility and performance issues stemming from the shim’s fidelity.
33+
2234

2335
---
2436
## Problem statement review
2537

2638
We got Stage 1 for the following problem statement:
2739
> A way to evaluate a module and its dependencies in the context of a new global scope within the same Realm
2840
29-
Aiming to achieve it by severing the tie to the `GlobalEnvironmentRecord` in `ModuleEnvironmentRecord` instances (optionally)
30-
by setting `[[OuterEnv]]` to a different record than `module.[[Realm]].[[GlobalEnv]]`, replacing it with user-defined emulation of a global
41+
Aiming to achieve it by severing the tie to the `GlobalEnvironmentRecord` in `ModuleEnvironmentRecord` instances by allowing setting `[[OuterEnv]]` to a different record than `module.[[Realm]].[[GlobalEnv]]`, replacing it with user-defined emulation of a global.
3142

3243
Feedback addressed: No multiple Globals in one Realm
3344

@@ -36,6 +47,19 @@ Feedback addressed: No multiple Globals in one Realm
3647

3748
[16.2.1.7.3.1 InitializeEnvironment ( )](https://tc39.es/ecma262/multipage/ecmascript-language-scripts-and-modules.html#sec-source-text-module-record-initialize-environment)
3849

50+
```scheme
51+
3. Let realm be module.[[Realm]].
52+
4. Assert: realm is not undefined.
53+
+ if module.[[ScopeCeiling]] is not EMPTY, then
54+
+ Let outer be NewObjectEnvironment(module.[[ScopeCeiling]], false, null)
55+
+ Let env be NewModuleEnvironment(outer)
56+
+ Else
57+
Let env be NewModuleEnvironment(realm.[[GlobalEnv]]).
58+
5. Set module.[[Environment]] to env.
59+
```
60+
61+
---
62+
3963
```scheme
4064
3. Let realm be module.[[Realm]].
4165
4. Assert: realm is not undefined.
@@ -50,6 +74,7 @@ Feedback addressed: No multiple Globals in one Realm
5074
> - `module` is Source Text Module Record
5175
> - NewObjectEnvironment could be called earlier
5276
> - `[[ScopeCeiling]]` might be accessed indirectly
77+
5378
---
5479

5580
### Path to [[ScopeCeiling]]

slides/2026-05-update.pdf

109 KB
Binary file not shown.

0 commit comments

Comments
 (0)