-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patharch-stack.tsx
More file actions
204 lines (198 loc) · 5.95 KB
/
Copy patharch-stack.tsx
File metadata and controls
204 lines (198 loc) · 5.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import { type CSSProperties, Fragment, type ReactNode } from "react";
import { SdkBinding, SdkName, SdkSwap } from "@/components/sdk-text";
// Layered architecture stack — exact port of the prototype's `.archstack` HTML
// (semantic layers + binding/store boundaries as direct children). The
// user-facing layer adapts to the active SDK via the SDK-text atoms.
type Kind = "py" | "rust" | "store" | "";
interface Layer {
tag: ReactNode;
/** Pill colour: `.ltag t-*`. */
tagKind?: Kind;
/** `.layer` modifier; defaults to `tagKind`. The prototype sometimes pairs a
* `rust` layer surface with a `py` pill (e.g. the resource-proxy layer). */
layerKind?: Kind;
style?: CSSProperties;
title: string;
body: ReactNode;
role?: string;
}
function ArchStack({
layers,
bounds,
legend,
}: {
layers: Layer[];
bounds: ReactNode[]; // one fewer than layers
legend?: ReactNode;
}) {
return (
<div className="archstack">
{legend ? <div className="arch-legend">{legend}</div> : null}
{layers.map((l, i) => (
<Fragment key={l.title}>
<div
className={`layer ${l.layerKind ?? l.tagKind ?? ""}`.trim()}
style={l.style}
>
<span className={`ltag t-${l.tagKind ?? "store"}`}>{l.tag}</span>
<div className="lbody">
<div className="lt">{l.title}</div>
<div className="ld">{l.body}</div>
</div>
{l.role ? <span className="lrole">{l.role}</span> : null}
</div>
{i < bounds.length ? <div className="bound">{bounds[i]}</div> : null}
</Fragment>
))}
</div>
);
}
/** `architecture/overview.mdx` — the Python / Rust / Store stack. */
export function ArchitectureStack() {
return (
<ArchStack
legend={
<>
<span className="al-item">
<span className="al-arrow down">↓</span> you call down — enqueue
jobs
</span>
<span className="al-item">
<span className="al-arrow up">↑</span> results & state flow back
up
</span>
</>
}
layers={[
{
tag: <SdkName />,
tagKind: "py",
title: "User-facing API",
body: (
<>
<code>Queue</code>,{" "}
<SdkSwap
python={
<>
<code>@task</code>, <code>.delay()</code>
</>
}
node={
<>
<code>.task()</code>, <code>.enqueue()</code>
</>
}
java={
<>
<code>Task.of()</code>, <code>enqueue()</code>
</>
}
/>
, results, workflows, resources — the surface you write against.
</>
),
role: "what you write",
},
{
tag: "Rust",
tagKind: "rust",
title: "Engine",
body: (
<>
Scheduler, dispatcher, worker pool, rate limiter — Tokio runtime,
OS-thread pool, near-zero <SdkName /> overhead.
</>
),
role: "where the work runs",
},
{
tag: "Store",
tagKind: "store",
title: "Storage layer",
body: "SQLite (bundled) or Postgres — jobs, results, schedules, rate-limit state, all in one place.",
role: "where state lives",
},
]}
bounds={[
<>
<span className="bdir">↓</span>
<span className="pyo3">
<SdkBinding /> boundary
</span>
<span className="bdir">↑</span>
</>,
<>
<span className="bdir">↓</span>reads & writes
<span className="bdir">↑</span>
</>,
]}
/>
);
}
/** `architecture/resources.mdx` — the 3-layer resource pipeline. */
export function ResourcePipeline() {
return (
<ArchStack
layers={[
{
tag: "Layer 1",
tagKind: "py",
title: "Argument interception",
body: (
<>
The <code>ArgumentInterceptor</code> walks every argument before
serialization. CONVERT types become JSON-safe markers, REDIRECT
types become DI placeholders, PROXY types are deconstructed,
REJECT types raise in strict mode.
</>
),
},
{
tag: "Layer 2",
tagKind: "py",
title: "Worker resource runtime",
body: (
<>
<code>ResourceRuntime</code> initializes resources at worker
startup in topological order, then injects requested ones (via{" "}
<SdkSwap
python={
<>
<code>inject=</code> or <code>Inject["name"]</code>
</>
}
node={
<>
<code>inject:</code> or <code>useResource()</code>
</>
}
java={<code>Resources.use()</code>}
/>
). Task-scoped resources come from a semaphore pool.
</>
),
},
{
tag: "Layer 3",
tagKind: "py",
layerKind: "rust",
style: {
borderColor: "var(--indigo-line)",
background:
"linear-gradient(100deg,var(--indigo-soft),var(--panel))",
},
title: "Resource proxies",
body: (
<>
<code>ProxyHandler</code>s deconstruct live objects (file handles,
HTTP sessions, cloud clients) into a JSON recipe and reconstruct
them on the worker. Recipes are optionally HMAC-signed for tamper
detection.
</>
),
},
]}
bounds={["enqueue → worker", "before task()"]}
/>
);
}