Srishti280992 commited on
Commit
25f3b2e
·
verified ·
1 Parent(s): 5cc5437

Refresh TimeRCD reproduction bundle with HF job outputs and revised logbook

Browse files
Files changed (36) hide show
  1. .trackio/logbook/.sync.log +0 -0
  2. .trackio/logbook/.sync_lock +0 -0
  3. .trackio/logbook/README.md +18 -0
  4. .trackio/logbook/bucket-icon.svg +5 -0
  5. .trackio/logbook/index.html +54 -0
  6. .trackio/logbook/logbook.css +1602 -0
  7. .trackio/logbook/logbook.js +2275 -0
  8. .trackio/logbook/logbook.json +71 -0
  9. .trackio/logbook/pages/claim-1-claim-1/page.md +14 -0
  10. .trackio/logbook/pages/claim-2-claim-2/page.md +14 -0
  11. .trackio/logbook/pages/claim-3-claim-3/page.md +19 -0
  12. .trackio/logbook/pages/claim-4-claim-4/page.md +12 -0
  13. .trackio/logbook/pages/claim-5-claim-5/page.md +14 -0
  14. .trackio/logbook/pages/claim-6-claim-6/page.md +21 -0
  15. .trackio/logbook/pages/conclusion/page.md +28 -0
  16. .trackio/logbook/pages/executive-summary/page.md +29 -0
  17. .trackio/logbook/pages/index.md +16 -0
  18. .trackio/logbook/trackio-logo-light.png +3 -0
  19. .trackio/logbook/trackio-logo.png +3 -0
  20. .trackio/logbook/trackio-wordmark-dark.png +3 -0
  21. outputs/hf_job_results/recon_vs_head_1784686657/recon_vs_head_summary.json +17 -0
  22. outputs/hf_job_results/recon_vs_head_1784686657/recon_vs_head_ucr.csv +121 -0
  23. outputs/hf_job_results/specialized_eval_1784687655/specialized_contextual_series.csv +0 -0
  24. outputs/hf_job_results/specialized_eval_1784687655/specialized_eval_per_series.csv +41 -0
  25. outputs/hf_job_results/specialized_eval_1784687655/specialized_eval_summary.json +45 -0
  26. outputs/hf_job_results/specialized_eval_1784687655/specialized_generation_summary.json +11 -0
  27. outputs/hf_job_results/specialized_eval_1784687655/specialized_point_series.csv +0 -0
  28. poster_embed.html +101 -0
  29. scripts/__pycache__/hf_full_table1_eval.cpython-38.pyc +0 -0
  30. scripts/__pycache__/hf_recon_vs_head_ucr.cpython-38.pyc +0 -0
  31. scripts/__pycache__/hf_reduced_ablation_train.cpython-38.pyc +0 -0
  32. scripts/__pycache__/hf_specialized_context_eval.cpython-38.pyc +0 -0
  33. scripts/hf_full_table1_eval.py +288 -0
  34. scripts/hf_recon_vs_head_ucr.py +210 -0
  35. scripts/hf_reduced_ablation_train.py +435 -0
  36. scripts/hf_specialized_context_eval.py +288 -0
.trackio/logbook/.sync.log ADDED
File without changes
.trackio/logbook/.sync_lock ADDED
File without changes
.trackio/logbook/README.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: "Reproduction: Towards Foundation Models for Zero-Shot Time Series Anomaly Detection: Leveraging Synthetic Data and Relative Context Discrepancy"
3
+ emoji: 🎯
4
+ colorFrom: yellow
5
+ colorTo: red
6
+ sdk: static
7
+ pinned: false
8
+ tags:
9
+ - trackio
10
+ - trackio-logbook
11
+ - open-experiment
12
+ - icml2026-repro
13
+ - paper-yXqnyIvGAy
14
+ ---
15
+
16
+ # Reproduction: Towards Foundation Models for Zero-Shot Time Series Anomaly Detection: Leveraging Synthetic Data and Relative Context Discrepancy
17
+
18
+ An open experiment logbook, published with [Trackio](https://github.com/gradio-app/trackio).
.trackio/logbook/bucket-icon.svg ADDED
.trackio/logbook/index.html ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Reproduction: Towards Foundation Models for Zero-Shot Time Series Anomaly Detection: Leveraging Synthetic Data and Relative Context Discrepancy</title>
7
+ <link rel="stylesheet" href="./logbook.css" />
8
+ </head>
9
+ <body>
10
+ <div id="app">
11
+ <aside id="sidebar">
12
+ <div id="book-head">
13
+ <img id="book-wordmark" src="./trackio-wordmark-dark.png" alt="" />
14
+ <div id="book-title" class="sr-only">Logbook</div>
15
+ </div>
16
+ <nav id="tree"></nav>
17
+ <div id="sidebar-foot" hidden>
18
+ <button id="connect-btn" type="button">
19
+ <span class="ico">ⓘ</span> Collaborate with your agent
20
+ </button>
21
+ </div>
22
+ </aside>
23
+ <main id="content">
24
+ <div id="page"></div>
25
+ </main>
26
+ </div>
27
+
28
+ <div id="modal" hidden>
29
+ <div class="modal-backdrop"></div>
30
+ <div class="modal-card" role="dialog" aria-modal="true">
31
+ <div class="modal-head">
32
+ <div class="modal-title">
33
+ <img class="modal-logo" src="./trackio-logo.png" alt="" />
34
+ Collaborate with your agent
35
+ </div>
36
+ <div class="modal-actions">
37
+ <button id="copy-agent" class="btn">Copy for agent</button>
38
+ <button id="modal-close" class="btn icon" aria-label="Close">×</button>
39
+ </div>
40
+ </div>
41
+ <div class="modal-body">
42
+ <p class="modal-intro">
43
+ Point your coding agent at this logbook. It reads a compact,
44
+ token-efficient version — and if you've given it write access to this
45
+ Space, it can add findings that sync back automatically.
46
+ </p>
47
+ <ol id="connect-steps"></ol>
48
+ </div>
49
+ </div>
50
+ </div>
51
+
52
+ <script src="./logbook.js"></script>
53
+ </body>
54
+ </html>
.trackio/logbook/logbook.css ADDED
@@ -0,0 +1,1602 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ --bg: #ffffff;
3
+ --paper: #fdfcf9;
4
+ --panel: #ffffff;
5
+ --ink: #1f2937;
6
+ --muted: #6b7280;
7
+ --line: #e5e7eb;
8
+ --accent: #f97316;
9
+ --accent-strong: #ea580c;
10
+ --accent-soft: #fff7ed;
11
+ --accent-line: rgba(249, 115, 22, 0.16);
12
+ --grid-line: rgba(31, 41, 55, 0.045);
13
+ --code-bg: #f3f4f6;
14
+ --radius: 12px;
15
+ --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
16
+ --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
17
+ sans-serif;
18
+ --mono: "SFMono-Regular", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas,
19
+ ui-monospace, monospace;
20
+ }
21
+
22
+ * {
23
+ box-sizing: border-box;
24
+ }
25
+
26
+ html,
27
+ body {
28
+ margin: 0;
29
+ padding: 0;
30
+ }
31
+
32
+ html {
33
+ scroll-behavior: smooth;
34
+ }
35
+
36
+ body {
37
+ background: var(--bg);
38
+ color: var(--ink);
39
+ font-family: var(--sans);
40
+ font-size: 13px;
41
+ line-height: 1.65;
42
+ -webkit-font-smoothing: antialiased;
43
+ }
44
+
45
+ #app {
46
+ display: flex;
47
+ min-height: 100vh;
48
+ }
49
+
50
+ /* ---- sidebar (composition-book cover) ---- */
51
+ #sidebar {
52
+ width: 280px;
53
+ flex: 0 0 280px;
54
+ background: #17181c;
55
+ color: #e7e7ea;
56
+ position: sticky;
57
+ top: 0;
58
+ height: 100vh;
59
+ overflow-y: auto;
60
+ padding: 22px 16px;
61
+ display: flex;
62
+ flex-direction: column;
63
+ }
64
+
65
+ #book-head {
66
+ display: flex;
67
+ align-items: center;
68
+ gap: 10px;
69
+ padding: 8px;
70
+ margin-bottom: 12px;
71
+ border-radius: 10px;
72
+ cursor: pointer;
73
+ transition: background 0.12s;
74
+ }
75
+ #book-head:hover {
76
+ background: rgba(255, 255, 255, 0.05);
77
+ }
78
+ #book-wordmark {
79
+ width: 154px;
80
+ height: auto;
81
+ object-fit: contain;
82
+ }
83
+ .sr-only {
84
+ position: absolute;
85
+ width: 1px;
86
+ height: 1px;
87
+ padding: 0;
88
+ margin: -1px;
89
+ overflow: hidden;
90
+ clip: rect(0, 0, 0, 0);
91
+ white-space: nowrap;
92
+ border: 0;
93
+ }
94
+
95
+ #tree {
96
+ flex: 1;
97
+ padding-top: 8px;
98
+ }
99
+
100
+ #tree a {
101
+ display: block;
102
+ padding: 6px 10px;
103
+ border-radius: 8px;
104
+ color: #c3c4cb;
105
+ text-decoration: none;
106
+ font-size: 14px;
107
+ transition: background 0.12s, color 0.12s;
108
+ }
109
+
110
+ #tree a:hover {
111
+ background: rgba(255, 255, 255, 0.06);
112
+ color: #ffffff;
113
+ }
114
+
115
+ #tree a.active {
116
+ background: rgba(249, 115, 22, 0.16);
117
+ color: #fdba74;
118
+ font-weight: 600;
119
+ }
120
+
121
+ #tree a .tree-mark {
122
+ color: #6b6d76;
123
+ }
124
+
125
+ #tree a:hover .tree-mark,
126
+ #tree a.active .tree-mark {
127
+ color: inherit;
128
+ opacity: 0.6;
129
+ }
130
+
131
+ #tree .depth-1 {
132
+ padding-left: 22px;
133
+ }
134
+ #tree .depth-2 {
135
+ padding-left: 34px;
136
+ }
137
+ #tree .depth-3 {
138
+ padding-left: 46px;
139
+ }
140
+
141
+
142
+ /* ---- content ---- */
143
+ #content {
144
+ flex: 1;
145
+ min-width: 0;
146
+ padding: 48px 40px 120px;
147
+ background-color: var(--paper);
148
+ background-image:
149
+ linear-gradient(var(--grid-line) 1px, transparent 1px),
150
+ linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
151
+ background-size: 26px 26px;
152
+ background-position: center top;
153
+ }
154
+
155
+ #page {
156
+ width: 100%;
157
+ min-width: 0;
158
+ max-width: 1052px;
159
+ margin: 0 auto;
160
+ }
161
+
162
+ .page-section {
163
+ scroll-margin-top: 40px;
164
+ padding: 0 0 35px;
165
+ margin: 0 0 32px;
166
+ }
167
+
168
+ .page-section:last-child {
169
+ margin-bottom: 0;
170
+ }
171
+
172
+ .page-layout {
173
+ display: grid;
174
+ grid-template-columns: minmax(0, 760px) 248px;
175
+ gap: 44px;
176
+ align-items: start;
177
+ }
178
+
179
+ .page-body {
180
+ min-width: 0;
181
+ }
182
+
183
+ .resource-anchor {
184
+ display: block;
185
+ height: 0;
186
+ overflow: hidden;
187
+ }
188
+
189
+ /* ---- pinned notes ---- */
190
+ .pinned-notes {
191
+ margin: 30px 0 0;
192
+ }
193
+ .pinned-notes-list .cell {
194
+ margin: 0;
195
+ border-color: rgba(249, 115, 22, 0.55);
196
+ }
197
+ .pinned-notes-list .cell + .cell {
198
+ margin-top: 12px;
199
+ }
200
+ .cell.pinned-source {
201
+ border-color: rgba(249, 115, 22, 0.55);
202
+ }
203
+ .book-intro.has-pinned-notes {
204
+ border-bottom: none;
205
+ padding-bottom: 22px;
206
+ margin-bottom: 30px;
207
+ }
208
+ .book-intro.book-intro-tight {
209
+ border-bottom: none;
210
+ padding-bottom: 4px;
211
+ margin-bottom: 20px;
212
+ }
213
+
214
+ #page h1 {
215
+ font-family: var(--serif);
216
+ font-size: 34px;
217
+ line-height: 1.15;
218
+ letter-spacing: -0.02em;
219
+ margin: 0 0 8px;
220
+ overflow-wrap: anywhere;
221
+ }
222
+
223
+ #page .page-section:not(.book-intro) h1 {
224
+ font-size: 26px;
225
+ }
226
+
227
+ #page h2 {
228
+ font-family: var(--serif);
229
+ font-size: 24px;
230
+ margin: 36px 0 10px;
231
+ }
232
+
233
+ #page h3 {
234
+ font-size: 17px;
235
+ font-weight: 700;
236
+ margin: 26px 0 2px;
237
+ letter-spacing: -0.01em;
238
+ }
239
+
240
+ #page h3::before {
241
+ content: "";
242
+ display: inline-block;
243
+ width: 7px;
244
+ height: 7px;
245
+ border-radius: 2px;
246
+ background: var(--accent);
247
+ margin-right: 10px;
248
+ vertical-align: middle;
249
+ transform: translateY(-1px);
250
+ }
251
+
252
+ #page p {
253
+ margin: 10px 0;
254
+ }
255
+
256
+ #page blockquote {
257
+ margin: 14px 0;
258
+ padding: 2px 16px;
259
+ border-left: 3px solid #fdba74;
260
+ color: var(--muted);
261
+ }
262
+
263
+ #page hr {
264
+ display: none;
265
+ }
266
+
267
+ #page code {
268
+ font-family: var(--mono);
269
+ font-size: 0.86em;
270
+ background: var(--code-bg);
271
+ padding: 2px 6px;
272
+ border-radius: 6px;
273
+ }
274
+
275
+ #page pre {
276
+ max-width: 100%;
277
+ background: var(--code-bg);
278
+ border: 1px solid var(--line);
279
+ border-radius: var(--radius);
280
+ padding: 14px 16px;
281
+ overflow-x: auto;
282
+ }
283
+ #page pre code {
284
+ background: none;
285
+ padding: 0;
286
+ font-size: 11.5px;
287
+ }
288
+
289
+ /* ---- code blocks + collapsible accordion ---- */
290
+ #page pre.hl {
291
+ background: #17181c;
292
+ border: none;
293
+ color: #e7e7ea;
294
+ font-size: 13px;
295
+ line-height: 1.58;
296
+ }
297
+ #page pre.hl code {
298
+ color: inherit;
299
+ font-family: var(--mono);
300
+ }
301
+ .code-accordion {
302
+ border: 1px solid rgba(249, 115, 22, 0.2);
303
+ border-radius: 8px;
304
+ overflow: hidden;
305
+ margin: 12px 0;
306
+ background: #17181c;
307
+ }
308
+ .code-accordion summary {
309
+ list-style: none;
310
+ cursor: pointer;
311
+ display: flex;
312
+ align-items: center;
313
+ gap: 9px;
314
+ padding: 9px 12px;
315
+ font-family: var(--mono);
316
+ font-size: 11.5px;
317
+ font-weight: 700;
318
+ color: #e7e7ea;
319
+ background: #1e2027;
320
+ user-select: none;
321
+ overflow-wrap: anywhere;
322
+ }
323
+ .code-accordion summary::-webkit-details-marker {
324
+ display: none;
325
+ }
326
+ .code-accordion summary::after {
327
+ content: "▸";
328
+ margin-left: auto;
329
+ color: var(--accent);
330
+ transition: transform 0.12s;
331
+ transform: rotate(180deg);
332
+ }
333
+ .code-accordion[open] summary::after {
334
+ transform: rotate(90deg);
335
+ }
336
+ .code-accordion .code-ico {
337
+ color: var(--accent);
338
+ font-weight: 700;
339
+ }
340
+ .code-accordion pre.hl {
341
+ margin: 0;
342
+ border-radius: 0;
343
+ border: none;
344
+ border-top: 1px solid rgba(249, 115, 22, 0.16);
345
+ }
346
+ .tok-comment {
347
+ color: #7a7d87;
348
+ font-style: italic;
349
+ }
350
+ .tok-string {
351
+ color: #a5d6a7;
352
+ }
353
+ .tok-keyword {
354
+ color: #fdba74;
355
+ }
356
+ .tok-number {
357
+ color: #7fd0e0;
358
+ }
359
+
360
+ #page a {
361
+ color: var(--accent);
362
+ }
363
+
364
+ #page ul {
365
+ padding-left: 20px;
366
+ }
367
+
368
+ .ts {
369
+ font-family: var(--mono);
370
+ font-size: 12px;
371
+ color: var(--muted);
372
+ background: none;
373
+ padding: 0;
374
+ }
375
+
376
+ /* ---- notebook-style cells ---- */
377
+ .cell {
378
+ max-width: 100%;
379
+ border: 1px solid var(--line);
380
+ border-radius: 10px;
381
+ background: rgba(255, 255, 255, 0.86);
382
+ margin: 18px 0;
383
+ overflow: hidden;
384
+ box-shadow: 0 2px 10px rgba(31, 41, 55, 0.035);
385
+ }
386
+ .cell-head {
387
+ display: flex;
388
+ justify-content: space-between;
389
+ gap: 16px;
390
+ align-items: center;
391
+ padding: 14px 18px;
392
+ background: rgba(255, 255, 255, 0.92);
393
+ border-bottom: 1px solid var(--line);
394
+ }
395
+ .cell-head.no-title {
396
+ justify-content: flex-end;
397
+ padding-top: 10px;
398
+ padding-bottom: 10px;
399
+ }
400
+ .cell-title {
401
+ flex: 1;
402
+ min-width: 0;
403
+ font-size: 13px;
404
+ font-weight: 650;
405
+ color: var(--ink);
406
+ line-height: 1.35;
407
+ overflow-wrap: anywhere;
408
+ }
409
+ .cell-meta {
410
+ flex: 0 0 auto;
411
+ display: flex;
412
+ align-items: center;
413
+ gap: 10px;
414
+ font-family: var(--sans);
415
+ font-size: 13px;
416
+ color: var(--muted);
417
+ }
418
+ .cell-open {
419
+ flex: 0 0 auto;
420
+ font-family: var(--mono);
421
+ font-size: 12px;
422
+ color: var(--accent);
423
+ text-decoration: none;
424
+ }
425
+ .cell-open:hover {
426
+ color: var(--accent-strong);
427
+ }
428
+ .cell-body {
429
+ min-width: 0;
430
+ padding: 14px 18px 18px;
431
+ }
432
+ .cell.dashboard .cell-body {
433
+ padding: 0;
434
+ }
435
+ #page .cell-body h1,
436
+ #page .cell-body h2 {
437
+ font-family: var(--sans);
438
+ font-size: 17px;
439
+ font-weight: 700;
440
+ letter-spacing: -0.01em;
441
+ line-height: 1.35;
442
+ margin: 22px 0 6px;
443
+ }
444
+ #page .cell-body > :first-child {
445
+ margin-top: 0;
446
+ }
447
+ #page .cell-body > :last-child {
448
+ margin-bottom: 0;
449
+ }
450
+ .cell.code .cell-head {
451
+ background: #fbfbfc;
452
+ }
453
+ .figure-fit {
454
+ position: relative;
455
+ overflow: hidden;
456
+ min-height: 160px;
457
+ border: 1px solid var(--line);
458
+ border-radius: 8px;
459
+ background: #fff;
460
+ }
461
+ .figure-fit[hidden] {
462
+ display: none;
463
+ }
464
+ .figure-fit:fullscreen,
465
+ .figure-fit:-webkit-full-screen {
466
+ width: 100%;
467
+ height: 100%;
468
+ border: none;
469
+ border-radius: 0;
470
+ }
471
+ .figure-frame {
472
+ display: block;
473
+ width: 100%;
474
+ min-height: 160px;
475
+ border: none;
476
+ background: #fff;
477
+ }
478
+ .figure-frame[hidden],
479
+ .figure-raw[hidden] {
480
+ display: none;
481
+ }
482
+ .fig-switch {
483
+ position: relative;
484
+ display: inline-flex;
485
+ flex: 0 0 auto;
486
+ border: 1px solid var(--line);
487
+ border-radius: 999px;
488
+ background: var(--code-bg);
489
+ padding: 2px;
490
+ }
491
+ .fig-switch button {
492
+ position: relative;
493
+ z-index: 1;
494
+ flex: 1;
495
+ min-width: 62px;
496
+ border: none;
497
+ background: none;
498
+ font-family: var(--sans);
499
+ font-size: 12px;
500
+ font-weight: 600;
501
+ color: var(--muted);
502
+ padding: 3px 12px;
503
+ border-radius: 999px;
504
+ cursor: pointer;
505
+ transition: color 0.15s;
506
+ }
507
+ .fig-switch button.active {
508
+ color: var(--accent-strong);
509
+ }
510
+ .fig-switch-thumb {
511
+ position: absolute;
512
+ top: 2px;
513
+ bottom: 2px;
514
+ left: 2px;
515
+ width: calc(50% - 2px);
516
+ border-radius: 999px;
517
+ background: var(--panel);
518
+ border: 1px solid rgba(249, 115, 22, 0.35);
519
+ box-shadow: 0 1px 4px rgba(31, 41, 55, 0.08);
520
+ transition: transform 0.18s ease;
521
+ }
522
+ .fig-switch.raw .fig-switch-thumb {
523
+ transform: translateX(100%);
524
+ }
525
+ #page .figure-raw pre {
526
+ margin: 0;
527
+ max-height: 420px;
528
+ overflow: auto;
529
+ font-family: var(--mono);
530
+ font-size: 13px;
531
+ line-height: 1.55;
532
+ background: var(--code-bg);
533
+ border: 1px solid var(--line);
534
+ border-radius: 8px;
535
+ padding: 12px 14px;
536
+ }
537
+ /* ---- figure fullscreen ---- */
538
+ .cell-fullscreen {
539
+ position: relative;
540
+ display: inline-flex;
541
+ flex: 0 0 auto;
542
+ }
543
+ .cell-fullscreen-btn {
544
+ display: inline-flex;
545
+ align-items: center;
546
+ justify-content: center;
547
+ width: 26px;
548
+ height: 26px;
549
+ padding: 0;
550
+ border: 1px solid var(--line);
551
+ border-radius: 999px;
552
+ background: var(--code-bg);
553
+ color: var(--muted);
554
+ cursor: pointer;
555
+ transition: color 0.15s, border-color 0.15s, background 0.15s;
556
+ }
557
+ .cell-fullscreen-btn:hover {
558
+ color: var(--accent-strong);
559
+ border-color: rgba(249, 115, 22, 0.35);
560
+ background: var(--accent-soft);
561
+ }
562
+ .cell-fullscreen-btn svg {
563
+ width: 14px;
564
+ height: 14px;
565
+ }
566
+ /* ---- copyable snippets ---- */
567
+ .snippet {
568
+ position: relative;
569
+ }
570
+ .copy-snippet {
571
+ position: absolute;
572
+ top: 7px;
573
+ right: 8px;
574
+ width: 24px;
575
+ height: 24px;
576
+ border: none;
577
+ border-radius: 6px;
578
+ background: rgba(255, 255, 255, 0.08);
579
+ color: #9a9da8;
580
+ font-size: 12px;
581
+ line-height: 1;
582
+ cursor: pointer;
583
+ opacity: 0;
584
+ transition: opacity 0.12s, color 0.12s, background 0.12s;
585
+ }
586
+ .snippet:hover .copy-snippet,
587
+ .jp-out:hover .copy-snippet,
588
+ .figure-raw:hover .copy-snippet,
589
+ .code-accordion summary:hover .copy-snippet {
590
+ opacity: 1;
591
+ }
592
+ .copy-snippet:hover {
593
+ color: #ffffff;
594
+ background: rgba(255, 255, 255, 0.16);
595
+ }
596
+ .copy-snippet.copied {
597
+ color: #52d08a;
598
+ opacity: 1;
599
+ }
600
+ .code-accordion .code-name {
601
+ user-select: text;
602
+ cursor: text;
603
+ }
604
+ .jp-out,
605
+ .figure-raw {
606
+ position: relative;
607
+ }
608
+ .jp-out .copy-snippet,
609
+ .figure-raw .copy-snippet {
610
+ background: var(--code-bg);
611
+ color: var(--muted);
612
+ border: 1px solid var(--line);
613
+ }
614
+ .jp-out .copy-snippet:hover,
615
+ .figure-raw .copy-snippet:hover {
616
+ color: var(--accent-strong);
617
+ background: var(--panel);
618
+ }
619
+
620
+ /* ---- jupyter-style code cells ---- */
621
+ .jp {
622
+ border: 1px solid var(--line);
623
+ border-radius: 10px;
624
+ overflow: hidden;
625
+ margin: 12px 0;
626
+ background: var(--panel);
627
+ }
628
+ .jp-gutter {
629
+ flex: 0 0 46px;
630
+ padding: 13px 0 0 13px;
631
+ font-family: var(--mono);
632
+ font-size: 10.5px;
633
+ letter-spacing: 0.07em;
634
+ text-transform: uppercase;
635
+ font-weight: 600;
636
+ user-select: none;
637
+ }
638
+ .jp-in {
639
+ display: flex;
640
+ background: #17181c;
641
+ }
642
+ .jp-in .jp-gutter {
643
+ color: #6f727d;
644
+ }
645
+ .jp-in-body {
646
+ flex: 1;
647
+ min-width: 0;
648
+ }
649
+ #page .jp-in-body pre.hl {
650
+ margin: 0;
651
+ border: none;
652
+ border-radius: 0;
653
+ background: none;
654
+ padding: 12px 16px 12px 0;
655
+ }
656
+ .jp-in-body .code-accordion {
657
+ margin: 0;
658
+ border: none;
659
+ border-top: 1px solid rgba(255, 255, 255, 0.09);
660
+ border-radius: 0;
661
+ background: none;
662
+ }
663
+ .jp-in-body .code-accordion summary {
664
+ background: none;
665
+ padding: 9px 16px 9px 0;
666
+ }
667
+ .jp-in-body .code-accordion pre.hl {
668
+ border-top: 1px solid rgba(255, 255, 255, 0.09);
669
+ }
670
+ .jp-meta {
671
+ padding: 5px 14px;
672
+ font-family: var(--mono);
673
+ font-size: 11.5px;
674
+ color: var(--muted);
675
+ background: #fbfbfc;
676
+ border-top: 1px solid var(--line);
677
+ }
678
+ .jp-out {
679
+ display: flex;
680
+ border-top: 1px solid var(--line);
681
+ background: var(--panel);
682
+ }
683
+ .jp-out .jp-gutter {
684
+ color: var(--accent-strong);
685
+ }
686
+ .jp-out-body {
687
+ flex: 1;
688
+ min-width: 0;
689
+ }
690
+ #page .jp-out-pre {
691
+ min-width: 0;
692
+ margin: 0;
693
+ border: none;
694
+ border-radius: 0;
695
+ background: none;
696
+ color: var(--ink);
697
+ font-family: var(--mono);
698
+ font-size: 13px;
699
+ line-height: 1.55;
700
+ padding: 12px 16px 12px 0;
701
+ white-space: pre;
702
+ overflow-x: auto;
703
+ overflow-y: auto;
704
+ max-height: 26em;
705
+ }
706
+ .jp-artifacts {
707
+ display: flex;
708
+ flex-direction: column;
709
+ }
710
+ .jp-out-body .jp-out-pre + .jp-artifacts {
711
+ border-top: 1px solid var(--line);
712
+ }
713
+ .out-artifact {
714
+ display: flex;
715
+ align-items: baseline;
716
+ gap: 8px;
717
+ padding: 9px 16px 9px 0;
718
+ text-decoration: none;
719
+ color: inherit;
720
+ }
721
+ .out-artifact + .out-artifact {
722
+ border-top: 1px solid var(--line);
723
+ }
724
+ a.out-artifact:hover .out-artifact-name {
725
+ color: var(--accent-strong);
726
+ }
727
+ .out-artifact-ico {
728
+ flex: 0 0 auto;
729
+ font-size: 13px;
730
+ }
731
+ .out-artifact-name {
732
+ font-family: var(--mono);
733
+ font-size: 12.5px;
734
+ font-weight: 600;
735
+ color: var(--ink);
736
+ overflow: hidden;
737
+ text-overflow: ellipsis;
738
+ white-space: nowrap;
739
+ }
740
+ .out-artifact-meta {
741
+ flex: 0 0 auto;
742
+ margin-left: auto;
743
+ padding-left: 12px;
744
+ font-size: 12px;
745
+ color: var(--muted);
746
+ white-space: nowrap;
747
+ }
748
+ .out-artifact-state.open {
749
+ color: var(--accent);
750
+ font-weight: 600;
751
+ }
752
+ .trackio-embed {
753
+ border: 1px solid var(--line);
754
+ border-radius: var(--radius);
755
+ overflow: hidden;
756
+ background: var(--panel);
757
+ }
758
+ .trackio-cell-meta {
759
+ display: flex;
760
+ gap: 6px;
761
+ flex-wrap: wrap;
762
+ justify-content: flex-end;
763
+ }
764
+
765
+ /* ---- unfurl cards ---- */
766
+ .unfurl {
767
+ display: block;
768
+ border: 1px solid var(--line);
769
+ border-radius: var(--radius);
770
+ background: var(--panel);
771
+ margin: 12px 0;
772
+ overflow: hidden;
773
+ text-decoration: none;
774
+ color: inherit;
775
+ transition: border-color 0.14s, box-shadow 0.14s;
776
+ }
777
+ .unfurl:hover {
778
+ border-color: #cfcbe6;
779
+ box-shadow: 0 4px 18px rgba(30, 20, 80, 0.06);
780
+ }
781
+
782
+ .unfurl-body {
783
+ padding: 13px 16px;
784
+ display: flex;
785
+ gap: 12px;
786
+ align-items: flex-start;
787
+ }
788
+
789
+ .unfurl-ico {
790
+ font-size: 20px;
791
+ line-height: 1.3;
792
+ flex: 0 0 auto;
793
+ }
794
+
795
+ .unfurl-main {
796
+ min-width: 0;
797
+ flex: 1;
798
+ }
799
+
800
+ .unfurl-kind {
801
+ font-family: var(--mono);
802
+ font-size: 10.5px;
803
+ text-transform: uppercase;
804
+ letter-spacing: 0.08em;
805
+ color: var(--accent);
806
+ font-weight: 600;
807
+ }
808
+
809
+ .unfurl-title {
810
+ font-weight: 650;
811
+ font-size: 15px;
812
+ margin: 1px 0 2px;
813
+ white-space: nowrap;
814
+ overflow: hidden;
815
+ text-overflow: ellipsis;
816
+ }
817
+
818
+ .unfurl-desc {
819
+ color: var(--muted);
820
+ font-size: 13.5px;
821
+ line-height: 1.45;
822
+ }
823
+
824
+ .unfurl-meta {
825
+ margin-top: 6px;
826
+ display: flex;
827
+ flex-wrap: wrap;
828
+ gap: 6px;
829
+ }
830
+
831
+ .chip {
832
+ font-size: 11.5px;
833
+ background: var(--code-bg);
834
+ border-radius: 999px;
835
+ padding: 2px 9px;
836
+ color: var(--muted);
837
+ font-family: var(--mono);
838
+ }
839
+
840
+ .unfurl-raw {
841
+ font-family: var(--mono);
842
+ font-size: 11px;
843
+ color: var(--muted);
844
+ border-top: 1px solid var(--line);
845
+ padding: 7px 16px;
846
+ white-space: nowrap;
847
+ overflow: hidden;
848
+ text-overflow: ellipsis;
849
+ }
850
+
851
+ .unfurl.embed {
852
+ padding: 0;
853
+ overflow: hidden;
854
+ }
855
+ .embed-head {
856
+ display: flex;
857
+ align-items: center;
858
+ gap: 10px;
859
+ padding: 10px 14px;
860
+ border-bottom: 1px solid var(--line);
861
+ }
862
+ .embed-head .unfurl-kind {
863
+ flex: 0 0 auto;
864
+ }
865
+ .embed-title {
866
+ flex: 1;
867
+ min-width: 0;
868
+ font-weight: 650;
869
+ font-size: 14px;
870
+ color: var(--ink);
871
+ text-decoration: none;
872
+ white-space: nowrap;
873
+ overflow: hidden;
874
+ text-overflow: ellipsis;
875
+ }
876
+ .embed-title:hover {
877
+ color: var(--accent);
878
+ }
879
+ .embed-open {
880
+ flex: 0 0 auto;
881
+ font-family: var(--mono);
882
+ font-size: 12px;
883
+ color: var(--accent);
884
+ text-decoration: none;
885
+ }
886
+ .embed-frame {
887
+ display: block;
888
+ width: 100%;
889
+ height: 560px;
890
+ border: 0;
891
+ background: var(--code-bg);
892
+ }
893
+
894
+ .dashboard-shell {
895
+ display: block;
896
+ }
897
+ .dashboard-shell .dashboard-frame {
898
+ display: block;
899
+ width: 100%;
900
+ height: 900px;
901
+ border: 0;
902
+ background: var(--code-bg);
903
+ }
904
+
905
+ .unfurl.image {
906
+ padding: 0;
907
+ }
908
+ .unfurl.image img {
909
+ display: block;
910
+ width: 100%;
911
+ height: auto;
912
+ max-height: 460px;
913
+ object-fit: contain;
914
+ background: var(--code-bg);
915
+ }
916
+
917
+ .artifact-chip {
918
+ border: 1px solid var(--line);
919
+ background: var(--panel);
920
+ border-radius: var(--radius);
921
+ padding: 10px 14px;
922
+ margin: 8px 0;
923
+ font-size: 14px;
924
+ }
925
+ .cell.dashboard .artifact-chip {
926
+ margin: 14px 18px 18px;
927
+ }
928
+ .artifact-chip code {
929
+ color: var(--accent);
930
+ }
931
+
932
+ /* ---- task board ---- */
933
+ .board-wrap {
934
+ overflow-x: auto;
935
+ border: 1px solid var(--line);
936
+ border-radius: var(--radius);
937
+ margin: 12px 0 20px;
938
+ background: var(--panel);
939
+ }
940
+ table.board {
941
+ border-collapse: collapse;
942
+ width: 100%;
943
+ font-size: 14px;
944
+ }
945
+ table.board th,
946
+ table.board td {
947
+ text-align: left;
948
+ padding: 9px 14px;
949
+ border-bottom: 1px solid var(--line);
950
+ vertical-align: top;
951
+ }
952
+ table.board thead th {
953
+ background: var(--accent-soft);
954
+ font-size: 12px;
955
+ text-transform: uppercase;
956
+ letter-spacing: 0.05em;
957
+ color: #9a4a12;
958
+ font-weight: 600;
959
+ border-bottom: 1px solid var(--line);
960
+ }
961
+ table.board tbody tr:last-child td {
962
+ border-bottom: none;
963
+ }
964
+ table.board .col-check {
965
+ text-align: center;
966
+ width: 92px;
967
+ white-space: nowrap;
968
+ }
969
+ table.board tr.section-row td {
970
+ background: var(--accent-soft);
971
+ text-align: center;
972
+ font-weight: 700;
973
+ font-size: 13px;
974
+ color: var(--accent-strong);
975
+ padding: 7px 14px;
976
+ letter-spacing: 0.02em;
977
+ }
978
+ .box {
979
+ display: inline-flex;
980
+ align-items: center;
981
+ justify-content: center;
982
+ width: 18px;
983
+ height: 18px;
984
+ border: 1.5px solid #cfcbe0;
985
+ border-radius: 5px;
986
+ font-size: 12px;
987
+ color: #fff;
988
+ line-height: 1;
989
+ }
990
+ .box.on {
991
+ background: var(--accent);
992
+ border-color: var(--accent);
993
+ }
994
+ .who-chip {
995
+ display: inline-block;
996
+ padding: 3px 12px;
997
+ border-radius: 999px;
998
+ font-size: 12.5px;
999
+ font-weight: 600;
1000
+ white-space: nowrap;
1001
+ }
1002
+ .who-chip.muted {
1003
+ background: var(--code-bg);
1004
+ color: var(--muted);
1005
+ font-weight: 500;
1006
+ }
1007
+
1008
+ /* ---- status badges + clickable rows ---- */
1009
+ table.board .col-status {
1010
+ width: 130px;
1011
+ white-space: nowrap;
1012
+ }
1013
+ .badge {
1014
+ display: inline-block;
1015
+ padding: 3px 11px;
1016
+ border-radius: 999px;
1017
+ font-size: 12px;
1018
+ font-weight: 600;
1019
+ letter-spacing: 0.01em;
1020
+ }
1021
+ .badge.gray {
1022
+ background: var(--code-bg);
1023
+ color: var(--muted);
1024
+ }
1025
+ .badge.amber {
1026
+ background: var(--accent-soft);
1027
+ color: #b45309;
1028
+ }
1029
+ .badge.green {
1030
+ background: #e6f7ee;
1031
+ color: #1a8a55;
1032
+ }
1033
+ .badge.red {
1034
+ background: #fde8ec;
1035
+ color: #c62a4b;
1036
+ }
1037
+ table.board tr.linked-row {
1038
+ cursor: pointer;
1039
+ }
1040
+ table.board tr.linked-row:hover td {
1041
+ background: var(--accent-soft);
1042
+ }
1043
+ table.board tr.linked-row a {
1044
+ color: var(--ink);
1045
+ font-weight: 600;
1046
+ text-decoration: none;
1047
+ }
1048
+ table.board tr.linked-row:hover a {
1049
+ color: var(--accent-strong);
1050
+ }
1051
+
1052
+ /* ---- agent read hint ---- */
1053
+ .agent-hint {
1054
+ display: flex;
1055
+ align-items: center;
1056
+ flex-wrap: wrap;
1057
+ gap: 8px;
1058
+ margin: 4px 0 22px;
1059
+ font-size: 12.5px;
1060
+ color: var(--muted);
1061
+ }
1062
+ #page .agent-hint code {
1063
+ background: var(--code-bg);
1064
+ padding: 2px 9px;
1065
+ border-radius: 6px;
1066
+ font-family: var(--mono);
1067
+ font-size: 12px;
1068
+ font-weight: 500;
1069
+ color: var(--ink);
1070
+ }
1071
+ .agent-hint .copy {
1072
+ flex: 0 0 auto;
1073
+ background: none;
1074
+ color: var(--muted);
1075
+ border: 1px solid var(--line);
1076
+ border-radius: 6px;
1077
+ width: 22px;
1078
+ height: 22px;
1079
+ font-size: 11px;
1080
+ line-height: 1;
1081
+ cursor: pointer;
1082
+ transition: color 0.12s, border-color 0.12s;
1083
+ }
1084
+ .agent-hint .copy:hover {
1085
+ color: var(--accent-strong);
1086
+ border-color: var(--accent);
1087
+ }
1088
+ .agent-hint .copy.copied {
1089
+ color: #1a8a55;
1090
+ border-color: #1a8a55;
1091
+ }
1092
+ .agent-hint-note {
1093
+ margin-left: auto;
1094
+ font-size: 12px;
1095
+ color: var(--muted);
1096
+ }
1097
+
1098
+ /* ---- logbook summary stats ---- */
1099
+ .logbook-stats {
1100
+ display: flex;
1101
+ flex-wrap: wrap;
1102
+ gap: 12px;
1103
+ margin: 0 0 28px;
1104
+ }
1105
+ .stat-tile {
1106
+ position: relative;
1107
+ display: inline-flex;
1108
+ align-items: center;
1109
+ gap: 11px;
1110
+ border: 1px solid var(--line);
1111
+ background: var(--panel);
1112
+ border-radius: var(--radius);
1113
+ padding: 12px 23px;
1114
+ font: inherit;
1115
+ text-align: left;
1116
+ cursor: pointer;
1117
+ transition: border-color 0.12s, box-shadow 0.12s;
1118
+ }
1119
+ .stat-tile:hover:not([disabled]) {
1120
+ border-color: rgba(249, 115, 22, 0.45);
1121
+ box-shadow: 0 3px 12px rgba(31, 41, 55, 0.06);
1122
+ }
1123
+ .stat-tile:focus-visible {
1124
+ outline: 2px solid var(--accent);
1125
+ outline-offset: 2px;
1126
+ }
1127
+ .stat-tile[disabled] {
1128
+ cursor: default;
1129
+ opacity: 0.7;
1130
+ }
1131
+ .stat-tile.open {
1132
+ border-color: rgba(249, 115, 22, 0.6);
1133
+ box-shadow: 0 3px 12px rgba(31, 41, 55, 0.08);
1134
+ }
1135
+ .stat-icon {
1136
+ width: 24px;
1137
+ height: 24px;
1138
+ flex: 0 0 24px;
1139
+ object-fit: contain;
1140
+ align-self: center;
1141
+ }
1142
+ .stat-text {
1143
+ display: flex;
1144
+ align-items: baseline;
1145
+ gap: 8px;
1146
+ white-space: nowrap;
1147
+ line-height: 1;
1148
+ }
1149
+ .stat-num {
1150
+ font-family: var(--mono);
1151
+ font-size: 20px;
1152
+ font-weight: 600;
1153
+ line-height: 1;
1154
+ color: var(--accent-strong);
1155
+ }
1156
+ .stat-label {
1157
+ font-size: 15px;
1158
+ line-height: 1;
1159
+ color: var(--muted);
1160
+ }
1161
+ .stat-caret {
1162
+ margin-left: 2px;
1163
+ font-size: 10px;
1164
+ color: var(--muted);
1165
+ align-self: center;
1166
+ transition: transform 0.12s;
1167
+ }
1168
+ .stat-tile.open .stat-caret {
1169
+ transform: rotate(180deg);
1170
+ }
1171
+ .stat-popover {
1172
+ position: absolute;
1173
+ top: 100%;
1174
+ left: 0;
1175
+ margin-top: 6px;
1176
+ min-width: 300px;
1177
+ max-width: min(460px, 92vw);
1178
+ max-height: 340px;
1179
+ overflow-y: auto;
1180
+ z-index: 20;
1181
+ background: var(--panel);
1182
+ border: 1px solid var(--line);
1183
+ border-radius: var(--radius);
1184
+ box-shadow: 0 8px 28px rgba(31, 41, 55, 0.12);
1185
+ padding: 6px;
1186
+ }
1187
+ .stat-popover[hidden] {
1188
+ display: none;
1189
+ }
1190
+ .stat-pop-head {
1191
+ padding: 6px 10px 8px;
1192
+ font-size: 11.5px;
1193
+ font-weight: 700;
1194
+ letter-spacing: 0.03em;
1195
+ text-transform: uppercase;
1196
+ color: var(--muted);
1197
+ }
1198
+ .stat-row {
1199
+ display: flex;
1200
+ align-items: flex-start;
1201
+ gap: 10px;
1202
+ padding: 9px 11px;
1203
+ border-radius: 9px;
1204
+ border: 1px solid transparent;
1205
+ text-decoration: none;
1206
+ color: inherit;
1207
+ cursor: pointer;
1208
+ }
1209
+ .stat-row:hover {
1210
+ border-color: rgba(249, 115, 22, 0.4);
1211
+ background: var(--accent-soft);
1212
+ }
1213
+ .stat-row-ico {
1214
+ font-size: 15px;
1215
+ line-height: 1.3;
1216
+ flex: 0 0 auto;
1217
+ }
1218
+ .stat-row-main {
1219
+ min-width: 0;
1220
+ flex: 1;
1221
+ }
1222
+ .stat-row-title {
1223
+ font-family: var(--mono);
1224
+ font-size: 12.5px;
1225
+ font-weight: 600;
1226
+ color: var(--ink);
1227
+ overflow: hidden;
1228
+ text-overflow: ellipsis;
1229
+ white-space: nowrap;
1230
+ }
1231
+ .stat-row-meta {
1232
+ margin-top: 2px;
1233
+ font-size: 12px;
1234
+ color: var(--muted);
1235
+ }
1236
+ .stat-row-state.open {
1237
+ color: var(--accent);
1238
+ font-weight: 600;
1239
+ border-radius: 5px;
1240
+ padding: 1px 5px;
1241
+ margin: -1px -2px;
1242
+ }
1243
+ .stat-row-state.open:hover {
1244
+ background: rgba(249, 115, 22, 0.14);
1245
+ text-decoration: underline;
1246
+ }
1247
+ .art-ico {
1248
+ width: 1em;
1249
+ height: 1em;
1250
+ object-fit: contain;
1251
+ vertical-align: -0.15em;
1252
+ }
1253
+
1254
+ /* ---- scroll-to-resource highlight ---- */
1255
+ .res-flash {
1256
+ animation: res-flash 1.5s ease;
1257
+ border-radius: 8px;
1258
+ }
1259
+ @keyframes res-flash {
1260
+ 0%,
1261
+ 25% {
1262
+ box-shadow: 0 0 0 3px var(--accent);
1263
+ }
1264
+ 100% {
1265
+ box-shadow: 0 0 0 3px rgba(249, 115, 22, 0);
1266
+ }
1267
+ }
1268
+
1269
+ /* ---- inline resource chips ---- */
1270
+ #page .res-chip {
1271
+ display: inline-flex;
1272
+ align-items: center;
1273
+ gap: 5px;
1274
+ max-width: 100%;
1275
+ padding: 0 9px 0 6px;
1276
+ margin: 0 1px;
1277
+ border: 1px solid var(--line);
1278
+ border-radius: 999px;
1279
+ background: var(--panel);
1280
+ font-family: var(--mono);
1281
+ font-size: 0.78em;
1282
+ font-weight: 600;
1283
+ color: var(--ink);
1284
+ text-decoration: none;
1285
+ white-space: nowrap;
1286
+ overflow: hidden;
1287
+ text-overflow: ellipsis;
1288
+ vertical-align: middle;
1289
+ line-height: 1.65;
1290
+ transform: translateY(-0.08em);
1291
+ transition: border-color 0.12s, background 0.12s, color 0.12s;
1292
+ }
1293
+ .res-chip-ico {
1294
+ font-size: 1.05em;
1295
+ line-height: 1;
1296
+ }
1297
+ #page .res-chip:hover,
1298
+ #page .res-chip.res-hl {
1299
+ border-color: var(--accent);
1300
+ background: var(--accent-soft);
1301
+ color: var(--accent-strong);
1302
+ }
1303
+ #page a.res-link.res-hl {
1304
+ background: var(--accent-soft);
1305
+ border-radius: 4px;
1306
+ }
1307
+ .rail-item.res-hl {
1308
+ border-color: var(--accent);
1309
+ background: var(--accent-soft);
1310
+ box-shadow: 0 3px 12px rgba(249, 115, 22, 0.14);
1311
+ }
1312
+ .rail-item.res-hl .rail-title {
1313
+ color: var(--accent-strong);
1314
+ }
1315
+ .rail-item.rail-local {
1316
+ cursor: default;
1317
+ }
1318
+ .artifact-chip.res-hl {
1319
+ border-color: var(--accent);
1320
+ background: var(--accent-soft);
1321
+ }
1322
+
1323
+ /* ---- contextual resources rail ---- */
1324
+ .context-rail {
1325
+ position: relative;
1326
+ width: 248px;
1327
+ }
1328
+ .context-rail[hidden] {
1329
+ display: none;
1330
+ }
1331
+ .rail-kind {
1332
+ display: flex;
1333
+ align-items: center;
1334
+ gap: 5px;
1335
+ font-family: var(--mono);
1336
+ font-size: 10px;
1337
+ text-transform: uppercase;
1338
+ letter-spacing: 0.08em;
1339
+ font-weight: 600;
1340
+ color: var(--accent);
1341
+ margin-bottom: 4px;
1342
+ }
1343
+ .rail-item {
1344
+ position: absolute;
1345
+ left: 0;
1346
+ right: 0;
1347
+ display: block;
1348
+ border: 1px solid var(--line);
1349
+ border-radius: 10px;
1350
+ background: var(--panel);
1351
+ padding: 9px 12px;
1352
+ margin-bottom: 8px;
1353
+ text-decoration: none;
1354
+ color: inherit;
1355
+ transition: border-color 0.14s, box-shadow 0.14s;
1356
+ }
1357
+ .rail-item:hover {
1358
+ border-color: rgba(249, 115, 22, 0.45);
1359
+ box-shadow: 0 3px 12px rgba(31, 41, 55, 0.06);
1360
+ }
1361
+ .rail-title {
1362
+ font-family: var(--mono);
1363
+ font-size: 12.5px;
1364
+ font-weight: 600;
1365
+ color: var(--ink);
1366
+ overflow-wrap: anywhere;
1367
+ line-height: 1.4;
1368
+ }
1369
+ .rail-item:hover .rail-title {
1370
+ color: var(--accent-strong);
1371
+ }
1372
+ .rail-meta {
1373
+ font-size: 11.5px;
1374
+ color: var(--muted);
1375
+ margin-top: 2px;
1376
+ }
1377
+
1378
+ @media (max-width: 1400px) {
1379
+ .page-layout {
1380
+ display: block;
1381
+ }
1382
+ .context-rail {
1383
+ width: 100%;
1384
+ margin-top: 28px;
1385
+ position: static;
1386
+ min-height: 0 !important;
1387
+ display: grid;
1388
+ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
1389
+ gap: 10px;
1390
+ }
1391
+ .context-rail[hidden] {
1392
+ display: none;
1393
+ }
1394
+ .context-rail .rail-item {
1395
+ position: static;
1396
+ margin-bottom: 0;
1397
+ }
1398
+ }
1399
+
1400
+ /* ---- connect footer + modal ---- */
1401
+ #sidebar-foot {
1402
+ margin-top: auto;
1403
+ padding-top: 14px;
1404
+ border-top: 1px solid rgba(255, 255, 255, 0.1);
1405
+ }
1406
+
1407
+ #connect-btn {
1408
+ width: 100%;
1409
+ display: flex;
1410
+ align-items: center;
1411
+ gap: 8px;
1412
+ background: rgba(255, 255, 255, 0.05);
1413
+ color: #c3c4cb;
1414
+ border: 1px solid rgba(255, 255, 255, 0.12);
1415
+ border-radius: 9px;
1416
+ padding: 9px 12px;
1417
+ font-size: 13.5px;
1418
+ font-family: var(--sans);
1419
+ cursor: pointer;
1420
+ transition: background 0.12s, color 0.12s, border-color 0.12s;
1421
+ }
1422
+ #connect-btn:hover {
1423
+ background: rgba(249, 115, 22, 0.14);
1424
+ border-color: rgba(249, 115, 22, 0.4);
1425
+ color: #fdba74;
1426
+ }
1427
+ #connect-btn .ico {
1428
+ font-size: 15px;
1429
+ }
1430
+
1431
+ #modal[hidden] {
1432
+ display: none;
1433
+ }
1434
+ #modal {
1435
+ position: fixed;
1436
+ inset: 0;
1437
+ z-index: 100;
1438
+ display: flex;
1439
+ align-items: center;
1440
+ justify-content: center;
1441
+ padding: 24px;
1442
+ }
1443
+ .modal-backdrop {
1444
+ position: absolute;
1445
+ inset: 0;
1446
+ background: rgba(20, 18, 30, 0.5);
1447
+ backdrop-filter: blur(2px);
1448
+ }
1449
+ .modal-card {
1450
+ position: relative;
1451
+ background: var(--panel);
1452
+ border-radius: 16px;
1453
+ width: 100%;
1454
+ max-width: 620px;
1455
+ max-height: 85vh;
1456
+ overflow-y: auto;
1457
+ box-shadow: 0 24px 70px rgba(20, 15, 50, 0.28);
1458
+ }
1459
+ .modal-head {
1460
+ display: flex;
1461
+ align-items: center;
1462
+ justify-content: space-between;
1463
+ gap: 12px;
1464
+ padding: 18px 22px;
1465
+ border-bottom: 1px solid var(--line);
1466
+ position: sticky;
1467
+ top: 0;
1468
+ background: var(--panel);
1469
+ }
1470
+ .modal-title {
1471
+ display: flex;
1472
+ align-items: center;
1473
+ gap: 10px;
1474
+ font-family: var(--serif);
1475
+ font-size: 21px;
1476
+ letter-spacing: -0.01em;
1477
+ }
1478
+ .modal-logo {
1479
+ width: 26px;
1480
+ height: 26px;
1481
+ object-fit: contain;
1482
+ }
1483
+ .modal-actions {
1484
+ display: flex;
1485
+ align-items: center;
1486
+ gap: 8px;
1487
+ }
1488
+ .btn {
1489
+ font-family: var(--sans);
1490
+ font-size: 13.5px;
1491
+ font-weight: 600;
1492
+ border: 1px solid var(--line);
1493
+ background: var(--panel);
1494
+ color: var(--ink);
1495
+ border-radius: 9px;
1496
+ padding: 8px 13px;
1497
+ cursor: pointer;
1498
+ transition: background 0.12s, border-color 0.12s, color 0.12s;
1499
+ }
1500
+ .btn:hover {
1501
+ border-color: var(--accent);
1502
+ color: var(--accent-strong);
1503
+ }
1504
+ .btn.copied {
1505
+ border-color: #1a8a55;
1506
+ color: #1a8a55;
1507
+ }
1508
+ .btn.icon {
1509
+ font-size: 18px;
1510
+ line-height: 1;
1511
+ padding: 6px 11px;
1512
+ font-weight: 400;
1513
+ }
1514
+ .modal-body {
1515
+ padding: 20px 22px 26px;
1516
+ }
1517
+ .modal-intro {
1518
+ margin: 0 0 20px;
1519
+ color: var(--muted);
1520
+ line-height: 1.55;
1521
+ }
1522
+ #connect-steps {
1523
+ list-style: none;
1524
+ margin: 0;
1525
+ padding: 0;
1526
+ }
1527
+ #connect-steps li {
1528
+ margin-bottom: 18px;
1529
+ }
1530
+ .step-title {
1531
+ font-weight: 600;
1532
+ font-size: 14.5px;
1533
+ margin-bottom: 8px;
1534
+ }
1535
+ .codeblock {
1536
+ display: flex;
1537
+ align-items: center;
1538
+ gap: 8px;
1539
+ background: #17181c;
1540
+ border-radius: 10px;
1541
+ padding: 11px 12px 11px 15px;
1542
+ }
1543
+ .codeblock code {
1544
+ flex: 1;
1545
+ min-width: 0;
1546
+ overflow-x: auto;
1547
+ white-space: nowrap;
1548
+ font-family: var(--mono);
1549
+ font-size: 13px;
1550
+ color: #f0efff;
1551
+ background: none;
1552
+ padding: 0;
1553
+ }
1554
+ .codeblock .copy {
1555
+ flex: 0 0 auto;
1556
+ background: rgba(255, 255, 255, 0.08);
1557
+ color: #c3c4cb;
1558
+ border: 1px solid rgba(255, 255, 255, 0.14);
1559
+ border-radius: 7px;
1560
+ width: 30px;
1561
+ height: 30px;
1562
+ font-size: 14px;
1563
+ cursor: pointer;
1564
+ transition: background 0.12s, color 0.12s;
1565
+ }
1566
+ .codeblock .copy:hover {
1567
+ background: rgba(249, 115, 22, 0.2);
1568
+ color: #fdba74;
1569
+ }
1570
+ .codeblock .copy.copied {
1571
+ color: #52d08a;
1572
+ }
1573
+
1574
+ @media (max-width: 720px) {
1575
+ #app {
1576
+ flex-direction: column;
1577
+ }
1578
+ #sidebar {
1579
+ width: 100%;
1580
+ flex: none;
1581
+ height: auto;
1582
+ position: static;
1583
+ }
1584
+ #content {
1585
+ display: block;
1586
+ width: 100%;
1587
+ padding: 28px 20px 80px;
1588
+ overflow-x: hidden;
1589
+ }
1590
+ #page {
1591
+ width: 100%;
1592
+ max-width: 100%;
1593
+ }
1594
+ #page h1 {
1595
+ font-size: 30px;
1596
+ }
1597
+ .cell-head {
1598
+ align-items: flex-start;
1599
+ flex-direction: column;
1600
+ gap: 4px;
1601
+ }
1602
+ }
.trackio/logbook/logbook.js ADDED
@@ -0,0 +1,2275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function () {
2
+ "use strict";
3
+
4
+ let MANIFEST = null;
5
+ const PAGE_CACHE = {};
6
+ const UNFURL_CACHE = {};
7
+ const LIVE_RELOAD_MS = 1500;
8
+ const FIGURE_FRAME_WINDOWS = new Set();
9
+ let FIGURE_NAVIGATION_READY = false;
10
+
11
+ function esc(s) {
12
+ return String(s)
13
+ .replace(/&/g, "&amp;")
14
+ .replace(/</g, "&lt;")
15
+ .replace(/>/g, "&gt;")
16
+ .replace(/"/g, "&quot;")
17
+ .replace(/'/g, "&#39;");
18
+ }
19
+
20
+ function flattenTree(node, depth, acc) {
21
+ acc.push({ node: node, depth: depth });
22
+ (node.children || []).forEach((c) => flattenTree(c, depth + 1, acc));
23
+ return acc;
24
+ }
25
+
26
+ function findNode(node, slug) {
27
+ if (node.slug === slug) return node;
28
+ for (const c of node.children || []) {
29
+ const hit = findNode(c, slug);
30
+ if (hit) return hit;
31
+ }
32
+ return null;
33
+ }
34
+
35
+ /* -------------------- minimal markdown -------------------- */
36
+
37
+ function inline(text) {
38
+ let t = esc(text);
39
+ t = t.replace(/`([^`]+)`/g, (_, c) => `<code>${c}</code>`);
40
+ t = t.replace(/\*\*([^*]+)\*\*/g, (_, c) => `<strong>${c}</strong>`);
41
+ t = t.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_, txt, url) => {
42
+ const safe = esc(url);
43
+ const attrs = /^https?:/.test(url) ? ' target="_blank" rel="noopener"' : "";
44
+ const item = /^https?:/.test(url) ? classifyResource(url) : null;
45
+ const data = item
46
+ ? ` class="res-link" data-res-url="${esc(item.url)}"`
47
+ : "";
48
+ return `<a href="${safe}"${attrs}${data}>${txt}</a>`;
49
+ });
50
+ t = t.replace(/(^|[\s(])(https?:\/\/[^\s<>)"'`]+)/g, (m, pre, url) => {
51
+ let rest = "";
52
+ const cut = url.search(/&quot;|&#39;|&lt;|&gt;/);
53
+ if (cut !== -1) {
54
+ rest = url.slice(cut);
55
+ url = url.slice(0, cut);
56
+ }
57
+ const trailing = (url.match(/[.,;:!?`]+$/) || [""])[0];
58
+ const clean = trailing ? url.slice(0, -trailing.length) : url;
59
+ if (!clean) return m;
60
+ const item = classifyResource(clean);
61
+ if (item) return `${pre}${resChipHtml(item)}${trailing}${rest}`;
62
+ return `${pre}<a href="${clean}" target="_blank" rel="noopener">${clean}</a>${trailing}${rest}`;
63
+ });
64
+ return t;
65
+ }
66
+
67
+ function resChipHtml(item) {
68
+ return (
69
+ `<a class="res-chip" href="${esc(item.url)}" target="_blank" ` +
70
+ `rel="noopener" data-res-url="${esc(item.url)}">` +
71
+ `<span class="res-chip-ico">${RESOURCE_ICONS[item.kind]}</span>` +
72
+ `${esc(item.id)}</a>`
73
+ );
74
+ }
75
+
76
+ const URL_ONLY = /^(https?:\/\/[^\s]+)$/;
77
+ const DETECTED_URL =
78
+ /(https?:\/\/[^\s<>)\]"'`]+|trackio-local-dashboard:\/\/[^\s<>)\]"'`]+|trackio-artifact:\/\/[^\s<>)\]"'`]+|trackio-local-path:\/\/[^\s<>)\]"'`]+)/g;
79
+
80
+ function renderMarkdown(md, container) {
81
+ const cellRe = /(^|\n)---\n<!-- trackio-cell\n([\s\S]*?)\n-->\n([\s\S]*?)(?=\n---\n<!-- trackio-cell\n|\s*$)/g;
82
+ const tokens = [];
83
+ let pos = 0;
84
+ let found = false;
85
+ let match;
86
+ while ((match = cellRe.exec(md))) {
87
+ found = true;
88
+ tokens.push({
89
+ kind: "md",
90
+ text: md.slice(pos, match.index + match[1].length),
91
+ });
92
+ tokens.push({
93
+ kind: "cell",
94
+ meta: parseCellMeta(match[2]),
95
+ body: match[3],
96
+ });
97
+ pos = match.index + match[0].length;
98
+ }
99
+ tokens.push({ kind: "md", text: found ? md.slice(pos) : md });
100
+
101
+ for (let i = 0; i < tokens.length; i++) {
102
+ const t = tokens[i];
103
+ if (t.kind === "md") {
104
+ renderMarkdownPlain(t.text, container);
105
+ continue;
106
+ }
107
+ if (t.consumed) continue;
108
+ if (t.meta.type === "code") {
109
+ const arts = [];
110
+ for (let j = i + 1; j < tokens.length; j++) {
111
+ const n = tokens[j];
112
+ if (n.kind === "md") {
113
+ if (n.text.trim() === "") continue;
114
+ break;
115
+ }
116
+ if (n.meta.type === "artifact") {
117
+ arts.push(n);
118
+ n.consumed = true;
119
+ continue;
120
+ }
121
+ break;
122
+ }
123
+ renderCell(t.meta, t.body, container, arts);
124
+ } else {
125
+ renderCell(t.meta, t.body, container);
126
+ }
127
+ }
128
+ }
129
+
130
+ function parseCellMeta(raw) {
131
+ try {
132
+ return JSON.parse(raw);
133
+ } catch (e) {
134
+ return { type: "markdown", title: "Note" };
135
+ }
136
+ }
137
+
138
+ function renderMarkdownPlain(md, container) {
139
+ const lines = md.replace(/<!--[\s\S]*?-->/g, "").split("\n");
140
+ let i = 0;
141
+ let para = [];
142
+
143
+ function flushPara() {
144
+ if (!para.length) return;
145
+ const joined = para.join(" ").trim();
146
+ para = [];
147
+ if (!joined) return;
148
+ if (/^trackio-artifact:\/\/\S+$/.test(joined)) return;
149
+ if (/^trackio-local-path:\/\/\S+$/.test(joined)) return;
150
+ if (joined.indexOf("📦 Artifact") !== -1) {
151
+ const div = document.createElement("div");
152
+ div.className = "artifact-chip";
153
+ div.innerHTML = ARTIFACT_ICON_IMG + inline(joined.replace(/📦\s*/, ""));
154
+ container.appendChild(div);
155
+ return;
156
+ }
157
+ if (URL_ONLY.test(joined) || IMG_PATH.test(joined)) {
158
+ const el = renderStandaloneUrl(joined);
159
+ if (el) container.appendChild(el);
160
+ return;
161
+ }
162
+ const p = document.createElement("p");
163
+ p.innerHTML = inline(joined);
164
+ container.appendChild(p);
165
+ }
166
+
167
+ while (i < lines.length) {
168
+ const line = lines[i];
169
+ const trimmed = line.trim();
170
+
171
+ if (trimmed === "") {
172
+ flushPara();
173
+ i++;
174
+ continue;
175
+ }
176
+ const fence = trimmed.match(/^(`{3,}|~{3,})(.*)$/);
177
+ if (fence) {
178
+ flushPara();
179
+ const marker = fence[1][0];
180
+ const closeRe = new RegExp("^" + marker + "{" + fence[1].length + ",}\\s*$");
181
+ const info = fence[2].trim();
182
+ const buf = [];
183
+ i++;
184
+ while (i < lines.length && !closeRe.test(lines[i].trim())) {
185
+ buf.push(lines[i]);
186
+ i++;
187
+ }
188
+ i++;
189
+ const lang = (info.split(/\s+/)[0] || "").toLowerCase();
190
+ const tm = info.match(/title=(\S+)/);
191
+ container.appendChild(
192
+ renderCode(buf.join("\n"), lang, tm ? tm[1] : null)
193
+ );
194
+ continue;
195
+ }
196
+ if (trimmed === "---") {
197
+ flushPara();
198
+ container.appendChild(document.createElement("hr"));
199
+ i++;
200
+ continue;
201
+ }
202
+ const h = trimmed.match(/^(#{1,4})\s+(.*)$/);
203
+ if (h) {
204
+ flushPara();
205
+ const el = document.createElement("h" + h[1].length);
206
+ el.innerHTML = inline(h[2]);
207
+ container.appendChild(el);
208
+ i++;
209
+ continue;
210
+ }
211
+ if (
212
+ trimmed.startsWith("|") &&
213
+ i + 1 < lines.length &&
214
+ /^\|?[\s:|-]*-{2,}[\s:|-]*\|?$/.test(lines[i + 1].trim())
215
+ ) {
216
+ flushPara();
217
+ const rows = [];
218
+ while (i < lines.length && lines[i].trim().startsWith("|")) {
219
+ rows.push(parseRow(lines[i].trim()));
220
+ i++;
221
+ }
222
+ renderTable(rows, container);
223
+ continue;
224
+ }
225
+ if (trimmed.startsWith("> ")) {
226
+ flushPara();
227
+ const bq = document.createElement("blockquote");
228
+ bq.innerHTML = inline(trimmed.slice(2));
229
+ container.appendChild(bq);
230
+ i++;
231
+ continue;
232
+ }
233
+ if (/^`[^`]+`$/.test(trimmed)) {
234
+ flushPara();
235
+ const el = document.createElement("div");
236
+ el.className = "ts";
237
+ el.textContent = trimmed.replace(/`/g, "");
238
+ container.appendChild(el);
239
+ i++;
240
+ continue;
241
+ }
242
+ if (trimmed.startsWith("- ")) {
243
+ flushPara();
244
+ const items = [];
245
+ while (i < lines.length && lines[i].trim().startsWith("- ")) {
246
+ items.push(lines[i].trim().slice(2).trim());
247
+ i++;
248
+ }
249
+ renderList(items, container);
250
+ continue;
251
+ }
252
+ para.push(trimmed);
253
+ i++;
254
+ }
255
+ flushPara();
256
+ }
257
+
258
+ function renderCell(meta, body, container, artifacts) {
259
+ const cell = document.createElement("section");
260
+ cell.className = `cell ${meta.type || "markdown"}`;
261
+ if (meta.id) cell.dataset.cellId = meta.id;
262
+ if (isPinned(meta)) cell.classList.add("pinned-source");
263
+
264
+ const head = document.createElement("div");
265
+ head.className = "cell-head";
266
+ const rawTitle = (meta.title || "").trim();
267
+ const title = rawTitle && rawTitle.toLowerCase() !== "untitled" ? esc(rawTitle) : "";
268
+ const when = meta.created_at ? `<span>${esc(formatTime(meta.created_at))}</span>` : "";
269
+ head.innerHTML =
270
+ (title ? `<div class="cell-title">${title}</div>` : "") +
271
+ `<div class="cell-meta">${when}</div>`;
272
+ if (!title) head.classList.add("no-title");
273
+ cell.appendChild(head);
274
+
275
+ const bodyEl = document.createElement("div");
276
+ bodyEl.className = "cell-body";
277
+ if (meta.type === "code") {
278
+ renderCodeCell(body, bodyEl, artifacts);
279
+ } else if (meta.type === "figure") {
280
+ cell.dataset.resUrl = `trackio-figure://${(meta.title || "Figure").trim()}`;
281
+ renderFigureCell(body, bodyEl, head);
282
+ } else if (meta.type === "artifact") {
283
+ renderMarkdownPlain(body, bodyEl);
284
+ const chip = bodyEl.querySelector(".artifact-chip");
285
+ const uri = body.match(
286
+ /(trackio-artifact:\/\/\S+|trackio-local-path:\/\/\S+|https:\/\/huggingface\.co\/buckets\/[^\s<)]+#\S+)/
287
+ );
288
+ if (chip && uri) chip.dataset.resUrl = uri[1];
289
+ } else if (meta.type === "dashboard") {
290
+ const sp = body.match(/https:\/\/huggingface\.co\/spaces\/[^\s<>)"'`]+/);
291
+ cell.dataset.resUrl = sp
292
+ ? sp[0]
293
+ : `trackio-local-dashboard://${(meta.dashboard_project || "").trim()}`;
294
+ renderDashboardCell(meta, body, bodyEl, head);
295
+ } else {
296
+ const cleaned = stripDuplicateTitle(body, meta.title);
297
+ renderMarkdownPlain(cleaned, bodyEl);
298
+ renderDetectedEmbeds(cleaned, bodyEl);
299
+ }
300
+ cell.appendChild(bodyEl);
301
+ container.appendChild(cell);
302
+ return cell;
303
+ }
304
+
305
+ function isPinned(meta) {
306
+ return Boolean(meta && (meta.pinned === true || meta.pinned === "true"));
307
+ }
308
+
309
+ function stripDuplicateTitle(body, title) {
310
+ if (!title) return body;
311
+ const m = body.match(/^\s*#{1,6}\s+([^\n]+)\n?/);
312
+ if (!m) return body;
313
+ const norm = (s) =>
314
+ s
315
+ .toLowerCase()
316
+ .replace(/[*_`#]/g, "")
317
+ .replace(/\s+/g, " ")
318
+ .trim();
319
+ return norm(m[1]) === norm(title) ? body.slice(m[0].length) : body;
320
+ }
321
+
322
+ function formatTime(iso) {
323
+ const d = new Date(iso);
324
+ if (Number.isNaN(d.getTime())) return iso;
325
+ return d.toLocaleString(undefined, {
326
+ month: "short",
327
+ day: "numeric",
328
+ hour: "2-digit",
329
+ minute: "2-digit",
330
+ });
331
+ }
332
+
333
+ function parseFences(text) {
334
+ const fenceRe = /(`{3,4}|~{3,4})([^\n]*)\n([\s\S]*?)\n\1/g;
335
+ const parts = [];
336
+ let pos = 0;
337
+ let match;
338
+ while ((match = fenceRe.exec(text))) {
339
+ if (match.index > pos) {
340
+ parts.push({ kind: "text", text: text.slice(pos, match.index) });
341
+ }
342
+ const info = match[2].trim();
343
+ const lang = (info.split(/\s+/)[0] || "").toLowerCase();
344
+ const titleMatch = info.match(/title=(\S+)/);
345
+ parts.push({
346
+ kind: lang === "result" || lang === "output" ? "output" : "code",
347
+ lang,
348
+ title: titleMatch ? titleMatch[1] : null,
349
+ text: match[3],
350
+ });
351
+ pos = match.index + match[0].length;
352
+ }
353
+ if (pos < text.length) parts.push({ kind: "text", text: text.slice(pos) });
354
+ return parts;
355
+ }
356
+
357
+ function fitFigureFrame(frame, wrap) {
358
+ let doc;
359
+ try {
360
+ doc = frame.contentDocument;
361
+ } catch (e) {
362
+ return;
363
+ }
364
+ if (!doc || !doc.body) return;
365
+ frame.style.transform = "none";
366
+ frame.style.width = "100%";
367
+ frame.style.height = "auto";
368
+ frame.style.position = "";
369
+ frame.style.left = "";
370
+ frame.style.top = "";
371
+ const avail = wrap.clientWidth;
372
+ const isFullscreen =
373
+ document.fullscreenElement === wrap ||
374
+ document.webkitFullscreenElement === wrap;
375
+ const availHeight = isFullscreen ? wrap.clientHeight : Infinity;
376
+ const cw = Math.max(doc.body.scrollWidth, doc.documentElement.scrollWidth, 1);
377
+ const ch = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight, 1);
378
+ const scale = Math.min(avail / cw, availHeight / ch);
379
+ if (avail && scale < 1 - 1e-3) {
380
+ frame.style.width = `${cw}px`;
381
+ frame.style.height = `${ch}px`;
382
+ frame.style.transformOrigin = "top left";
383
+ frame.style.transform = `scale(${scale})`;
384
+ if (isFullscreen) {
385
+ frame.style.position = "absolute";
386
+ frame.style.left = `${Math.max(0, (avail - cw * scale) / 2)}px`;
387
+ frame.style.top = `${Math.max(0, (availHeight - ch * scale) / 2)}px`;
388
+ wrap.style.height = "100%";
389
+ } else {
390
+ wrap.style.height = `${Math.ceil(ch * scale)}px`;
391
+ }
392
+ } else {
393
+ frame.style.width = "100%";
394
+ frame.style.height = `${ch}px`;
395
+ wrap.style.height = isFullscreen ? "100%" : `${ch}px`;
396
+ }
397
+ }
398
+
399
+ function attachFigureFit(frame, wrap) {
400
+ const refit = () => fitFigureFrame(frame, wrap);
401
+ frame.addEventListener("load", refit);
402
+ if (window.ResizeObserver) {
403
+ const ro = new ResizeObserver(() => refit());
404
+ ro.observe(wrap);
405
+ }
406
+ }
407
+
408
+ function renderFigureCell(text, container, head) {
409
+ const parts = parseFences(text);
410
+ const htmlPart = parts.find((part) => part.lang === "html");
411
+ const rawPart = parts.find((part) => part.lang === "raw");
412
+ if (!htmlPart || !htmlPart.text.trim()) {
413
+ const empty = document.createElement("p");
414
+ empty.className = "muted";
415
+ empty.textContent = "No figure HTML.";
416
+ container.appendChild(empty);
417
+ return;
418
+ }
419
+ const frame = document.createElement("iframe");
420
+ frame.className = "figure-frame";
421
+ frame.sandbox = "allow-scripts allow-same-origin";
422
+ frame.loading = "lazy";
423
+ frame.srcdoc = htmlPart.text;
424
+ registerFigureNavigation(frame);
425
+ const figWrap = document.createElement("div");
426
+ figWrap.className = "figure-fit";
427
+ figWrap.appendChild(frame);
428
+ attachFigureFit(frame, figWrap);
429
+ if (head) {
430
+ const metaEl = head.querySelector(".cell-meta");
431
+ if (metaEl)
432
+ metaEl.insertBefore(buildFullscreenControl(figWrap, frame), metaEl.firstChild);
433
+ }
434
+ if (!rawPart || !rawPart.text.trim()) {
435
+ container.appendChild(figWrap);
436
+ return;
437
+ }
438
+ const sw = document.createElement("div");
439
+ sw.className = "fig-switch";
440
+ const thumb = document.createElement("span");
441
+ thumb.className = "fig-switch-thumb";
442
+ const figBtn = document.createElement("button");
443
+ figBtn.type = "button";
444
+ figBtn.className = "active";
445
+ figBtn.textContent = "Figure";
446
+ const rawBtn = document.createElement("button");
447
+ rawBtn.type = "button";
448
+ rawBtn.textContent = "Raw";
449
+ sw.appendChild(thumb);
450
+ sw.appendChild(figBtn);
451
+ sw.appendChild(rawBtn);
452
+ const rawView = document.createElement("div");
453
+ rawView.className = "figure-raw";
454
+ rawView.hidden = true;
455
+ const pre = document.createElement("pre");
456
+ const code = document.createElement("code");
457
+ code.textContent = rawPart.text;
458
+ pre.appendChild(code);
459
+ rawView.appendChild(pre);
460
+ rawView.appendChild(copySnippetBtn(rawPart.text));
461
+ const select = (showRaw) => {
462
+ sw.classList.toggle("raw", showRaw);
463
+ figBtn.classList.toggle("active", !showRaw);
464
+ rawBtn.classList.toggle("active", showRaw);
465
+ figWrap.hidden = showRaw;
466
+ rawView.hidden = !showRaw;
467
+ };
468
+ figBtn.addEventListener("click", () => select(false));
469
+ rawBtn.addEventListener("click", () => select(true));
470
+ if (head) {
471
+ head.insertBefore(sw, head.querySelector(".cell-meta"));
472
+ } else {
473
+ container.appendChild(sw);
474
+ }
475
+ container.appendChild(figWrap);
476
+ container.appendChild(rawView);
477
+ }
478
+
479
+ // Poster embeds can send `{ type: "trackio-logbook:navigate", target: "..." }`
480
+ // from their iframe. Only accept messages from figure frames we created, and
481
+ // only route to pages that are present in this logbook's manifest.
482
+ function registerFigureNavigation(frame) {
483
+ const registerFrameWindow = () => {
484
+ if (frame.contentWindow) FIGURE_FRAME_WINDOWS.add(frame.contentWindow);
485
+ };
486
+ // `srcdoc` replaces the initial about:blank document. Register after that
487
+ // navigation as well, so messages come from the live figure document.
488
+ frame.addEventListener("load", registerFrameWindow);
489
+ registerFrameWindow();
490
+ if (FIGURE_NAVIGATION_READY) return;
491
+ FIGURE_NAVIGATION_READY = true;
492
+ window.addEventListener("message", (event) => {
493
+ if (!FIGURE_FRAME_WINDOWS.has(event.source)) return;
494
+ const message = event.data;
495
+ if (!message || message.type !== "trackio-logbook:navigate") return;
496
+ const target = String(message.target || "").replace(/^#?\//, "");
497
+ if (!target || !MANIFEST || !findNode(MANIFEST.root, target)) return;
498
+ const hash = "#/" + target;
499
+ if (location.hash === hash) scrollToHash();
500
+ else location.hash = hash;
501
+ });
502
+ }
503
+
504
+ const FULLSCREEN_ICON =
505
+ '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" ' +
506
+ 'stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">' +
507
+ '<path d="M8 3H3v5M16 3h5v5M21 16v5h-5M3 16v5h5"/>' +
508
+ '<path d="M3 8 8 3M16 3l5 5M21 16l-5 5M8 21l-5-5"/></svg>';
509
+
510
+ // Figures are rendered in same-origin iframes, so fullscreen the fitted
511
+ // wrapper rather than the iframe document. This uses the browser's native
512
+ // fullscreen UI and preserves the figure's existing responsive sizing.
513
+ function buildFullscreenControl(figWrap, frame) {
514
+ const wrap = document.createElement("span");
515
+ wrap.className = "cell-fullscreen";
516
+ const btn = document.createElement("button");
517
+ btn.type = "button";
518
+ btn.className = "cell-fullscreen-btn";
519
+ btn.setAttribute("aria-label", "Open figure in fullscreen");
520
+ btn.title = "Open figure in fullscreen";
521
+ btn.innerHTML = FULLSCREEN_ICON;
522
+ wrap.appendChild(btn);
523
+
524
+ btn.addEventListener("click", async () => {
525
+ const request = figWrap.requestFullscreen || figWrap.webkitRequestFullscreen;
526
+ if (!request) return;
527
+ try {
528
+ await request.call(figWrap);
529
+ } catch (_) {
530
+ // Fullscreen can be disabled by the embedding browser or policy.
531
+ }
532
+ });
533
+ document.addEventListener("fullscreenchange", () => {
534
+ if (document.fullscreenElement === figWrap) fitFigureFrame(frame, figWrap);
535
+ });
536
+ return wrap;
537
+ }
538
+
539
+ function extractUrls(text) {
540
+ const seen = new Set();
541
+ const urls = [];
542
+ let match;
543
+ while ((match = DETECTED_URL.exec(text))) {
544
+ const url = match[1].replace(/[.,;:!?'"`]+$/, "");
545
+ if (!seen.has(url)) {
546
+ seen.add(url);
547
+ urls.push(url);
548
+ }
549
+ }
550
+ DETECTED_URL.lastIndex = 0;
551
+ return urls;
552
+ }
553
+
554
+ const IMG_URL = /(\.(png|jpe?g|gif|svg|webp)(\?|$)|\/artifact_blob\/)/i;
555
+
556
+ function renderDetectedEmbeds(text, container) {
557
+ extractUrls(text).forEach((url) => {
558
+ if (url.startsWith("trackio-local-dashboard://")) {
559
+ const div = document.createElement("div");
560
+ div.className = "artifact-chip";
561
+ div.dataset.resUrl = url;
562
+ div.innerHTML =
563
+ "🎯 <strong>Local Trackio dashboard</strong> — publish the logbook to share it";
564
+ container.appendChild(div);
565
+ } else if (IMG_URL.test(url)) {
566
+ container.appendChild(renderImage(url));
567
+ } else if (/huggingface\.co\/spaces\//.test(url)) {
568
+ maybeEmbedTrackioSpace(url, container);
569
+ }
570
+ });
571
+ }
572
+
573
+ function renderStandaloneUrl(url) {
574
+ if (IMG_URL.test(url) || IMG_PATH.test(url)) return renderImage(url);
575
+ const item = classifyResource(url);
576
+ if (item) {
577
+ const marker = document.createElement("span");
578
+ marker.className = "resource-anchor";
579
+ marker.dataset.resUrl = item.url;
580
+ marker.setAttribute("aria-hidden", "true");
581
+ return marker;
582
+ }
583
+ const p = document.createElement("p");
584
+ p.innerHTML = inline(url);
585
+ return p;
586
+ }
587
+
588
+ function renderImage(url) {
589
+ const a = document.createElement("a");
590
+ a.className = "unfurl image";
591
+ a.href = url;
592
+ a.target = "_blank";
593
+ a.rel = "noopener";
594
+ const img = document.createElement("img");
595
+ img.loading = "lazy";
596
+ img.src = url;
597
+ img.alt = "artifact image";
598
+ a.appendChild(img);
599
+ return a;
600
+ }
601
+
602
+ function maybeEmbedTrackioSpace(url, container) {
603
+ const id = url.split("/spaces/")[1].split(/[?#]/)[0].replace(/\/$/, "");
604
+ const holder = document.createElement("div");
605
+ container.appendChild(holder);
606
+ getJSON(`https://huggingface.co/api/spaces/${id}`).then((d) => {
607
+ const tags = (d && d.tags) || [];
608
+ if (tags.some((t) => String(t).toLowerCase() === "trackio")) {
609
+ renderTrackioSpaceEmbed(holder, url, id);
610
+ } else {
611
+ holder.remove();
612
+ }
613
+ });
614
+ }
615
+
616
+ function jpGutter(label) {
617
+ const g = document.createElement("div");
618
+ g.className = "jp-gutter";
619
+ g.textContent = label;
620
+ return g;
621
+ }
622
+
623
+ function renderOutArtifact(info) {
624
+ const remote = !info.local && !!info.url;
625
+ const el = document.createElement(remote ? "a" : "div");
626
+ el.className = "out-artifact";
627
+ if (remote) {
628
+ el.href = info.url;
629
+ el.target = "_blank";
630
+ el.rel = "noopener";
631
+ }
632
+ el.dataset.resUrl = info.resUrl;
633
+ const parts = [info.type, info.size].filter(Boolean).map(esc);
634
+ const state = remote
635
+ ? `<span class="out-artifact-state open">Open ↗</span>`
636
+ : `<span class="out-artifact-state">publish to share</span>`;
637
+ const meta = parts.length ? `${parts.join(" · ")} · ${state}` : state;
638
+ el.innerHTML =
639
+ `<span class="out-artifact-ico">${ARTIFACT_ICON_IMG}</span>` +
640
+ `<span class="out-artifact-name">${esc(info.name)}</span>` +
641
+ `<span class="out-artifact-meta">${meta}</span>`;
642
+ return el;
643
+ }
644
+
645
+ function renderCodeCell(body, container, artifacts) {
646
+ const parts = parseFences(body);
647
+ const block = document.createElement("div");
648
+ block.className = "jp";
649
+ const input = document.createElement("div");
650
+ input.className = "jp-in";
651
+ const inputBody = document.createElement("div");
652
+ inputBody.className = "jp-in-body";
653
+ input.appendChild(jpGutter("In"));
654
+ input.appendChild(inputBody);
655
+ let metaEl = null;
656
+ let outputEl = null;
657
+ let outBody = null;
658
+ const ensureOut = () => {
659
+ if (outputEl) return;
660
+ outputEl = document.createElement("div");
661
+ outputEl.className = "jp-out";
662
+ outputEl.appendChild(jpGutter("Out"));
663
+ outBody = document.createElement("div");
664
+ outBody.className = "jp-out-body";
665
+ outputEl.appendChild(outBody);
666
+ };
667
+ const embedTexts = [];
668
+ parts.forEach((part) => {
669
+ if (part.kind === "text") {
670
+ const text = part.text.trim();
671
+ if (!text) return;
672
+ if (/^exit\s+\S+(\s|·)/.test(text)) {
673
+ metaEl = document.createElement("div");
674
+ metaEl.className = "jp-meta";
675
+ metaEl.textContent = text.replace(
676
+ /\s*·\s*[A-Z][a-z]{2} \d{1,2}, \d{4}.*$/,
677
+ ""
678
+ );
679
+ } else {
680
+ renderMarkdownPlain(text, container);
681
+ embedTexts.push(text);
682
+ }
683
+ return;
684
+ }
685
+ if (part.kind === "output") {
686
+ ensureOut();
687
+ const pre = document.createElement("pre");
688
+ pre.className = "jp-out-pre";
689
+ const c = document.createElement("code");
690
+ c.textContent = part.text;
691
+ pre.appendChild(c);
692
+ outBody.appendChild(pre);
693
+ outputEl.appendChild(copySnippetBtn(part.text));
694
+ embedTexts.push(part.text);
695
+ return;
696
+ }
697
+ inputBody.appendChild(renderCode(part.text, part.lang, part.title));
698
+ });
699
+ if (artifacts && artifacts.length) {
700
+ ensureOut();
701
+ const artWrap = document.createElement("div");
702
+ artWrap.className = "jp-artifacts";
703
+ artifacts.forEach((a) => {
704
+ artWrap.appendChild(
705
+ renderOutArtifact(artifactInfoFromCell(a.meta, a.body))
706
+ );
707
+ });
708
+ outBody.appendChild(artWrap);
709
+ }
710
+ if (inputBody.childNodes.length > 0) block.appendChild(input);
711
+ if (metaEl) block.appendChild(metaEl);
712
+ if (outputEl) block.appendChild(outputEl);
713
+ if (block.childNodes.length) container.appendChild(block);
714
+ embedTexts.forEach((text) => renderDetectedEmbeds(text, container));
715
+ }
716
+
717
+ function parseRow(line) {
718
+ let s = line.trim();
719
+ if (s.startsWith("|")) s = s.slice(1);
720
+ if (s.endsWith("|")) s = s.slice(0, -1);
721
+ return s.split(/(?<!\\)\|/).map((c) => c.replace(/\\\|/g, "|").trim());
722
+ }
723
+
724
+ const TRUTHY = ["x", "✓", "✔", "yes", "done", "true", "[x]"];
725
+ const CHIP_COLORS = [
726
+ ["#e7f0ff", "#2158d0"],
727
+ ["#fde8ec", "#c62a4b"],
728
+ ["#e6f7ee", "#1a8a55"],
729
+ ["#fdf0e0", "#b26a12"],
730
+ ["#efe9ff", "#5b3bd6"],
731
+ ["#e6f6f8", "#127b88"],
732
+ ];
733
+
734
+ function chipColor(name) {
735
+ let h = 0;
736
+ for (let i = 0; i < name.length; i++) h = (h * 31 + name.charCodeAt(i)) >>> 0;
737
+ return CHIP_COLORS[h % CHIP_COLORS.length];
738
+ }
739
+
740
+ const STATUS_MAP = {
741
+ "": ["Planned", "gray"],
742
+ planned: ["Planned", "gray"],
743
+ todo: ["Planned", "gray"],
744
+ "to do": ["Planned", "gray"],
745
+ backlog: ["Planned", "gray"],
746
+ "in progress": ["In progress", "amber"],
747
+ "in-progress": ["In progress", "amber"],
748
+ wip: ["In progress", "amber"],
749
+ running: ["In progress", "amber"],
750
+ active: ["In progress", "amber"],
751
+ done: ["Done", "green"],
752
+ complete: ["Done", "green"],
753
+ completed: ["Done", "green"],
754
+ blocked: ["Blocked", "red"],
755
+ failed: ["Failed", "red"],
756
+ abandoned: ["Abandoned", "gray"],
757
+ };
758
+
759
+ function statusBadge(val) {
760
+ const [label, tone] = STATUS_MAP[val.toLowerCase()] || [val || "—", "gray"];
761
+ return `<span class="badge ${tone}">${esc(label)}</span>`;
762
+ }
763
+
764
+ function renderTable(rows, container) {
765
+ if (rows.length < 2) return;
766
+ const header = rows[0];
767
+ const body = rows.slice(2);
768
+ const roles = header.map((h) => {
769
+ const t = h.toLowerCase();
770
+ if (t.includes("status") || t.includes("state")) return "status";
771
+ if (t.includes("progress") || t.includes("complete") || t.includes("done"))
772
+ return "check";
773
+ if (t === "who" || t.includes("assign") || t.includes("owner")) return "who";
774
+ return "text";
775
+ });
776
+ const table = document.createElement("table");
777
+ table.className = "board";
778
+ const thead = document.createElement("thead");
779
+ const htr = document.createElement("tr");
780
+ header.forEach((h, c) => {
781
+ const th = document.createElement("th");
782
+ th.textContent = h;
783
+ if (roles[c] === "check") th.className = "col-check";
784
+ htr.appendChild(th);
785
+ });
786
+ thead.appendChild(htr);
787
+ table.appendChild(thead);
788
+ const tbody = document.createElement("tbody");
789
+ body.forEach((cells) => {
790
+ const nonEmpty = cells.filter((x) => x !== "").length;
791
+ if (header.length > 1 && nonEmpty === 1 && cells[0]) {
792
+ const tr = document.createElement("tr");
793
+ tr.className = "section-row";
794
+ const td = document.createElement("td");
795
+ td.colSpan = header.length;
796
+ td.innerHTML = inline(cells[0]);
797
+ tr.appendChild(td);
798
+ tbody.appendChild(tr);
799
+ return;
800
+ }
801
+ const tr = document.createElement("tr");
802
+ header.forEach((_, c) => {
803
+ const td = document.createElement("td");
804
+ const val = (cells[c] || "").trim();
805
+ if (roles[c] === "status") {
806
+ td.className = "col-status";
807
+ td.innerHTML = statusBadge(val);
808
+ } else if (roles[c] === "check") {
809
+ td.className = "col-check";
810
+ const on = TRUTHY.indexOf(val.toLowerCase()) !== -1;
811
+ td.innerHTML = `<span class="box ${on ? "on" : ""}">${on ? "✓" : ""}</span>`;
812
+ } else if (roles[c] === "who") {
813
+ if (!val || /^to assign$/i.test(val)) {
814
+ td.innerHTML = `<span class="who-chip muted">${esc(val || "—")}</span>`;
815
+ } else {
816
+ const [bg, fg] = chipColor(val);
817
+ td.innerHTML = `<span class="who-chip" style="background:${bg};color:${fg}">${esc(val)}</span>`;
818
+ }
819
+ } else {
820
+ td.innerHTML = inline(val);
821
+ }
822
+ tr.appendChild(td);
823
+ });
824
+ const link = tr.querySelector('a[href^="#/"]');
825
+ if (link) {
826
+ tr.classList.add("linked-row");
827
+ tr.addEventListener("click", (e) => {
828
+ if (e.target.tagName !== "A") location.hash = link.getAttribute("href");
829
+ });
830
+ }
831
+ tbody.appendChild(tr);
832
+ });
833
+ table.appendChild(tbody);
834
+ const wrap = document.createElement("div");
835
+ wrap.className = "board-wrap";
836
+ wrap.appendChild(table);
837
+ container.appendChild(wrap);
838
+ }
839
+
840
+ const HL_RULES = {
841
+ python: [
842
+ ["comment", /#[^\n]*/],
843
+ ["string", /'''[\s\S]*?'''|"""[\s\S]*?"""|'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"/],
844
+ [
845
+ "keyword",
846
+ /\b(?:def|class|return|if|elif|else|for|while|import|from|as|with|try|except|finally|raise|in|not|and|or|is|None|True|False|lambda|yield|global|nonlocal|assert|pass|break|continue|async|await|print)\b/,
847
+ ],
848
+ ["number", /\b\d[\d_.eE+-]*\b/],
849
+ ],
850
+ bash: [
851
+ ["comment", /#[^\n]*/],
852
+ ["string", /'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"/],
853
+ ["keyword", /\b(?:if|then|else|fi|for|in|do|done|while|case|esac|function|export|source|echo|cd|return|local)\b/],
854
+ ["number", /(?<=\s)-{1,2}[a-zA-Z][\w-]*/],
855
+ ],
856
+ json: [
857
+ ["string", /"(?:\\.|[^"\\])*"/],
858
+ ["keyword", /\b(?:true|false|null)\b/],
859
+ ["number", /-?\b\d[\d.eE+-]*\b/],
860
+ ],
861
+ yaml: [
862
+ ["comment", /#[^\n]*/],
863
+ ["string", /'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"/],
864
+ ["keyword", /\b(?:true|false|null|yes|no)\b/],
865
+ ["number", /-?\b\d[\d.eE+-]*\b/],
866
+ ],
867
+ };
868
+ HL_RULES.javascript = HL_RULES.python;
869
+ HL_RULES.typescript = HL_RULES.python;
870
+ HL_RULES.sql = [
871
+ ["comment", /--[^\n]*/],
872
+ ["string", /'(?:\\.|[^'\\])*'/],
873
+ [
874
+ "keyword",
875
+ /\b(?:SELECT|FROM|WHERE|JOIN|LEFT|RIGHT|INNER|OUTER|ON|GROUP|BY|ORDER|LIMIT|INSERT|INTO|VALUES|UPDATE|SET|DELETE|CREATE|TABLE|AS|AND|OR|NOT|NULL|COUNT|DISTINCT|IN)\b/i,
876
+ ],
877
+ ["number", /\b\d[\d.]*\b/],
878
+ ];
879
+
880
+ function highlightCode(code, lang) {
881
+ const rules = HL_RULES[lang];
882
+ if (!rules) return esc(code);
883
+ const combined = new RegExp(rules.map((r) => "(" + r[1].source + ")").join("|"), "g");
884
+ let out = "";
885
+ let last = 0;
886
+ let m;
887
+ while ((m = combined.exec(code))) {
888
+ if (m[0] === "") {
889
+ combined.lastIndex++;
890
+ continue;
891
+ }
892
+ out += esc(code.slice(last, m.index));
893
+ let gi = 1;
894
+ while (gi < m.length && m[gi] === undefined) gi++;
895
+ out += `<span class="tok-${rules[gi - 1][0]}">${esc(m[0])}</span>`;
896
+ last = m.index + m[0].length;
897
+ }
898
+ out += esc(code.slice(last));
899
+ return out;
900
+ }
901
+
902
+ function copySnippetBtn(text) {
903
+ const btn = document.createElement("button");
904
+ btn.type = "button";
905
+ btn.className = "copy-snippet";
906
+ btn.title = "Copy";
907
+ btn.textContent = "⧉";
908
+ btn.addEventListener("click", (e) => {
909
+ e.preventDefault();
910
+ e.stopPropagation();
911
+ copyText(text, btn, "⧉");
912
+ });
913
+ return btn;
914
+ }
915
+
916
+ function renderCode(code, lang, title) {
917
+ const pre = document.createElement("pre");
918
+ pre.className = "hl";
919
+ const c = document.createElement("code");
920
+ c.innerHTML = highlightCode(code, lang);
921
+ pre.appendChild(c);
922
+ if (!title) {
923
+ const wrap = document.createElement("div");
924
+ wrap.className = "snippet";
925
+ wrap.appendChild(pre);
926
+ wrap.appendChild(copySnippetBtn(code));
927
+ return wrap;
928
+ }
929
+ const det = document.createElement("details");
930
+ det.className = "code-accordion";
931
+ det.dataset.resUrl = `trackio-script://${title}`;
932
+ const sum = document.createElement("summary");
933
+ sum.innerHTML =
934
+ `<span class="code-ico">&lt;/&gt;</span>` +
935
+ `<span class="code-name">${esc(title)}</span>`;
936
+ sum
937
+ .querySelector(".code-name")
938
+ .addEventListener("click", (e) => e.preventDefault());
939
+ det.appendChild(sum);
940
+ const wrap = document.createElement("div");
941
+ wrap.className = "snippet";
942
+ wrap.appendChild(pre);
943
+ wrap.appendChild(copySnippetBtn(code));
944
+ det.appendChild(wrap);
945
+ return det;
946
+ }
947
+
948
+ const IMG_PATH = /^[^\s]+\.(png|jpe?g|gif|svg|webp)$/i;
949
+
950
+ function renderList(items, container) {
951
+ let ul = null;
952
+ items.forEach((item) => {
953
+ if (URL_ONLY.test(item) || IMG_PATH.test(item)) {
954
+ const el = renderStandaloneUrl(item);
955
+ if (el) {
956
+ ul = null;
957
+ container.appendChild(el);
958
+ }
959
+ } else if (item.indexOf("📦 Artifact") !== -1) {
960
+ ul = null;
961
+ const div = document.createElement("div");
962
+ div.className = "artifact-chip";
963
+ div.innerHTML = inline(item.replace("📦", "🪣"));
964
+ container.appendChild(div);
965
+ } else if (item.indexOf("trackio-local-dashboard://") !== -1) {
966
+ ul = null;
967
+ const uri = item.match(/trackio-local-dashboard:\/\/\S+/)?.[0] || "";
968
+ const div = document.createElement("div");
969
+ div.className = "artifact-chip";
970
+ if (uri) div.dataset.resUrl = uri;
971
+ div.innerHTML =
972
+ "🎯 <strong>Local dashboard</strong> — publish the logbook to share it";
973
+ container.appendChild(div);
974
+ } else {
975
+ if (!ul) {
976
+ ul = document.createElement("ul");
977
+ container.appendChild(ul);
978
+ }
979
+ const li = document.createElement("li");
980
+ li.innerHTML = inline(item);
981
+ ul.appendChild(li);
982
+ }
983
+ });
984
+ }
985
+
986
+ /* -------------------- resources rail -------------------- */
987
+
988
+ function fmt(n) {
989
+ if (n == null) return null;
990
+ if (n >= 1e6) return (n / 1e6).toFixed(1) + "M";
991
+ if (n >= 1e3) return (n / 1e3).toFixed(1) + "k";
992
+ return String(n);
993
+ }
994
+
995
+ const RESOURCE_SECTIONS = [
996
+ ["dashboard", "Dashboards", "🎯"],
997
+ ["model", "Models", "🤗"],
998
+ ["dataset", "Datasets", "📊"],
999
+ ["space", "Spaces", "🚀"],
1000
+ ["artifact", "Artifacts", "🪣"],
1001
+ ["paper", "Papers", "📄"],
1002
+ ["repo", "Code", "🐙"],
1003
+ ["job", "Jobs", "⚙️"],
1004
+ ["bucket", "Buckets", "🪣"],
1005
+ ];
1006
+
1007
+ const RESOURCE_ICONS = Object.fromEntries(
1008
+ RESOURCE_SECTIONS.map(([kind, , icon]) => [kind, icon])
1009
+ );
1010
+
1011
+ const ARTIFACT_ICON_IMG = `<img class="art-ico" src="./bucket-icon.svg" alt="" />`;
1012
+ const DASHBOARD_ICON_IMG = `<img class="art-ico" src="./trackio-logo-light.png" alt="" />`;
1013
+
1014
+ const RESOURCE_DESC = {
1015
+ dashboard: "Dashboard",
1016
+ model: "Model",
1017
+ dataset: "Dataset",
1018
+ space: "Space",
1019
+ artifact: "Artifact — in Bucket",
1020
+ paper: "Paper",
1021
+ repo: "Repository",
1022
+ job: "Job — status & logs",
1023
+ bucket: "Bucket — artifacts & data",
1024
+ };
1025
+
1026
+ const HF_NON_MODEL_PREFIX =
1027
+ /^(datasets|spaces|jobs|buckets|papers|blog|docs|api|posts|collections|organizations|settings|new|join|login|pricing|tasks|learn|chat|models)(\/|$)/;
1028
+
1029
+ function hfId(url, marker) {
1030
+ return url.split(marker)[1].split(/[?#]/)[0].replace(/\/$/, "");
1031
+ }
1032
+
1033
+ function classifyResource(url) {
1034
+ if (IMG_URL.test(url)) {
1035
+ return null;
1036
+ }
1037
+ let m;
1038
+ if (url.startsWith("trackio-local-dashboard://")) {
1039
+ return {
1040
+ kind: "dashboard",
1041
+ id: url.slice("trackio-local-dashboard://".length),
1042
+ url,
1043
+ local: true,
1044
+ };
1045
+ }
1046
+ if (url.startsWith("trackio-artifact://")) {
1047
+ return {
1048
+ kind: "artifact",
1049
+ id: url.slice("trackio-artifact://".length),
1050
+ url,
1051
+ local: true,
1052
+ };
1053
+ }
1054
+ if (url.startsWith("trackio-local-path://")) {
1055
+ return {
1056
+ kind: "artifact",
1057
+ id: url.slice("trackio-local-path://".length),
1058
+ url,
1059
+ local: true,
1060
+ };
1061
+ }
1062
+ if ((m = url.match(/huggingface\.co\/buckets\/[^#\s]+#(.+)/))) {
1063
+ return { kind: "artifact", id: decodeURIComponent(m[1]), url };
1064
+ }
1065
+ if (/huggingface\.co\/datasets\/[^/]+\/[^/]+/.test(url)) {
1066
+ return { kind: "dataset", id: hfId(url, "/datasets/"), url };
1067
+ }
1068
+ if (/huggingface\.co\/spaces\/[^/]+\/[^/]+/.test(url)) {
1069
+ return { kind: "space", id: hfId(url, "/spaces/"), url };
1070
+ }
1071
+ if (/huggingface\.co\/jobs\//.test(url)) {
1072
+ const parts = hfId(url, "/jobs/").split("/");
1073
+ const jid = parts[1] || "";
1074
+ return {
1075
+ kind: "job",
1076
+ id: parts[0] + (jid ? ` · ${jid.slice(0, 12)}${jid.length > 12 ? "…" : ""}` : ""),
1077
+ url,
1078
+ };
1079
+ }
1080
+ if (/huggingface\.co\/buckets\//.test(url)) {
1081
+ return { kind: "bucket", id: hfId(url, "/buckets/"), url };
1082
+ }
1083
+ if (/huggingface\.co\/papers\//.test(url)) {
1084
+ return { kind: "paper", id: `Paper ${hfId(url, "/papers/")}`, url };
1085
+ }
1086
+ if ((m = url.match(/arxiv\.org\/(?:abs|pdf)\/([^?#\s]+)/))) {
1087
+ return { kind: "paper", id: `arXiv:${m[1].replace(/\.pdf$/, "")}`, url };
1088
+ }
1089
+ if ((m = url.match(/github\.com\/([^/?#]+\/[^/?#]+)/))) {
1090
+ return { kind: "repo", id: m[1], url };
1091
+ }
1092
+ if ((m = url.match(/huggingface\.co\/([^?#]+)/))) {
1093
+ const rest = m[1].replace(/\/$/, "");
1094
+ if (/^[^/]+\/[^/]+$/.test(rest) && !HF_NON_MODEL_PREFIX.test(rest)) {
1095
+ return { kind: "model", id: rest, url };
1096
+ }
1097
+ }
1098
+ return null;
1099
+ }
1100
+
1101
+ async function fillRailMeta(item, el) {
1102
+ if (item.local) return;
1103
+ const meta = el.querySelector(".rail-meta");
1104
+ const set = (parts) => {
1105
+ const text = parts.filter(Boolean).join(" · ");
1106
+ if (text) meta.textContent = text;
1107
+ };
1108
+ if (item.kind === "model") {
1109
+ const d = await getJSON(`https://huggingface.co/api/models/${item.id}`);
1110
+ if (d) set([d.pipeline_tag, `↓ ${fmt(d.downloads)}`, `♥ ${fmt(d.likes)}`]);
1111
+ } else if (item.kind === "dataset") {
1112
+ const d = await getJSON(`https://huggingface.co/api/datasets/${item.id}`);
1113
+ if (d) set([`↓ ${fmt(d.downloads)}`, `♥ ${fmt(d.likes)}`]);
1114
+ } else if (item.kind === "space" || item.kind === "dashboard") {
1115
+ const d = await getJSON(`https://huggingface.co/api/spaces/${item.id}`);
1116
+ if (d) set([d.sdk, `♥ ${fmt(d.likes)}`]);
1117
+ } else if (item.kind === "repo") {
1118
+ const d = await getJSON(`https://api.github.com/repos/${item.id}`);
1119
+ if (d) set([`★ ${fmt(d.stargazers_count)}`, d.language]);
1120
+ } else if (item.kind === "paper") {
1121
+ const m = item.id.match(/^(?:arXiv:|Paper )(.+)$/);
1122
+ if (!m) return;
1123
+ const arxivId = m[1].replace(/v\d+$/, "");
1124
+ const d = await getJSON(`https://huggingface.co/api/papers/${arxivId}`);
1125
+ if (d && d.id) {
1126
+ if (el.href) el.href = `https://huggingface.co/papers/${d.id}`;
1127
+ const title =
1128
+ d.title && d.title.length > 70 ? `${d.title.slice(0, 69)}…` : d.title;
1129
+ set([title, d.upvotes ? `▲ ${fmt(d.upvotes)}` : null]);
1130
+ }
1131
+ }
1132
+ }
1133
+
1134
+ const BARE_ID_SKIP_DIRS = new Set([
1135
+ "scripts",
1136
+ "configs",
1137
+ "config",
1138
+ "results",
1139
+ "figures",
1140
+ "data",
1141
+ "datasets",
1142
+ "src",
1143
+ "tests",
1144
+ "test",
1145
+ "examples",
1146
+ "pages",
1147
+ "assets",
1148
+ "docs",
1149
+ "outputs",
1150
+ "output",
1151
+ "checkpoints",
1152
+ "models",
1153
+ "utils",
1154
+ "lib",
1155
+ "bin",
1156
+ "tmp",
1157
+ "node_modules",
1158
+ "dist",
1159
+ "build",
1160
+ ]);
1161
+ const FILE_EXT_RE =
1162
+ /\.(py|pyc|js|ts|jsx|tsx|json|jsonl|yaml|yml|csv|tsv|md|txt|sh|bash|html|css|png|jpe?g|svg|gif|webp|ipynb|toml|cfg|ini|lock|pdf|whl|gz|zip|tar|pt|pth|bin|safetensors|db|sqlite)$/i;
1163
+
1164
+ async function detectBareModelIds(text, groups) {
1165
+ const stripped = text.replace(DETECTED_URL, " ");
1166
+ DETECTED_URL.lastIndex = 0;
1167
+ const seen = new Set();
1168
+ const candidates = [];
1169
+ const re = /(^|[\s"'`(=[])([A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*)/g;
1170
+ let m;
1171
+ while ((m = re.exec(stripped)) && candidates.length < 15) {
1172
+ const id = m[2].replace(/[.:,]+$/, "");
1173
+ if (seen.has(id)) continue;
1174
+ seen.add(id);
1175
+ if (FILE_EXT_RE.test(id)) continue;
1176
+ if (BARE_ID_SKIP_DIRS.has(id.split("/")[0].toLowerCase())) continue;
1177
+ candidates.push(id);
1178
+ }
1179
+ const results = await Promise.all(
1180
+ candidates.map((id) => getJSON(`https://huggingface.co/api/models/${id}`))
1181
+ );
1182
+ let added = false;
1183
+ const confirmed = [];
1184
+ results.forEach((d, i) => {
1185
+ if (!d || !d.id) return;
1186
+ const id = candidates[i];
1187
+ confirmed.push(id);
1188
+ const url = `https://huggingface.co/${id}`;
1189
+ if (!groups.has("model")) groups.set("model", new Map());
1190
+ if (!groups.get("model").has(url)) {
1191
+ groups.get("model").set(url, { kind: "model", id, url });
1192
+ added = true;
1193
+ }
1194
+ });
1195
+ return { added, confirmed };
1196
+ }
1197
+
1198
+ function chipifyBareIds(ids, container) {
1199
+ if (!ids.length) return;
1200
+ const escaped = ids.map((id) => id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
1201
+ const pattern = new RegExp("(" + escaped.join("|") + ")");
1202
+ const splitter = new RegExp(pattern.source, "g");
1203
+ container
1204
+ .querySelectorAll(".cell.markdown .cell-body")
1205
+ .forEach((body) => {
1206
+ const walker = document.createTreeWalker(body, NodeFilter.SHOW_TEXT, {
1207
+ acceptNode(node) {
1208
+ if (!pattern.test(node.nodeValue)) return NodeFilter.FILTER_REJECT;
1209
+ for (
1210
+ let el = node.parentElement;
1211
+ el && el !== body;
1212
+ el = el.parentElement
1213
+ ) {
1214
+ if (["A", "CODE", "PRE", "BUTTON"].indexOf(el.tagName) !== -1) {
1215
+ return NodeFilter.FILTER_REJECT;
1216
+ }
1217
+ }
1218
+ return NodeFilter.FILTER_ACCEPT;
1219
+ },
1220
+ });
1221
+ const nodes = [];
1222
+ while (walker.nextNode()) nodes.push(walker.currentNode);
1223
+ nodes.forEach((node) => {
1224
+ const frag = document.createDocumentFragment();
1225
+ node.nodeValue.split(splitter).forEach((part) => {
1226
+ if (ids.indexOf(part) !== -1) {
1227
+ const holder = document.createElement("span");
1228
+ holder.innerHTML = resChipHtml({
1229
+ kind: "model",
1230
+ id: part,
1231
+ url: `https://huggingface.co/${part}`,
1232
+ });
1233
+ frag.appendChild(holder.firstChild);
1234
+ } else if (part) {
1235
+ frag.appendChild(document.createTextNode(part));
1236
+ }
1237
+ });
1238
+ node.parentNode.replaceChild(frag, node);
1239
+ });
1240
+ });
1241
+ }
1242
+
1243
+ let RAIL_TOKEN = 0;
1244
+ const RAIL_EXCLUDE_KINDS = new Set(["paper", "repo", "artifact", "dashboard"]);
1245
+
1246
+ function railDashboardItem(it) {
1247
+ return {
1248
+ kind: "dashboard",
1249
+ id: it.id,
1250
+ url: it.local ? it.resUrl : it.url || it.resUrl,
1251
+ local: it.local,
1252
+ railLabel: "Dashboard",
1253
+ };
1254
+ }
1255
+
1256
+ function promoteTrackioSpacesInRail(groups, dashResUrls, body, rail, token) {
1257
+ const spaceGroup = groups.get("space");
1258
+ if (!spaceGroup || !spaceGroup.size) return;
1259
+ spaceGroup.forEach((item, url) => {
1260
+ getJSON(`https://huggingface.co/api/spaces/${item.id}`)
1261
+ .then((d) => {
1262
+ if (rail.dataset.renderToken !== token) return;
1263
+ const tags = (d && d.tags) || [];
1264
+ if (!tags.some((t) => String(t).toLowerCase() === "trackio")) return;
1265
+ if (dashResUrls.has(url)) return;
1266
+ spaceGroup.delete(url);
1267
+ if (!spaceGroup.size) groups.delete("space");
1268
+ if (!groups.has("dashboard")) groups.set("dashboard", new Map());
1269
+ groups.get("dashboard").set(url, {
1270
+ kind: "dashboard",
1271
+ id: item.id,
1272
+ url: item.url,
1273
+ local: false,
1274
+ railLabel: "Dashboard",
1275
+ });
1276
+ dashResUrls.add(url);
1277
+ paintRail(groups, body, rail);
1278
+ })
1279
+ .catch(() => {});
1280
+ });
1281
+ }
1282
+
1283
+ function renderRail(md, body, rail) {
1284
+ const token = String(++RAIL_TOKEN);
1285
+ rail.dataset.renderToken = token;
1286
+ const scanText = md.replace(
1287
+ /(`{3,4}|~{3,4})(html|raw)[^\n]*\n[\s\S]*?\n\1/g,
1288
+ " "
1289
+ );
1290
+ const groups = new Map();
1291
+ const dashMap = new Map();
1292
+ const dashResUrls = new Set();
1293
+ cellDashboardItems(md).forEach((it) => {
1294
+ if (dashMap.has(it.resUrl)) return;
1295
+ dashMap.set(it.resUrl, railDashboardItem(it));
1296
+ dashResUrls.add(it.resUrl);
1297
+ });
1298
+ if (dashMap.size) groups.set("dashboard", dashMap);
1299
+ extractUrls(scanText).forEach((url) => {
1300
+ const item = classifyResource(url);
1301
+ if (!item) return;
1302
+ if (RAIL_EXCLUDE_KINDS.has(item.kind)) return;
1303
+ if (dashResUrls.has(url)) return;
1304
+ if (!groups.has(item.kind)) groups.set(item.kind, new Map());
1305
+ groups.get(item.kind).set(item.url, item);
1306
+ });
1307
+ const artMap = new Map();
1308
+ cellArtifactItems(md).forEach((it) => {
1309
+ if (artMap.has(it.resUrl)) return;
1310
+ const label = it.type
1311
+ ? it.type.charAt(0).toUpperCase() + it.type.slice(1)
1312
+ : "Artifact";
1313
+ artMap.set(it.resUrl, {
1314
+ kind: "artifact",
1315
+ id: it.name,
1316
+ url: it.local ? it.resUrl : it.url || it.resUrl,
1317
+ local: it.local,
1318
+ railLabel: label,
1319
+ size: it.size,
1320
+ });
1321
+ });
1322
+ if (artMap.size) groups.set("artifact", artMap);
1323
+ paintRail(groups, body, rail);
1324
+ promoteTrackioSpacesInRail(groups, dashResUrls, body, rail, token);
1325
+ detectBareModelIds(scanText, groups)
1326
+ .then((result) => {
1327
+ if (rail.dataset.renderToken !== token) return;
1328
+ chipifyBareIds(result.confirmed, body);
1329
+ if (result.added) paintRail(groups, body, rail);
1330
+ })
1331
+ .catch(() => {});
1332
+ }
1333
+
1334
+ function paintRail(groups, body, rail) {
1335
+ rail.innerHTML = "";
1336
+ RESOURCE_SECTIONS.forEach(([kind, label, icon]) => {
1337
+ const group = groups.get(kind);
1338
+ if (!group || !group.size) return;
1339
+ group.forEach((item) => {
1340
+ const el = document.createElement(item.local ? "div" : "a");
1341
+ el.className = item.local ? "rail-item rail-local" : "rail-item";
1342
+ if (!item.local) {
1343
+ el.href = item.url;
1344
+ el.target = "_blank";
1345
+ el.rel = "noopener";
1346
+ }
1347
+ el.dataset.resUrl = item.url;
1348
+ let desc;
1349
+ if (kind === "artifact") {
1350
+ const state = item.local ? "publish to share" : "Open ↗";
1351
+ desc = item.size ? `${item.size} · ${state}` : state;
1352
+ } else if (kind === "dashboard") {
1353
+ desc = item.local ? "publish to share" : "Open ↗";
1354
+ } else {
1355
+ desc = item.local ? "publish to share" : RESOURCE_DESC[kind];
1356
+ }
1357
+ const kindLabel = item.railLabel || label.replace(/s$/, "");
1358
+ const iconHtml =
1359
+ kind === "artifact"
1360
+ ? ARTIFACT_ICON_IMG
1361
+ : kind === "dashboard"
1362
+ ? DASHBOARD_ICON_IMG
1363
+ : `<span>${icon}</span>`;
1364
+ el.innerHTML =
1365
+ `<div class="rail-kind">${iconHtml}${esc(kindLabel)}</div>` +
1366
+ `<div class="rail-title">${esc(item.id)}</div>` +
1367
+ `<div class="rail-meta">${esc(desc)}</div>`;
1368
+ rail.appendChild(el);
1369
+ fillRailMeta(item, el)
1370
+ .catch(() => {})
1371
+ .finally(() => scheduleRailPosition(body, rail));
1372
+ });
1373
+ });
1374
+ rail.hidden = !rail.childElementCount;
1375
+ scheduleRailPosition(body, rail);
1376
+ }
1377
+
1378
+ function resourceAnchor(body, url) {
1379
+ return body.querySelector(`[data-res-url="${CSS.escape(url)}"]`);
1380
+ }
1381
+
1382
+ function positionRail(body, rail) {
1383
+ if (rail.hidden || !rail.isConnected) return;
1384
+ const bodyRect = body.getBoundingClientRect();
1385
+ const items = Array.from(rail.querySelectorAll(".rail-item")).map((el, index) => {
1386
+ const anchor = resourceAnchor(body, el.dataset.resUrl);
1387
+ return {
1388
+ el,
1389
+ index,
1390
+ desired: anchor
1391
+ ? Math.max(0, anchor.getBoundingClientRect().top - bodyRect.top)
1392
+ : 0,
1393
+ };
1394
+ });
1395
+ items.sort((a, b) => a.desired - b.desired || a.index - b.index);
1396
+ let cursor = 0;
1397
+ items.forEach(({ el, desired }) => {
1398
+ const top = Math.max(desired, cursor);
1399
+ el.style.top = `${top}px`;
1400
+ cursor = top + el.offsetHeight + 10;
1401
+ });
1402
+ rail.style.minHeight = `${Math.max(body.offsetHeight, cursor)}px`;
1403
+ }
1404
+
1405
+ function scheduleRailPosition(body, rail) {
1406
+ cancelAnimationFrame(Number(rail.dataset.positionFrame || 0));
1407
+ rail.dataset.positionFrame = String(
1408
+ requestAnimationFrame(() => positionRail(body, rail))
1409
+ );
1410
+ }
1411
+
1412
+ function dashboardSubdomainFromUrl(url) {
1413
+ return spaceIdFromUrl(url).toLowerCase().replace(/[^a-z0-9-]/g, "-");
1414
+ }
1415
+
1416
+ function dashboardOpenLink(head, url) {
1417
+ if (!head || !url) return;
1418
+ const meta = head.querySelector(".cell-meta");
1419
+ if (!meta) return;
1420
+ let link = meta.querySelector(".cell-open");
1421
+ if (!link) {
1422
+ link = document.createElement("a");
1423
+ link.className = "cell-open";
1424
+ link.target = "_blank";
1425
+ link.rel = "noopener";
1426
+ meta.insertBefore(link, meta.firstChild);
1427
+ }
1428
+ link.href = url;
1429
+ link.textContent = "Open ↗";
1430
+ }
1431
+
1432
+ function dashboardFrame(src) {
1433
+ const iframe = document.createElement("iframe");
1434
+ iframe.className = "dashboard-frame";
1435
+ iframe.src = src;
1436
+ iframe.loading = "lazy";
1437
+ iframe.allow = "clipboard-read; clipboard-write; fullscreen";
1438
+ return iframe;
1439
+ }
1440
+
1441
+ function renderDashboardCell(meta, body, container, head) {
1442
+ const project = meta.dashboard_project || "";
1443
+ const holder = document.createElement("div");
1444
+ holder.className = "dashboard-shell";
1445
+ container.appendChild(holder);
1446
+ const space = body.match(/https:\/\/huggingface\.co\/spaces\/[^\s<>)"'`]+/);
1447
+ if (space) {
1448
+ const url = space[0];
1449
+ dashboardOpenLink(head, url);
1450
+ holder.appendChild(
1451
+ dashboardFrame(
1452
+ `https://${dashboardSubdomainFromUrl(url)}.hf.space/?sidebar=hidden&hide_empty_tabs=true`
1453
+ )
1454
+ );
1455
+ return;
1456
+ }
1457
+ if (!isLocalPreview()) {
1458
+ holder.className = "artifact-chip";
1459
+ holder.dataset.resUrl = `trackio-local-dashboard://${project}`;
1460
+ holder.innerHTML =
1461
+ "🎯 <strong>Local Trackio dashboard</strong> — publish the logbook to share it";
1462
+ return;
1463
+ }
1464
+ const open = "/dashboard/?project=" + encodeURIComponent(project);
1465
+ dashboardOpenLink(head, open);
1466
+ holder.appendChild(
1467
+ dashboardFrame(open + "&sidebar=hidden&hide_empty_tabs=true"),
1468
+ );
1469
+ }
1470
+
1471
+ const CACHE_PREFIX = "trackio-logbook:";
1472
+ const CACHE_TTL_MS = 24 * 60 * 60 * 1000;
1473
+ const CACHE_MISS_TTL_MS = 60 * 60 * 1000;
1474
+
1475
+ function cacheGet(url) {
1476
+ try {
1477
+ const raw = localStorage.getItem(CACHE_PREFIX + url);
1478
+ if (!raw) return undefined;
1479
+ const entry = JSON.parse(raw);
1480
+ const ttl = entry.d === null ? CACHE_MISS_TTL_MS : CACHE_TTL_MS;
1481
+ if (Date.now() - entry.t > ttl) {
1482
+ localStorage.removeItem(CACHE_PREFIX + url);
1483
+ return undefined;
1484
+ }
1485
+ return entry.d;
1486
+ } catch (e) {
1487
+ return undefined;
1488
+ }
1489
+ }
1490
+
1491
+ function cacheSet(url, data) {
1492
+ try {
1493
+ localStorage.setItem(
1494
+ CACHE_PREFIX + url,
1495
+ JSON.stringify({ t: Date.now(), d: data })
1496
+ );
1497
+ } catch (e) {}
1498
+ }
1499
+
1500
+ async function getJSON(url) {
1501
+ if (UNFURL_CACHE[url] !== undefined) return UNFURL_CACHE[url];
1502
+ const cached = cacheGet(url);
1503
+ if (cached !== undefined) {
1504
+ UNFURL_CACHE[url] = cached;
1505
+ return cached;
1506
+ }
1507
+ try {
1508
+ const r = await fetch(url);
1509
+ if (!r.ok) throw new Error(r.status);
1510
+ const j = await r.json();
1511
+ UNFURL_CACHE[url] = j;
1512
+ cacheSet(url, j);
1513
+ return j;
1514
+ } catch (e) {
1515
+ UNFURL_CACHE[url] = null;
1516
+ cacheSet(url, null);
1517
+ return null;
1518
+ }
1519
+ }
1520
+
1521
+ /* -------------------- routing / render -------------------- */
1522
+
1523
+ function buildTree() {
1524
+ const tree = document.getElementById("tree");
1525
+ tree.innerHTML = "";
1526
+ const nodes = [];
1527
+ (MANIFEST.root.children || []).forEach((c) => flattenTree(c, 0, nodes));
1528
+ nodes.forEach(({ node, depth }) => {
1529
+ const a = document.createElement("a");
1530
+ a.href = "#/" + node.slug;
1531
+ a.className = "depth-" + depth;
1532
+ a.dataset.slug = node.slug;
1533
+ const mark = document.createElement("span");
1534
+ mark.className = "tree-mark";
1535
+ mark.textContent = "§";
1536
+ a.appendChild(mark);
1537
+ a.appendChild(document.createTextNode(" " + node.title));
1538
+ tree.appendChild(a);
1539
+ });
1540
+ }
1541
+
1542
+ function highlight(slug) {
1543
+ document
1544
+ .querySelectorAll("#tree a")
1545
+ .forEach((a) => a.classList.toggle("active", a.dataset.slug === slug));
1546
+ document
1547
+ .getElementById("book-head")
1548
+ .classList.toggle("active", slug === MANIFEST.root.slug);
1549
+ }
1550
+
1551
+ function clearPageCache() {
1552
+ Object.keys(PAGE_CACHE).forEach((key) => {
1553
+ delete PAGE_CACHE[key];
1554
+ });
1555
+ }
1556
+
1557
+ function isLocalPreview() {
1558
+ return ["localhost", "127.0.0.1", "::1"].includes(location.hostname);
1559
+ }
1560
+
1561
+ async function fetchManifest() {
1562
+ const suffix = isLocalPreview() ? `?t=${Date.now()}` : "";
1563
+ return await (await fetch("./logbook.json" + suffix, { cache: "no-store" })).json();
1564
+ }
1565
+
1566
+ async function fetchPage(node) {
1567
+ if (PAGE_CACHE[node.file]) return PAGE_CACHE[node.file];
1568
+ try {
1569
+ const suffix = isLocalPreview()
1570
+ ? `?rev=${encodeURIComponent(MANIFEST.revision || "")}`
1571
+ : "";
1572
+ const r = await fetch("./" + node.file + suffix, { cache: "no-store" });
1573
+ PAGE_CACHE[node.file] = await r.text();
1574
+ } catch (e) {
1575
+ PAGE_CACHE[node.file] = "# " + node.title + "\n\n_Could not load section._";
1576
+ }
1577
+ return PAGE_CACHE[node.file];
1578
+ }
1579
+
1580
+ function allNodes() {
1581
+ const nodes = [];
1582
+ flattenTree(MANIFEST.root, 0, nodes);
1583
+ return nodes.map(({ node }) => node);
1584
+ }
1585
+
1586
+ function collectPinnedCells(markdown, nodes) {
1587
+ const cells = [];
1588
+ markdown.forEach((text, index) => {
1589
+ const cellRe = /(^|\n)---\n<!-- trackio-cell\n([\s\S]*?)\n-->\n([\s\S]*?)(?=\n---\n<!-- trackio-cell\n|\s*$)/g;
1590
+ let match;
1591
+ let cellIndex = 0;
1592
+ while ((match = cellRe.exec(text))) {
1593
+ const meta = parseCellMeta(match[2]);
1594
+ if (isPinned(meta)) {
1595
+ cells.push({
1596
+ meta,
1597
+ body: match[3],
1598
+ node: nodes[index],
1599
+ index: cells.length,
1600
+ order: meta.pinned_at || meta.created_at || "",
1601
+ cellIndex,
1602
+ });
1603
+ }
1604
+ cellIndex++;
1605
+ }
1606
+ });
1607
+ return cells.sort(
1608
+ (a, b) =>
1609
+ a.order.localeCompare(b.order) ||
1610
+ a.index - b.index ||
1611
+ a.cellIndex - b.cellIndex
1612
+ );
1613
+ }
1614
+
1615
+ function renderPinnedNotes(cells, container) {
1616
+ if (!cells.length) return;
1617
+ const deck = document.createElement("section");
1618
+ deck.className = "pinned-notes";
1619
+ const list = document.createElement("div");
1620
+ list.className = "pinned-notes-list";
1621
+ cells.forEach(({ meta, body }) => {
1622
+ const cell = renderCell(meta, body, list);
1623
+ cell.classList.add("pinned-copy");
1624
+ });
1625
+ deck.appendChild(list);
1626
+ const anchor =
1627
+ container.querySelector(".logbook-stats") ||
1628
+ container.querySelector(".agent-hint");
1629
+ container.insertBefore(deck, anchor ? anchor.nextSibling : container.firstChild);
1630
+ container.closest(".book-intro").classList.add("has-pinned-notes");
1631
+ }
1632
+
1633
+ function removeIndexProse(body) {
1634
+ const h1 = Array.from(body.children).find((el) => el.tagName === "H1");
1635
+ if (!h1) return;
1636
+ let current = h1.nextElementSibling;
1637
+ while (current && current.tagName !== "H2") {
1638
+ const next = current.nextElementSibling;
1639
+ current.remove();
1640
+ current = next;
1641
+ }
1642
+ }
1643
+
1644
+ function removePageDirectory(body) {
1645
+ const heading = Array.from(body.children).find(
1646
+ (el) => el.tagName === "H2" && el.textContent.trim().toLowerCase() === "pages"
1647
+ );
1648
+ if (!heading) return;
1649
+ let current = heading;
1650
+ while (current) {
1651
+ const next = current.nextElementSibling;
1652
+ current.remove();
1653
+ if (next && ["H1", "H2"].includes(next.tagName)) break;
1654
+ current = next;
1655
+ }
1656
+ }
1657
+
1658
+ const RAIL_OBSERVERS = [];
1659
+
1660
+ async function renderLogbook(opts = {}) {
1661
+ const scrollY = window.scrollY;
1662
+ const page = document.getElementById("page");
1663
+ RAIL_OBSERVERS.splice(0).forEach((observer) => observer.disconnect());
1664
+ page.innerHTML = "";
1665
+ const nodes = allNodes();
1666
+ const markdown = await Promise.all(nodes.map(fetchPage));
1667
+ const pinnedCells = collectPinnedCells(markdown, nodes);
1668
+ let bookIntroBody = null;
1669
+ nodes.forEach((node, index) => {
1670
+ const section = document.createElement("section");
1671
+ section.className = "page-section";
1672
+ section.id = "/" + node.slug;
1673
+ section.dataset.slug = node.slug;
1674
+
1675
+ const layout = document.createElement("div");
1676
+ layout.className = "page-layout";
1677
+ const body = document.createElement("div");
1678
+ body.className = "page-body";
1679
+ const rail = document.createElement("aside");
1680
+ rail.className = "context-rail";
1681
+ rail.setAttribute("aria-label", `Resources for ${node.title}`);
1682
+
1683
+ renderMarkdown(markdown[index], body);
1684
+ if (node.slug === MANIFEST.root.slug) {
1685
+ section.classList.add("book-intro");
1686
+ removeIndexProse(body);
1687
+ removePageDirectory(body);
1688
+ const hint = buildAgentHint();
1689
+ const h1 = body.querySelector("h1");
1690
+ if (h1 && h1.parentNode === body) {
1691
+ body.insertBefore(hint, h1.nextSibling);
1692
+ } else {
1693
+ body.prepend(hint);
1694
+ }
1695
+ hint.after(buildLogbookStats(markdown));
1696
+ bookIntroBody = body;
1697
+ }
1698
+ layout.appendChild(body);
1699
+ layout.appendChild(rail);
1700
+ section.appendChild(layout);
1701
+ page.appendChild(section);
1702
+ renderRail(markdown[index], body, rail);
1703
+ if (window.ResizeObserver) {
1704
+ const observer = new ResizeObserver(() => scheduleRailPosition(body, rail));
1705
+ observer.observe(body);
1706
+ observer.observe(rail);
1707
+ RAIL_OBSERVERS.push(observer);
1708
+ }
1709
+ });
1710
+ if (bookIntroBody) renderPinnedNotes(pinnedCells, bookIntroBody);
1711
+ if (bookIntroBody) {
1712
+ const section = bookIntroBody.closest(".book-intro");
1713
+ const hasExtra = Array.from(bookIntroBody.children).some(
1714
+ (el) =>
1715
+ el.tagName !== "H1" &&
1716
+ !el.classList.contains("agent-hint") &&
1717
+ !el.classList.contains("logbook-stats") &&
1718
+ !el.classList.contains("pinned-notes")
1719
+ );
1720
+ if (section && !section.classList.contains("has-pinned-notes") && !hasExtra) {
1721
+ section.classList.add("book-intro-tight");
1722
+ }
1723
+ }
1724
+ requestAnimationFrame(() => {
1725
+ if (opts.preserveScroll) {
1726
+ window.scrollTo(0, scrollY);
1727
+ } else {
1728
+ scrollToHash({ behavior: "auto" });
1729
+ }
1730
+ updateActiveSection();
1731
+ });
1732
+ }
1733
+
1734
+ function setupResourceHover() {
1735
+ document.addEventListener("mouseover", (e) => {
1736
+ const el = e.target.closest && e.target.closest("[data-res-url]");
1737
+ if (!el || el.classList.contains("rail-item")) return;
1738
+ const url = el.getAttribute("data-res-url");
1739
+ const section = el.closest(".page-section");
1740
+ const scope = section || document;
1741
+ scope.querySelectorAll(".context-rail [data-res-url]").forEach((n) => {
1742
+ n.classList.toggle("res-hl", n.getAttribute("data-res-url") === url);
1743
+ });
1744
+ });
1745
+ document.addEventListener("mouseout", (e) => {
1746
+ const el = e.target.closest && e.target.closest("[data-res-url]");
1747
+ if (!el || el.classList.contains("rail-item")) return;
1748
+ document.querySelectorAll(".context-rail .res-hl").forEach((n) => {
1749
+ n.classList.remove("res-hl");
1750
+ });
1751
+ });
1752
+ }
1753
+
1754
+ let STATS_TOKEN = 0;
1755
+ let STATS_LISTENERS = false;
1756
+
1757
+ function fmtBytes(n) {
1758
+ if (n == null || isNaN(n)) return null;
1759
+ if (n < 1000) return `${n} B`;
1760
+ const units = ["kB", "MB", "GB", "TB"];
1761
+ let v = n;
1762
+ let i = -1;
1763
+ do {
1764
+ v /= 1000;
1765
+ i++;
1766
+ } while (v >= 1000 && i < units.length - 1);
1767
+ return `${v.toFixed(v < 10 ? 1 : 0)} ${units[i]}`;
1768
+ }
1769
+
1770
+ function spaceIdFromUrl(url) {
1771
+ return url.split("/spaces/")[1].split(/[?#]/)[0].replace(/\/$/, "");
1772
+ }
1773
+
1774
+ const LB_CELL_RE = /(^|\n)---\n<!-- trackio-cell\n([\s\S]*?)\n-->\n([\s\S]*?)(?=\n---\n<!-- trackio-cell\n|\s*$)/g;
1775
+
1776
+ function cellDashboardItems(md) {
1777
+ const re = new RegExp(LB_CELL_RE.source, "g");
1778
+ const items = [];
1779
+ let m;
1780
+ while ((m = re.exec(md))) {
1781
+ const meta = parseCellMeta(m[2]);
1782
+ if (meta.type !== "dashboard") continue;
1783
+ const body = m[3];
1784
+ const project = meta.dashboard_project || "";
1785
+ const sp = body.match(/https:\/\/huggingface\.co\/spaces\/[^\s<>)"'`]+/);
1786
+ const local = !sp;
1787
+ const url = sp ? sp[0] : "";
1788
+ const resUrl = local ? `trackio-local-dashboard://${project}` : url;
1789
+ items.push({
1790
+ id: local ? project : spaceIdFromUrl(url),
1791
+ local,
1792
+ url,
1793
+ resUrl,
1794
+ });
1795
+ }
1796
+ return items;
1797
+ }
1798
+
1799
+ function artifactInfoFromCell(meta, body) {
1800
+ const name = meta.artifact || meta.path || "";
1801
+ let size = null;
1802
+ const sm = body.match(/·\s*([\d.]+\s*[kMGT]?B)\b/);
1803
+ if (sm) size = sm[1].trim();
1804
+ if (!size && meta.size != null) size = fmtBytes(meta.size);
1805
+ const bucket = body.match(/https:\/\/huggingface\.co\/buckets\/[^\s<>)"'`]+/);
1806
+ const artUri = body.match(/trackio-artifact:\/\/\S+/);
1807
+ const pathUri = body.match(/trackio-local-path:\/\/\S+/);
1808
+ const url = bucket ? bucket[0] : "";
1809
+ const local = !bucket;
1810
+ const resUrl =
1811
+ url || (artUri ? artUri[0] : pathUri ? pathUri[0] : `trackio-artifact://${name}`);
1812
+ return {
1813
+ name,
1814
+ type: meta.artifact_type || "",
1815
+ size,
1816
+ local,
1817
+ isPathRef: !!meta.path,
1818
+ url,
1819
+ resUrl,
1820
+ };
1821
+ }
1822
+
1823
+ function cellArtifactItems(md) {
1824
+ const re = new RegExp(LB_CELL_RE.source, "g");
1825
+ const items = [];
1826
+ let m;
1827
+ while ((m = re.exec(md))) {
1828
+ const meta = parseCellMeta(m[2]);
1829
+ const body = m[3];
1830
+ const order = meta.created_at || "";
1831
+ if (meta.type === "artifact") {
1832
+ const info = artifactInfoFromCell(meta, body);
1833
+ if (info.name) items.push({ ...info, order });
1834
+ }
1835
+ }
1836
+ return items;
1837
+ }
1838
+
1839
+ function collectLogbookResources(markdownList) {
1840
+ const re = new RegExp(LB_CELL_RE.source, "g");
1841
+ const dashboards = new Map();
1842
+ markdownList.forEach((md) => {
1843
+ let m;
1844
+ while ((m = re.exec(md))) {
1845
+ const meta = parseCellMeta(m[2]);
1846
+ const body = m[3];
1847
+ if (meta.type !== "dashboard") continue;
1848
+ const project = meta.dashboard_project || "";
1849
+ const space = body.match(/https:\/\/huggingface\.co\/spaces\/[^\s<>)"'`]+/);
1850
+ const local = !space;
1851
+ const url = space ? space[0] : "";
1852
+ const key = local ? `local:${project}` : `space:${spaceIdFromUrl(url)}`;
1853
+ const resUrl = local ? `trackio-local-dashboard://${project}` : url;
1854
+ if (!dashboards.has(key))
1855
+ dashboards.set(key, { project, local, url, resUrl });
1856
+ }
1857
+ });
1858
+ const artifacts = new Map();
1859
+ markdownList.forEach((md) => {
1860
+ cellArtifactItems(md).forEach((it) => {
1861
+ const key = `${it.type}:${it.name}`;
1862
+ const prev = artifacts.get(key);
1863
+ if (!prev || it.order >= prev.order) artifacts.set(key, it);
1864
+ });
1865
+ });
1866
+ return {
1867
+ dashboards: Array.from(dashboards.values()).sort((a, b) =>
1868
+ a.project.localeCompare(b.project)
1869
+ ),
1870
+ artifacts: Array.from(artifacts.values()).sort((a, b) =>
1871
+ a.name.localeCompare(b.name)
1872
+ ),
1873
+ };
1874
+ }
1875
+
1876
+ function closeStatPopovers() {
1877
+ document
1878
+ .querySelectorAll(".stat-popover")
1879
+ .forEach((p) => (p.hidden = true));
1880
+ document
1881
+ .querySelectorAll(".stat-tile.open")
1882
+ .forEach((t) => t.classList.remove("open"));
1883
+ }
1884
+
1885
+ function ensureStatListeners() {
1886
+ if (STATS_LISTENERS) return;
1887
+ STATS_LISTENERS = true;
1888
+ document.addEventListener("click", closeStatPopovers);
1889
+ document.addEventListener("keydown", (e) => {
1890
+ if (e.key === "Escape") closeStatPopovers();
1891
+ });
1892
+ }
1893
+
1894
+ function stateHtml(remote, url) {
1895
+ return remote
1896
+ ? `<a class="stat-row-state open" href="${esc(url)}" target="_blank" rel="noopener" title="Open in a new tab">Open ↗</a>`
1897
+ : `<span class="stat-row-state">publish to share</span>`;
1898
+ }
1899
+
1900
+ function scrollToResource(resUrl) {
1901
+ closeStatPopovers();
1902
+ if (!resUrl) return;
1903
+ const el = document.querySelector(
1904
+ `#page .page-body [data-res-url="${CSS.escape(resUrl)}"]:not(.stat-row)`
1905
+ );
1906
+ if (!el) return;
1907
+ el.scrollIntoView({ behavior: "smooth", block: "center" });
1908
+ el.classList.add("res-flash");
1909
+ setTimeout(() => el.classList.remove("res-flash"), 1500);
1910
+ }
1911
+
1912
+ function dashRowHtml(d) {
1913
+ const inner =
1914
+ `<span class="stat-row-ico">${DASHBOARD_ICON_IMG}</span>` +
1915
+ `<div class="stat-row-main"><div class="stat-row-title">${esc(d.project)}</div>` +
1916
+ `<div class="stat-row-meta">${stateHtml(!d.local, d.url)}</div></div>`;
1917
+ return `<div class="stat-row" data-res-url="${esc(d.resUrl)}" title="Jump to it in the logbook">${inner}</div>`;
1918
+ }
1919
+
1920
+ function artRowHtml(a) {
1921
+ const remote = !a.local && !!a.url;
1922
+ const parts = [a.type, a.size].filter(Boolean).map(esc);
1923
+ const meta = parts.length
1924
+ ? `${parts.join(" · ")} · ${stateHtml(remote, a.url)}`
1925
+ : stateHtml(remote, a.url);
1926
+ const inner =
1927
+ `<span class="stat-row-ico">${ARTIFACT_ICON_IMG}</span>` +
1928
+ `<div class="stat-row-main"><div class="stat-row-title">${esc(a.name)}</div>` +
1929
+ `<div class="stat-row-meta">${meta}</div></div>`;
1930
+ return `<div class="stat-row" data-res-url="${esc(a.resUrl)}" title="Jump to it in the logbook">${inner}</div>`;
1931
+ }
1932
+
1933
+ function statTile(icon, alt, singular, plural, head, rowFn) {
1934
+ const tile = document.createElement("button");
1935
+ tile.type = "button";
1936
+ tile.className = "stat-tile";
1937
+ const render = (items) => {
1938
+ const count = items.length;
1939
+ const label = count === 1 ? singular : plural;
1940
+ const caret = count > 0 ? `<span class="stat-caret">▾</span>` : "";
1941
+ tile.innerHTML =
1942
+ `<img class="stat-icon" src="${icon}" alt="${esc(alt)}" />` +
1943
+ `<div class="stat-text"><div class="stat-num">${count}</div>` +
1944
+ `<div class="stat-label">${esc(label)}</div></div>` +
1945
+ caret;
1946
+ tile.disabled = count === 0;
1947
+ if (count > 0) {
1948
+ const pop = document.createElement("div");
1949
+ pop.className = "stat-popover";
1950
+ pop.hidden = true;
1951
+ pop.innerHTML =
1952
+ `<div class="stat-pop-head">${esc(head)}</div>` +
1953
+ items.map(rowFn).join("");
1954
+ pop.addEventListener("click", (e) => {
1955
+ if (e.target.closest("a.stat-row-state")) {
1956
+ e.stopPropagation();
1957
+ return;
1958
+ }
1959
+ e.stopPropagation();
1960
+ const row = e.target.closest(".stat-row");
1961
+ if (row) scrollToResource(row.dataset.resUrl);
1962
+ });
1963
+ tile.appendChild(pop);
1964
+ }
1965
+ };
1966
+ tile.addEventListener("click", (e) => {
1967
+ if (tile.disabled) return;
1968
+ e.stopPropagation();
1969
+ const pop = tile.querySelector(".stat-popover");
1970
+ if (!pop) return;
1971
+ const isOpen = !pop.hidden;
1972
+ closeStatPopovers();
1973
+ if (!isOpen) {
1974
+ pop.hidden = false;
1975
+ tile.classList.add("open");
1976
+ }
1977
+ });
1978
+ return { tile, render };
1979
+ }
1980
+
1981
+ function buildLogbookStats(markdownList) {
1982
+ const token = ++STATS_TOKEN;
1983
+ ensureStatListeners();
1984
+ const { dashboards, artifacts } = collectLogbookResources(markdownList);
1985
+
1986
+ const el = document.createElement("div");
1987
+ el.className = "logbook-stats";
1988
+ const dash = statTile(
1989
+ "./trackio-logo-light.png",
1990
+ "Trackio",
1991
+ "Trackio Dashboard",
1992
+ "Trackio Dashboards",
1993
+ "Dashboards created in this logbook",
1994
+ dashRowHtml
1995
+ );
1996
+ const art = statTile(
1997
+ "./bucket-icon.svg",
1998
+ "Bucket",
1999
+ "Artifact",
2000
+ "Artifacts",
2001
+ "Artifacts created in this logbook",
2002
+ artRowHtml
2003
+ );
2004
+ dash.render(dashboards);
2005
+ art.render(artifacts);
2006
+ el.appendChild(dash.tile);
2007
+ el.appendChild(art.tile);
2008
+
2009
+ const scanText = markdownList
2010
+ .map((md) =>
2011
+ md.replace(/(`{3,4}|~{3,4})(html|raw)[^\n]*\n[\s\S]*?\n\1/g, " ")
2012
+ )
2013
+ .join("\n");
2014
+ const seen = new Set(
2015
+ dashboards.map((d) =>
2016
+ d.local ? `local:${d.project}` : `space:${spaceIdFromUrl(d.url)}`
2017
+ )
2018
+ );
2019
+ const remoteSpaces = new Map();
2020
+ extractUrls(scanText).forEach((url) => {
2021
+ const item = classifyResource(url);
2022
+ if (item && item.kind === "space" && !item.local) {
2023
+ remoteSpaces.set(item.url, item);
2024
+ }
2025
+ });
2026
+ remoteSpaces.forEach((s) => {
2027
+ const key = `space:${s.id}`;
2028
+ if (seen.has(key)) return;
2029
+ getJSON(`https://huggingface.co/api/spaces/${s.id}`)
2030
+ .then((d) => {
2031
+ if (STATS_TOKEN !== token) return;
2032
+ const tags = (d && d.tags) || [];
2033
+ if (
2034
+ !seen.has(key) &&
2035
+ tags.some((t) => String(t).toLowerCase() === "trackio")
2036
+ ) {
2037
+ seen.add(key);
2038
+ dashboards.push({
2039
+ project: s.id,
2040
+ local: false,
2041
+ url: s.url,
2042
+ resUrl: s.url,
2043
+ });
2044
+ dashboards.sort((a, b) => a.project.localeCompare(b.project));
2045
+ dash.render(dashboards);
2046
+ }
2047
+ })
2048
+ .catch(() => {});
2049
+ });
2050
+ return el;
2051
+ }
2052
+
2053
+ function buildAgentHint() {
2054
+ const onSpaces =
2055
+ /\.hf\.space$/.test(location.hostname) ||
2056
+ /(^|\.)huggingface\.co$/.test(location.hostname);
2057
+ let source = "";
2058
+ if (onSpaces && MANIFEST.space_id) {
2059
+ source = ` ${MANIFEST.space_id}`;
2060
+ } else if (/^https?:$/.test(location.protocol)) {
2061
+ source = ` ${location.origin}/`;
2062
+ }
2063
+ const command = `trackio logbook read${source}`;
2064
+ const tokens = MANIFEST.agent_view_tokens;
2065
+ const div = document.createElement("div");
2066
+ div.className = "agent-hint";
2067
+ const label = document.createElement("span");
2068
+ label.className = "agent-hint-label";
2069
+ label.textContent = "Read from the CLI:";
2070
+ const code = document.createElement("code");
2071
+ code.textContent = command;
2072
+ const copy = document.createElement("button");
2073
+ copy.className = "copy";
2074
+ copy.type = "button";
2075
+ copy.title = "Copy";
2076
+ copy.textContent = "⧉";
2077
+ copy.addEventListener("click", () => copyText(command, copy, "⧉"));
2078
+ const note = document.createElement("span");
2079
+ note.className = "agent-hint-note";
2080
+ note.textContent =
2081
+ "compact view for agents" + (tokens ? ` · ~${fmt(tokens)} tokens` : "");
2082
+ div.appendChild(label);
2083
+ div.appendChild(code);
2084
+ div.appendChild(copy);
2085
+ div.appendChild(note);
2086
+ return div;
2087
+ }
2088
+
2089
+ function currentSlug() {
2090
+ const slug = (location.hash || "").replace(/^#\//, "") || MANIFEST.root.slug;
2091
+ return findNode(MANIFEST.root, slug) ? slug : MANIFEST.root.slug;
2092
+ }
2093
+
2094
+ function scrollToHash(opts = {}) {
2095
+ const slug = currentSlug();
2096
+ if (!location.hash) {
2097
+ window.scrollTo({ top: 0, behavior: opts.behavior || "auto" });
2098
+ highlight(slug);
2099
+ return;
2100
+ }
2101
+ const section = document.getElementById("/" + slug);
2102
+ if (section) section.scrollIntoView({ behavior: opts.behavior || "smooth" });
2103
+ highlight(slug);
2104
+ }
2105
+
2106
+ function navigateToLogbookSlug(target) {
2107
+ const slug = String(target || "").replace(/^#?\//, "").trim();
2108
+ if (!slug || !findNode(MANIFEST.root, slug)) return;
2109
+ const hash = "#/" + slug;
2110
+ if (location.hash === hash) {
2111
+ scrollToHash({ behavior: "smooth" });
2112
+ } else {
2113
+ location.hash = hash;
2114
+ }
2115
+ }
2116
+
2117
+ function setupFigureNavigation() {
2118
+ window.addEventListener("message", (event) => {
2119
+ const data = event.data;
2120
+ if (!data || data.type !== "trackio-logbook:navigate") return;
2121
+ // Only accept messages from one of this logbook's sandboxed figure
2122
+ // iframes, rather than from an arbitrary same-origin page.
2123
+ const isFigureFrame = Array.from(
2124
+ document.querySelectorAll("iframe.figure-frame")
2125
+ ).some((frame) => frame.contentWindow === event.source);
2126
+ if (!isFigureFrame) return;
2127
+ navigateToLogbookSlug(data.target);
2128
+ });
2129
+ }
2130
+
2131
+ let SCROLL_FRAME = 0;
2132
+ function updateActiveSection() {
2133
+ cancelAnimationFrame(SCROLL_FRAME);
2134
+ SCROLL_FRAME = requestAnimationFrame(() => {
2135
+ const sections = Array.from(document.querySelectorAll(".page-section"));
2136
+ if (!sections.length) return;
2137
+ const marker = Math.min(window.innerHeight * 0.28, 180);
2138
+ let active = sections[0];
2139
+ sections.forEach((section) => {
2140
+ if (section.getBoundingClientRect().top <= marker) active = section;
2141
+ });
2142
+ if (
2143
+ window.innerHeight + window.scrollY >=
2144
+ document.documentElement.scrollHeight - 2
2145
+ ) {
2146
+ active = sections[sections.length - 1];
2147
+ }
2148
+ highlight(active.dataset.slug);
2149
+ });
2150
+ }
2151
+
2152
+ function startLiveReload() {
2153
+ if (!isLocalPreview()) return;
2154
+ setInterval(async () => {
2155
+ try {
2156
+ const next = await fetchManifest();
2157
+ if (!next || next.revision === MANIFEST.revision) return;
2158
+ MANIFEST = next;
2159
+ clearPageCache();
2160
+ document.title = MANIFEST.title + " · Trackio Logbook";
2161
+ document.getElementById("book-title").textContent = MANIFEST.title;
2162
+ document.getElementById("book-head").setAttribute("aria-label", MANIFEST.title);
2163
+ buildTree();
2164
+ renderLogbook({ preserveScroll: true });
2165
+ } catch (e) {}
2166
+ }, LIVE_RELOAD_MS);
2167
+ }
2168
+
2169
+ function setupConnect() {
2170
+ const space = MANIFEST.space_id;
2171
+ if (!space) return;
2172
+ const steps = [
2173
+ { t: "Install Trackio, if you don't have it yet.", c: "uv tool install trackio" },
2174
+ { t: "Add the Trackio skill for your agent, then reload it.", c: "trackio skills add" },
2175
+ { t: "Connect to this logbook.", c: `trackio logbook open ${space}` },
2176
+ ];
2177
+ const ol = document.getElementById("connect-steps");
2178
+ steps.forEach((s, i) => {
2179
+ const li = document.createElement("li");
2180
+ const title = document.createElement("div");
2181
+ title.className = "step-title";
2182
+ title.textContent = `${i + 1}. ${s.t}`;
2183
+ const block = document.createElement("div");
2184
+ block.className = "codeblock";
2185
+ const code = document.createElement("code");
2186
+ code.textContent = s.c;
2187
+ const copy = document.createElement("button");
2188
+ copy.className = "copy";
2189
+ copy.type = "button";
2190
+ copy.title = "Copy";
2191
+ copy.textContent = "⧉";
2192
+ copy.addEventListener("click", () => copyText(s.c, copy, "⧉"));
2193
+ block.appendChild(code);
2194
+ block.appendChild(copy);
2195
+ li.appendChild(title);
2196
+ li.appendChild(block);
2197
+ ol.appendChild(li);
2198
+ });
2199
+
2200
+ const agentPrompt =
2201
+ `Read and help maintain this Trackio experiment logbook ("${MANIFEST.title}").\n\n` +
2202
+ "1. If you don't have Trackio, install it: uv tool install trackio\n" +
2203
+ "2. Add the Trackio skill for your agent: trackio skills add (then reload)\n" +
2204
+ `3. Connect to this logbook: trackio logbook open ${space}\n\n` +
2205
+ "Start with `trackio logbook read`; use `trackio logbook read page \"...\"` " +
2206
+ "for a page-level view, then fetch relevant details with " +
2207
+ "`trackio logbook read cell cell_<id>`. If I've given you " +
2208
+ 'write access to the Space, add findings with `trackio logbook cell markdown "..." ' +
2209
+ '--page "..."` and they will sync back automatically.';
2210
+
2211
+ const foot = document.getElementById("sidebar-foot");
2212
+ foot.hidden = false;
2213
+ const modal = document.getElementById("modal");
2214
+ const open = () => (modal.hidden = false);
2215
+ const close = () => (modal.hidden = true);
2216
+ document.getElementById("connect-btn").addEventListener("click", open);
2217
+ document.getElementById("modal-close").addEventListener("click", close);
2218
+ modal.querySelector(".modal-backdrop").addEventListener("click", close);
2219
+ document.addEventListener("keydown", (e) => {
2220
+ if (e.key === "Escape") close();
2221
+ });
2222
+ const agentBtn = document.getElementById("copy-agent");
2223
+ agentBtn.addEventListener("click", () =>
2224
+ copyText(agentPrompt, agentBtn, "Copy for agent")
2225
+ );
2226
+ }
2227
+
2228
+ function copyText(text, btn, restore) {
2229
+ const done = () => {
2230
+ const prev = btn.textContent;
2231
+ btn.textContent = restore === "⧉" ? "✓" : "Copied!";
2232
+ btn.classList.add("copied");
2233
+ setTimeout(() => {
2234
+ btn.textContent = restore;
2235
+ btn.classList.remove("copied");
2236
+ }, 1400);
2237
+ void prev;
2238
+ };
2239
+ if (navigator.clipboard && navigator.clipboard.writeText) {
2240
+ navigator.clipboard.writeText(text).then(done, done);
2241
+ } else {
2242
+ const ta = document.createElement("textarea");
2243
+ ta.value = text;
2244
+ document.body.appendChild(ta);
2245
+ ta.select();
2246
+ try {
2247
+ document.execCommand("copy");
2248
+ } catch (e) {}
2249
+ document.body.removeChild(ta);
2250
+ done();
2251
+ }
2252
+ }
2253
+
2254
+ async function init() {
2255
+ MANIFEST = await fetchManifest();
2256
+ document.title = MANIFEST.title + " · Trackio Logbook";
2257
+ document.getElementById("book-title").textContent = MANIFEST.title;
2258
+ document.getElementById("book-head").setAttribute("aria-label", MANIFEST.title);
2259
+ document.getElementById("book-head").addEventListener("click", () => {
2260
+ const target = "#/" + MANIFEST.root.slug;
2261
+ if (location.hash === target) scrollToHash();
2262
+ else location.hash = target;
2263
+ });
2264
+ buildTree();
2265
+ setupConnect();
2266
+ setupResourceHover();
2267
+ setupFigureNavigation();
2268
+ window.addEventListener("hashchange", () => scrollToHash());
2269
+ window.addEventListener("scroll", updateActiveSection, { passive: true });
2270
+ await renderLogbook();
2271
+ startLiveReload();
2272
+ }
2273
+
2274
+ init();
2275
+ })();
.trackio/logbook/logbook.json ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 1,
3
+ "title": "Reproduction: Towards Foundation Models for Zero-Shot Time Series Anomaly Detection: Leveraging Synthetic Data and Relative Context Discrepancy",
4
+ "emoji": "🎯",
5
+ "space_id": "Srishti280992/repro-towards-foundation-models-for-zero-shot-time-series-anomaly-detection-leveraging-synthetic",
6
+ "paper": {
7
+ "arxiv_id": "2509.21190"
8
+ },
9
+ "tags": [
10
+ "icml2026-repro",
11
+ "paper-yXqnyIvGAy"
12
+ ],
13
+ "updated_at": "2026-07-21T21:30:18+00:00",
14
+ "root": {
15
+ "slug": "index",
16
+ "title": "Reproduction: Towards Foundation Models for Zero-Shot Time Series Anomaly Detection: Leveraging Synthetic Data and Relative Context Discrepancy",
17
+ "file": "pages/index.md",
18
+ "children": [
19
+ {
20
+ "slug": "executive-summary",
21
+ "title": "Executive summary",
22
+ "file": "pages/executive-summary/page.md",
23
+ "children": []
24
+ },
25
+ {
26
+ "slug": "claim-1-claim-1",
27
+ "title": "Claim 1",
28
+ "file": "pages/claim-1-claim-1/page.md",
29
+ "children": []
30
+ },
31
+ {
32
+ "slug": "claim-2-claim-2",
33
+ "title": "Claim 2",
34
+ "file": "pages/claim-2-claim-2/page.md",
35
+ "children": []
36
+ },
37
+ {
38
+ "slug": "claim-3-claim-3",
39
+ "title": "Claim 3",
40
+ "file": "pages/claim-3-claim-3/page.md",
41
+ "children": []
42
+ },
43
+ {
44
+ "slug": "claim-4-claim-4",
45
+ "title": "Claim 4",
46
+ "file": "pages/claim-4-claim-4/page.md",
47
+ "children": []
48
+ },
49
+ {
50
+ "slug": "claim-5-claim-5",
51
+ "title": "Claim 5",
52
+ "file": "pages/claim-5-claim-5/page.md",
53
+ "children": []
54
+ },
55
+ {
56
+ "slug": "claim-6-claim-6",
57
+ "title": "Claim 6",
58
+ "file": "pages/claim-6-claim-6/page.md",
59
+ "children": []
60
+ },
61
+ {
62
+ "slug": "conclusion",
63
+ "title": "Conclusion",
64
+ "file": "pages/conclusion/page.md",
65
+ "children": []
66
+ }
67
+ ]
68
+ },
69
+ "agent_view_tokens": 4614,
70
+ "revision": "1784669418765008000"
71
+ }
.trackio/logbook/pages/claim-1-claim-1/page.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Claim 1
2
+
3
+
4
+ ---
5
+ <!-- trackio-cell
6
+ {"type": "markdown", "id": "cell_d581ded40cf2", "created_at": "2026-07-21T02:39:07+00:00", "title": "Claim 1"}
7
+ -->
8
+ **Claim:** TimeRCD achieves the top rank in 41 of 56 univariate zero-shot anomaly detection cases and second-best in 6 cases, evaluated against general-purpose and anomaly-specific foundation models.
9
+
10
+ **Status: verified for the Table 1 rank arithmetic; partially verified by released-checkpoint reruns.** `scripts/rank_recount.py` parses arXiv Table 1 HTML for both [2509.21190v3](https://arxiv.org/abs/2509.21190v3) and [2509.21190v5](https://arxiv.org/abs/2509.21190v5), excludes asterisked leakage entries, and recomputes TimeRCD's ranks. The submission-era v3 table gives exactly **41 first / 6 second of 56** zero-shot univariate cases, matching this claim. The camera-ready v5 table expands to 64 cases and recomputes as **38 first / 14 second of 64**, matching the current paper text rather than the challenge's v3 wording.
11
+
12
+ I also verified that the released [thu-sail-lab/Time-RCD](https://huggingface.co/thu-sail-lab/Time-RCD) checkpoint loads and runs zero-shot on target data. The independent HF GPU run [6a60281f13e6ef894d54ab59](https://huggingface.co/jobs/Srishti280992/6a60281f13e6ef894d54ab59) evaluated the official univariate checkpoint on 60 UCR files and uploaded per-file results to [Srishti280992/timercd-full-eval/recon_vs_head_1784686657](https://huggingface.co/datasets/Srishti280992/timercd-full-eval/tree/main/recon_vs_head_1784686657). A broader Table 1 sweep was attempted in [6a6023f6d09dc1f57c6c0cfa](https://huggingface.co/jobs/Srishti280992/6a6023f6d09dc1f57c6c0cfa), but the public CLI path in the current repository only processed a tiny legacy univariate subset before failing on a historical multivariate checkpoint filename. I therefore do not claim a full independent rerun of every Table 1 comparator.
13
+
14
+ Relevant reproducibility assets: [official code](https://github.com/thu-sail-lab/Time-RCD), [official checkpoint](https://huggingface.co/thu-sail-lab/Time-RCD), [TSB-AD-U dataset](https://www.thedatum.org/datasets/TSB-AD-U.zip), [job output dataset](https://huggingface.co/datasets/Srishti280992/timercd-full-eval), and [reproduction bundle](https://huggingface.co/datasets/Srishti280992/timercd-repro-bundle).
.trackio/logbook/pages/claim-2-claim-2/page.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Claim 2
2
+
3
+
4
+ ---
5
+ <!-- trackio-cell
6
+ {"type": "markdown", "id": "cell_916307aa1f19", "created_at": "2026-07-21T02:39:07+00:00", "title": "Claim 2"}
7
+ -->
8
+ **Claim:** TimeRCD's zero-shot performance is competitive with full-shot baselines trained directly on target data, ranking first in 28 of those comparison cases.
9
+
10
+ **Status: verified for the Table 1 rank arithmetic, not independently retrained for all full-shot baselines.** The same `scripts/rank_recount.py` pass used for Claim 1 recomputes the full-shot comparison block from the submission-era Table 1. It gives exactly **28 first / 5 second of 56** full-shot comparison cases, matching the challenge claim. The camera-ready v5 table expands to 64 cases and recomputes as **35 first / 3 second of 64**.
11
+
12
+ This verifies the arithmetic behind the competitiveness claim and resolves the apparent discrepancy between the challenge wording and the current arXiv text. I did not retrain the full-shot baselines on each target dataset; their values are taken from the paper table. The additional zero-shot released-checkpoint run on UCR, [HF Job 6a60281f13e6ef894d54ab59](https://huggingface.co/jobs/Srishti280992/6a60281f13e6ef894d54ab59), confirms TimeRCD's public checkpoint is executable on target data and that its anomaly-head scores are materially stronger than reconstruction-error scores, but it is not a full full-shot-baseline rerun.
13
+
14
+ Relevant links: [official code](https://github.com/thu-sail-lab/Time-RCD), [official model](https://huggingface.co/thu-sail-lab/Time-RCD), [job output dataset](https://huggingface.co/datasets/Srishti280992/timercd-full-eval), and [reproduction bundle](https://huggingface.co/datasets/Srishti280992/timercd-repro-bundle).
.trackio/logbook/pages/claim-3-claim-3/page.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Claim 3
2
+
3
+
4
+ ---
5
+ <!-- trackio-cell
6
+ {"type": "markdown", "id": "cell_36ae07c0026b", "created_at": "2026-07-21T02:39:07+00:00", "title": "Claim 3"}
7
+ -->
8
+ **Claim:** The Relative Context Discrepancy paradigm detects anomalies by contrasting a query window against its surrounding context using a standard Transformer encoder with dual reconstruction and anomaly-scoring heads, rather than relying purely on reconstruction error.
9
+
10
+ **Status: verified.** Direct inspection of [thu-sail-lab/Time-RCD](https://github.com/thu-sail-lab/Time-RCD) and the released [thu-sail-lab/Time-RCD checkpoint](https://huggingface.co/thu-sail-lab/Time-RCD) confirms an 8-layer, 512-dimensional, 8-head Transformer-family encoder with both `self.reconstruction_head` and `self.anomaly_head`. The pretraining code combines masked-reconstruction MSE with anomaly cross-entropy, and the inference wrapper scores zero-shot detections from anomaly logits rather than reconstruction error.
11
+
12
+ The stronger check is an independent HF GPU run: [Job 6a60281f13e6ef894d54ab59](https://huggingface.co/jobs/Srishti280992/6a60281f13e6ef894d54ab59) ran the official univariate checkpoint on 60 UCR files and compared the anomaly head with a reconstruction-error readout from the same model. The uploaded artifact [Srishti280992/timercd-full-eval/recon_vs_head_1784686657](https://huggingface.co/datasets/Srishti280992/timercd-full-eval/tree/main/recon_vs_head_1784686657) reports:
13
+
14
+ | Readout | Files | Affiliation-F | F1-T | Standard-F1 | VUS-PR |
15
+ |---|---:|---:|---:|---:|---:|
16
+ | TimeRCD anomaly head | 60 | 0.839 | 0.365 | 0.175 | 0.234 |
17
+ | Reconstruction error | 60 | 0.739 | 0.091 | 0.031 | 0.038 |
18
+
19
+ The anomaly head is about **6.1x** higher on VUS-PR and about **5.7x** higher on Standard-F1 than reconstruction error. That directly supports the paper's central mechanism: the useful detector is the learned RCD/anomaly-logit pathway, not a plain reconstruction-error detector. Scripts and outputs are mirrored in [Srishti280992/timercd-repro-bundle](https://huggingface.co/datasets/Srishti280992/timercd-repro-bundle), with raw job artifacts also mounted in [Srishti280992/jobs-artifacts](https://huggingface.co/buckets/Srishti280992/jobs-artifacts).
.trackio/logbook/pages/claim-4-claim-4/page.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Claim 4
2
+
3
+
4
+ ---
5
+ <!-- trackio-cell
6
+ {"type": "markdown", "id": "cell_0d19b404ba7d", "created_at": "2026-07-21T02:39:07+00:00", "title": "Claim 4"}
7
+ -->
8
+ **Claim:** TimeRCD is pretrained on a synthetic corpus of 2.5 billion data points generated via context-template generation, joint-context fusion through causal DAG/ARX dynamics, causal-contextual anomaly injection, and token-level labeling.
9
+
10
+ **Status: verified for the public pipeline and scale plausibility.** `scripts/timercd_deep_audit.py` confirms all four public generator stages in [TSAD_dataset_gen_public](https://github.com/thu-sail-lab/TSAD_dataset_gen_public): context templates (trend/seasonal/noise), joint-context fusion via DAG/ARX dynamics with the `[-0.8, 0.8]` AR coefficient clamp, causal-contextual anomaly injection with endogenous/exogenous choices, and token-level labels. The same audit records one divergence from the paper description: the public code does not contain the half-life label-decay rule.
11
+
12
+ The local throughput probe generated 602,957 variable-length points in 8.918s on the CPU path (67.6k points/s), extrapolating to roughly 10.3 hours for 2.5B points on this machine. That does not prove the authors actually pretrained on every claimed point, but it makes the 2.5B-point corpus scale operationally plausible with the released generator. The official model/checkpoints are hosted at [thu-sail-lab/Time-RCD](https://huggingface.co/thu-sail-lab/Time-RCD).
.trackio/logbook/pages/claim-5-claim-5/page.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Claim 5
2
+
3
+
4
+ ---
5
+ <!-- trackio-cell
6
+ {"type": "markdown", "id": "cell_08d722d8d567", "created_at": "2026-07-21T02:39:07+00:00", "title": "Claim 5"}
7
+ -->
8
+ **Claim:** An ablation shows synthetic data with RCD injection reaches Affiliation-F 0.878 and F1-T 0.569, while switching to DADA injection on real-world data causes a catastrophic collapse to Affiliation-F 0.716 and F1-T 0.073.
9
+
10
+ **Status: partially verified; full ablation not completed.** The Table 2 values are exactly recovered from the paper text: synthetic data with RCD injection reports Affiliation-F **0.878** and F1-T **0.569**, while real-world data with DADA injection reports Affiliation-F **0.716** and F1-T **0.073**. Code inspection verifies the ingredients needed for the ablation: the public [TSAD_dataset_gen_public](https://github.com/thu-sail-lab/TSAD_dataset_gen_public) generator emits token labels, and [Time-RCD](https://github.com/thu-sail-lab/Time-RCD) trains with both reconstruction and anomaly-supervision losses.
11
+
12
+ I attempted to move this beyond paper-value extraction with checkpoint-free reduced ablation training. Script [hf_reduced_ablation_train.py](https://huggingface.co/datasets/Srishti280992/timercd-repro-bundle/tree/main/scripts) builds three arms: synthetic RCD data, synthetic normals with a context-independent DADA-style injection proxy, and real TSB normal prefixes with the same DADA-style proxy. The main HF GPU run [6a602c0113e6ef894d54abe5](https://huggingface.co/jobs/Srishti280992/6a602c0113e6ef894d54abe5) and a smaller sentinel [6a602f5713e6ef894d54ac51](https://huggingface.co/jobs/Srishti280992/6a602f5713e6ef894d54ac51) were still running at publish time and had not uploaded a `reduced_ablation_summary.json`.
13
+
14
+ Because no completed ablation artifact was available before publication, I do **not** claim independent reproduction of Table 2. This page verifies the reported values and mechanism, documents the exact attempted ablation jobs, and leaves the from-scratch training claim open pending completed artifacts in [Srishti280992/timercd-full-eval](https://huggingface.co/datasets/Srishti280992/timercd-full-eval) and [Srishti280992/jobs-artifacts](https://huggingface.co/buckets/Srishti280992/jobs-artifacts).
.trackio/logbook/pages/claim-6-claim-6/page.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Claim 6
2
+
3
+
4
+ ---
5
+ <!-- trackio-cell
6
+ {"type": "markdown", "id": "cell_e98ef5c836ff", "created_at": "2026-07-21T02:39:07+00:00", "title": "Claim 6"}
7
+ -->
8
+ **Claim:** TimeRCD attains a Standard-F1 of 0.827 on contextual anomalies, substantially outperforming competing methods, and shows a scaling law with consistent gains as pretraining data grows from 350M to 700M to 2.5B points.
9
+
10
+ **Status: partially verified with independent contextual evaluation; scaling remains reported-value evidence.** I regenerated point-only and contextual-only synthetic series with the public [TSAD_dataset_gen_public](https://github.com/thu-sail-lab/TSAD_dataset_gen_public) generator and evaluated the official zero-shot checkpoint from [thu-sail-lab/Time-RCD](https://huggingface.co/thu-sail-lab/Time-RCD). The completed HF GPU run [Job 6a602e7fd09dc1f57c6c0ea3](https://huggingface.co/jobs/Srishti280992/6a602e7fd09dc1f57c6c0ea3) uploaded its results to [Srishti280992/timercd-full-eval/specialized_eval_1784687655](https://huggingface.co/datasets/Srishti280992/timercd-full-eval/tree/main/specialized_eval_1784687655).
11
+
12
+ | Split / method | n | Affiliation-F | F1-T | Standard-F1 | VUS-PR |
13
+ |---|---:|---:|---:|---:|---:|
14
+ | Contextual / TimeRCD | 10 | 0.874 | 0.639 | 0.239 | 0.643 |
15
+ | Contextual / forecast-error baseline | 10 | 0.893 | 0.367 | 0.153 | 0.268 |
16
+ | Point / TimeRCD | 10 | 0.962 | 0.925 | 0.466 | 0.963 |
17
+ | Point / forecast-error baseline | 10 | 0.811 | 0.510 | 0.201 | 0.385 |
18
+
19
+ This run does **not** reproduce the paper's exact contextual Standard-F1 of 0.827: it is a small regenerated set, and TimeRCD's contextual Standard-F1 is 0.239. It does independently support the qualitative contextual-anomaly claim because TimeRCD strongly beats the forecasting baseline on VUS-PR and F1-T for the same generated contextual series. A longer 200-series HF Job, [6a602176d09dc1f57c6c0cb2](https://huggingface.co/jobs/Srishti280992/6a602176d09dc1f57c6c0cb2), was still running at publish time and is documented as an attempted closer match to the paper-scale specialized-set protocol.
20
+
21
+ For scaling, no 350M or 700M checkpoints are published in the official model repo, and I did not retrain 350M/700M/2.5B models. The current logbook therefore verifies that the paper text reports the 350M -> 700M -> 2.5B monotonic trend and provides a reduced contextual check, but it does not independently reproduce the full scaling curve. Reproduction scripts, generated series, and summaries are mirrored in [Srishti280992/timercd-repro-bundle](https://huggingface.co/datasets/Srishti280992/timercd-repro-bundle) and [Srishti280992/timercd-full-eval](https://huggingface.co/datasets/Srishti280992/timercd-full-eval).
.trackio/logbook/pages/conclusion/page.md ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Conclusion
2
+
3
+
4
+ ---
5
+ <!-- trackio-cell
6
+ {"type": "artifact", "id": "cell_b7e580a2bd6e", "created_at": "2026-07-21T02:48:05+00:00", "title": "Reproduction bundle", "artifact": "Srishti280992/timercd-repro-bundle", "artifact_type": "dataset"}
7
+ -->
8
+ **📦 Artifact** `repro-towards-foundation-models-for-zero-shot-time-series-anomaly-detection-leveraging-synthetic/repro-bundle:v1` · dataset
9
+
10
+ Published bundle mirror: [Srishti280992/timercd-repro-bundle](https://huggingface.co/datasets/Srishti280992/timercd-repro-bundle)
11
+
12
+
13
+ ---
14
+ <!-- trackio-cell
15
+ {"type": "markdown", "id": "cell_df3af82c6b71", "created_at": "2026-07-21T02:39:07+00:00", "title": "Download and rerun"}
16
+ -->
17
+ The reproduction bundle is mirrored as [Srishti280992/timercd-repro-bundle](https://huggingface.co/datasets/Srishti280992/timercd-repro-bundle), with heavier job outputs in [Srishti280992/timercd-full-eval](https://huggingface.co/datasets/Srishti280992/timercd-full-eval) and raw job mounts in [Srishti280992/jobs-artifacts](https://huggingface.co/buckets/Srishti280992/jobs-artifacts). To rerun locally or on HF Jobs:
18
+
19
+ ```bash
20
+ cd repro_towards_foundation_models_workspace
21
+ .venv/bin/python scripts/rank_recount.py
22
+ .venv/bin/python scripts/timercd_deep_audit.py
23
+ .venv/bin/python scripts/hf_recon_vs_head_ucr.py
24
+ .venv/bin/python scripts/hf_specialized_context_eval.py
25
+ .venv/bin/python scripts/hf_reduced_ablation_train.py
26
+ ```
27
+
28
+ The full Table 1 comparator sweep, full-shot baseline retraining, completed Table 2 ablation training, and 350M/700M/2.5B scaling retraining were not completed in this revision. This logbook improves the evidence trail substantially with independent released-checkpoint HF Jobs and transparent unfinished ablation/scaling boundaries.
.trackio/logbook/pages/executive-summary/page.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Executive summary
2
+
3
+
4
+ ---
5
+ <!-- trackio-cell
6
+ {"type": "markdown", "id": "cell_3d0dd4d7e5c9", "created_at": "2026-07-21T02:39:07+00:00", "title": "Executive summary", "pinned": true, "pinned_at": "2026-07-21T02:39:07+00:00"}
7
+ -->
8
+ This revision adopts the stronger methodology requested: exact Table 1 rank recounts by paper version, direct code/checkpoint inspection, independent HF GPU released-checkpoint evaluation, generated contextual/point anomaly evaluation, and attempted checkpoint-free ablation training. The submission-era Table 1 counts verify exactly (**41 first / 6 second of 56** zero-shot cases and **28 first-place** full-shot comparison cases); the current camera-ready table also verifies exactly with its expanded 64-case counts (**38 / 14** zero-shot and **35 / 3** full-shot).
9
+
10
+ The strongest new empirical result is [HF Job 6a60281f13e6ef894d54ab59](https://huggingface.co/jobs/Srishti280992/6a60281f13e6ef894d54ab59): on 60 UCR files, the official TimeRCD anomaly head beats reconstruction error by about **6.1x VUS-PR** (0.234 vs 0.038) and **5.7x Standard-F1** (0.175 vs 0.031), directly supporting the RCD/anomaly-logit mechanism. A specialized generated-set run, [6a602e7fd09dc1f57c6c0ea3](https://huggingface.co/jobs/Srishti280992/6a602e7fd09dc1f57c6c0ea3), shows TimeRCD beating a forecasting baseline on contextual VUS-PR (0.643 vs 0.268), but it does not reproduce the paper's exact contextual Standard-F1 of 0.827. The ablation claim remains only partially verified: reduced checkpoint-free ablation jobs were launched but had not uploaded completed summaries by publication.
11
+
12
+ ## Scope & cost
13
+
14
+ | | This reproduction | Full replication |
15
+ |---|---|---|
16
+ | Scope | Table rank recounts, checkpoint/code audits, 60-file UCR anomaly-head vs reconstruction run, generated point/contextual HF Job, reduced ablation attempts | Full Table 1 sweeps, all comparator reruns, full-shot baseline retraining, 350M/700M/2.5B pretraining ablations |
17
+ | Hardware | Local CPU plus multiple Hugging Face `rtx-pro-6000` Jobs | Multi-GPU training/evaluation |
18
+ | Cloud artifacts | [Srishti280992/timercd-full-eval](https://huggingface.co/datasets/Srishti280992/timercd-full-eval), [Srishti280992/jobs-artifacts](https://huggingface.co/buckets/Srishti280992/jobs-artifacts) | Not completed |
19
+ | Outcome | Claims 1-4 strongly supported; Claim 6 qualitatively supported but not exact; Claim 5 partially verified for values/mechanism only | Needed for a full 12/12-style reproduction |
20
+
21
+
22
+ ---
23
+ <!-- trackio-cell
24
+ {"type": "figure", "id": "cell_3edc58b50665", "created_at": "2026-07-21T02:50:58+00:00", "title": "Reproduction poster", "pinned": true, "pinned_at": "2026-07-21T02:50:59+00:00"}
25
+ -->
26
+ ````html
27
+ <!-- source: poster_embed.html -->
28
+ <iframe src="poster_embed.html" style="width:100%;height:720px;border:0" title="TimeRCD reproduction poster"></iframe>
29
+ ````
.trackio/logbook/pages/index.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Reproduction: Towards Foundation Models for Zero-Shot Time Series Anomaly Detection: Leveraging Synthetic Data and Relative Context Discrepancy
2
+
3
+ [HF paper page](https://huggingface.co/papers/2509.21190)
4
+
5
+ ## Pages
6
+
7
+ | Page |
8
+ | --- |
9
+ | [Executive summary](#/executive-summary) |
10
+ | [Claim 1](#/claim-1-claim-1) |
11
+ | [Claim 2](#/claim-2-claim-2) |
12
+ | [Claim 3](#/claim-3-claim-3) |
13
+ | [Claim 4](#/claim-4-claim-4) |
14
+ | [Claim 5](#/claim-5-claim-5) |
15
+ | [Claim 6](#/claim-6-claim-6) |
16
+ | [Conclusion](#/conclusion) |
.trackio/logbook/trackio-logo-light.png ADDED

Git LFS Details

  • SHA256: a6eb72253c0128ce79b526a86b7943eed37beec186b5f57ff6c1701d0e9ff596
  • Pointer size: 130 Bytes
  • Size of remote file: 30 kB
.trackio/logbook/trackio-logo.png ADDED

Git LFS Details

  • SHA256: 3e3792061d4d095759da30d7cfe7f14b621901793cd4d677b61b2896f5bf472b
  • Pointer size: 130 Bytes
  • Size of remote file: 55.6 kB
.trackio/logbook/trackio-wordmark-dark.png ADDED

Git LFS Details

  • SHA256: 71da94795855710d214801eb9b9b7b8898e9a8757abac0e22966a0531bbb2f4f
  • Pointer size: 130 Bytes
  • Size of remote file: 89.8 kB
outputs/hf_job_results/recon_vs_head_1784686657/recon_vs_head_summary.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "anomaly_head": {
3
+ "files": 60,
4
+ "VUS-PR": 0.23405226529185358,
5
+ "Standard-F1": 0.1746731578208736,
6
+ "Affiliation-F": 0.839149361520469,
7
+ "F1_T": 0.36507514908483546
8
+ },
9
+ "reconstruction_error": {
10
+ "files": 60,
11
+ "VUS-PR": 0.03842590873444119,
12
+ "Standard-F1": 0.030817348780468982,
13
+ "Affiliation-F": 0.7392492206443433,
14
+ "F1_T": 0.09090737616303765
15
+ },
16
+ "elapsed_seconds": 461.58
17
+ }
outputs/hf_job_results/recon_vs_head_1784686657/recon_vs_head_ucr.csv ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ filename,readout,AUC-PR,AUC-ROC,VUS-PR,VUS-ROC,Standard-F1,Standard-Precision,Standard-Recall,PA-F1,PA-Precision,PA-Recall,Affiliation-F,Affiliation-P,Affiliation-R,F1_T,Precision_T,Recall_T
2
+ 303_UCR_id_1_Medical_tr_2499_1st_8000.csv,anomaly_head,0.06871939454659813,0.9785656944072785,0.08358723095310445,0.9790572023160219,0.0,0.0,0.0,0.3424657534246575,0.2066115702479339,1.0,0.9062262664772636,0.8285318337104247,1.0,0.2283104956150055,0.12886597216129303,1.0
3
+ 303_UCR_id_1_Medical_tr_2499_1st_8000.csv,reconstruction_error,0.53179940685692,0.8242012309339042,0.2626835754616501,0.8907983193827207,0.5853658536585366,0.75,0.48,0.0,0.0,0.0,0.9997718675862263,1.0,0.9995439391918923,0.5939257740974426,1.0,0.42239999771118164
4
+ 304_UCR_id_2_Medical_tr_2499_1st_7000.csv,anomaly_head,0.23060720569809673,0.988862934622097,0.23878486570650825,0.98913517472988,0.3888888888888889,0.25301204819277107,0.84,0.0,0.0,0.0,0.9280677713386333,0.8666110213872138,0.9989065208694492,0.5027322769165039,0.3458646535873413,0.9200000166893005
5
+ 304_UCR_id_2_Medical_tr_2499_1st_7000.csv,reconstruction_error,0.03863920440934572,0.6223681031010874,0.02896371662016702,0.6824367390246997,0.1095890410958904,0.17391304347826086,0.08,0.0,0.0,0.0,0.8084827104548711,0.6797668260529975,0.9973303107080944,0.13617156445980072,0.17142857611179352,0.11294303834438324
6
+ 305_UCR_id_3_Medical_tr_3000_1st_5948.csv,anomaly_head,0.8901299940204846,0.9969501830138346,0.8478705384582377,0.9967665487933465,0.8780487804878049,0.972972972972973,0.8,0.0,0.0,0.0,0.9999450087100181,1.0,0.9998901234567902,0.9069767594337463,0.9512194991111755,0.8666666746139526
7
+ 305_UCR_id_3_Medical_tr_3000_1st_5948.csv,reconstruction_error,0.013149080302885544,0.6971598734412805,0.027187504219662557,0.8710350601643321,0.04356435643564356,0.022797927461139896,0.4888888888888889,0.0,0.0,0.0,0.6826918122400907,0.5184109444444445,0.9993925925925926,0.1080898717045784,0.06111111119389534,0.467401921749115
8
+ 306_UCR_id_4_Medical_tr_2507_1st_8500.csv,anomaly_head,0.0024630541871921183,0.9461436170212766,0.10640343445313466,0.9813382862182863,0.004901960784313725,0.002457002457002457,1.0,0.0,0.0,0.0,0.9970081093325402,0.996543012897221,0.9974737401941232,0.005602240562438965,0.002808988792821765,1.0
9
+ 306_UCR_id_4_Medical_tr_2507_1st_8500.csv,reconstruction_error,0.00035778175313059033,0.6284574468085107,0.008945923830962195,0.9322823647565291,0.0007150518412584912,0.000357653791130186,1.0,0.0,0.0,0.0,0.8208858231773578,0.7502105216504898,0.9062624650977263,0.0008956561214290559,0.00044802867341786623,1.0
10
+ 307_UCR_id_5_Facility_tr_29895_1st_39240.csv,anomaly_head,0.0007841498664007364,0.3699043339584101,0.000934237661402576,0.40927279353376367,0.0006675715970537841,0.00033450036795040474,0.15625,0.0,0.0,0.0,0.711887006729203,0.5559342212430608,0.9894519707866422,0.023538345471024513,0.011918642558157444,0.9384720325469971
11
+ 307_UCR_id_5_Facility_tr_29895_1st_39240.csv,reconstruction_error,0.002000966473835843,0.5761312307686584,0.0027812627619742823,0.6696160660749766,0.0,0.0,0.0,0.17695852534562212,0.09706774519716886,1.0,0.8171131862868083,0.6916649012283733,0.9981490773261972,0.03108774498105049,0.017281105741858482,0.1546223908662796
12
+ 308_UCR_id_6_Facility_tr_20000_1st_56600.csv,anomaly_head,0.006252008715295125,0.6336644277315288,0.007170585154996192,0.6530231899423267,0.01954866588929282,0.009875944278882805,0.95,0.0,0.0,0.0,0.783867115206755,0.6529268064235129,0.9805003249945834,0.029172105714678764,0.014829142950475216,0.8897892832756042
13
+ 308_UCR_id_6_Facility_tr_20000_1st_56600.csv,reconstruction_error,0.0029315210367929735,0.21491354137004962,0.0039045518315551355,0.3195876751402883,0.0,0.0,0.0,0.32275416890801506,0.19243104554201412,1.0,0.7107362099001889,0.5599914798167998,0.9725337911034816,0.015805428847670555,0.007966951467096806,0.9801329374313354
14
+ 309_UCR_id_7_Medical_tr_3000_1st_5948.csv,anomaly_head,0.9195429576222055,0.9931608660586886,0.8876311618475222,0.9965554739235103,0.0,0.0,0.0,0.6474820143884892,0.4787234042553192,1.0,0.9999579729293602,1.0,0.999916049382716,0.9318181872367859,0.9534883499145508,0.9111111164093018
15
+ 309_UCR_id_7_Medical_tr_3000_1st_5948.csv,reconstruction_error,0.01412133156464199,0.7022346299398226,0.028147227705632948,0.8721546157049148,0.044358727097396335,0.023185483870967742,0.5111111111111111,0.0,0.0,0.0,0.687210117393339,0.5269807162534434,0.9874444444444445,0.11219511926174164,0.06301369518041611,0.5111111402511597
16
+ 310_UCR_id_8_HumanActivity_tr_2631_1st_8285.csv,anomaly_head,0.11041425303940344,0.953898003306626,0.0713058285387828,0.9596963256524761,0.17391304347826086,0.25,0.13333333333333333,0.0,0.0,0.0,0.9273716778087512,0.8658074473353835,0.9983614172895815,0.40816327929496765,0.5263158082962036,0.3333333432674408
17
+ 310_UCR_id_8_HumanActivity_tr_2631_1st_8285.csv,reconstruction_error,0.013601739618996305,0.7044342702106914,0.03878638912903777,0.8055248199284902,0.0,0.0,0.0,0.43795620437956206,0.2803738317757009,1.0,0.7747412816534699,0.6340428227543392,0.9956923856581781,0.054768647998571396,0.0476190485060215,0.06444444507360458
18
+ 311_UCR_id_9_HumanActivity_tr_16000_1st_38400.csv,anomaly_head,0.07250329402663712,0.8970958818855933,0.0759515657580949,0.9011735478146738,0.0,0.0,0.0,0.6625258799171843,0.4953560371517028,1.0,0.6741892008609459,0.5085192630543013,0.999967734375,0.32731664180755615,0.20663847029209137,0.7868306636810303
19
+ 311_UCR_id_9_HumanActivity_tr_16000_1st_38400.csv,reconstruction_error,0.019781672612660898,0.41457089512711864,0.01760195037995745,0.4430723358813371,0.030000882378893496,0.0161397512579512,0.2125,0.0,0.0,0.0,0.7260889497987552,0.5721013257575758,0.9935013411458332,0.06554543972015381,0.033891819417476654,0.9925187230110168
20
+ 312_UCR_id_10_Facility_tr_19948_1st_52000.csv,anomaly_head,0.059124884882937476,0.839540978749339,0.06436139601210109,0.8603478702824161,0.17525385483264386,0.114271701814615,0.3758064516129032,0.0,0.0,0.0,0.7311708610089394,0.5767604737352005,0.9984857084490181,0.28747642040252686,0.23505572974681854,0.36998915672302246
21
+ 312_UCR_id_10_Facility_tr_19948_1st_52000.csv,reconstruction_error,0.024782748807110407,0.6646131995161317,0.02587135919519237,0.6869965937071851,0.08256880733944955,0.047751389590702374,0.30483870967741933,0.0,0.0,0.0,0.6815225505742146,0.5171765205058966,0.9989712880749136,0.13606375455856323,0.0855855867266655,0.331699013710022
22
+ 313_UCR_id_11_Sensor_tr_2827_1st_4711.csv,anomaly_head,0.9664055969720364,0.9993938169327138,0.9333408847204642,0.9992529111899846,0.9289617486338798,1.0,0.8673469387755102,0.0,0.0,0.0,0.9998723977517143,1.0,0.9997449280384244,0.9746193289756775,0.9696969985961914,0.9795918464660645
23
+ 313_UCR_id_11_Sensor_tr_2827_1st_4711.csv,reconstruction_error,0.022231390815480846,0.5571370144144977,0.03635752372417744,0.6806346548692999,0.046153846153846156,0.037037037037037035,0.061224489795918366,0.0,0.0,0.0,0.784141907834618,0.6497268403883191,0.9886793769506388,0.13239040970802307,0.07992202788591385,0.3854100704193115
24
+ 314_UCR_id_12_HumanActivity_tr_16250_1st_38500.csv,anomaly_head,0.023943677798204166,0.7752694530443756,0.0252757053976543,0.7990000681546016,0.07692307692307693,0.05660377358490566,0.12,0.0,0.0,0.0,0.8747245091789438,0.7792136960600375,0.9969204786324787,0.14285506308078766,0.1276041716337204,0.16224625706672668
25
+ 314_UCR_id_12_HumanActivity_tr_16250_1st_38500.csv,reconstruction_error,0.005143401722533813,0.43230388716890267,0.006697658984039741,0.5100441129936758,0.010497529992942838,0.005319148936170213,0.39666666666666667,0.0,0.0,0.0,0.670460392945388,0.506406168359942,0.9917435897435898,0.025907406583428383,0.01312544010579586,0.9900222420692444
26
+ 315_UCR_id_13_HumanActivity_tr_16000_1st_33070.csv,anomaly_head,0.012840151887960796,0.910479602877807,0.013949454711426897,0.9195492608627903,0.0,0.0,0.0,0.16628873771730915,0.09068425391591096,1.0,0.645268332182196,0.4763114594184028,0.9999810606060606,0.09895007312297821,0.05238095298409462,0.8918181657791138
27
+ 315_UCR_id_13_HumanActivity_tr_16000_1st_33070.csv,reconstruction_error,0.012181232848365288,0.44779551623986785,0.01302060931905184,0.607104276200469,0.07058823529411765,0.06206896551724138,0.08181818181818182,0.0,0.0,0.0,0.7305471526441794,0.5757001602564102,0.9993418560606061,0.10164174437522888,0.1428571492433548,0.07888329774141312
28
+ 316_UCR_id_14_Sensor_tr_2833_1st_5988.csv,anomaly_head,0.11182298123731654,0.9582844693494016,0.15660536513692797,0.9665024834774444,0.0,0.0,0.0,0.5773809523809523,0.40585774058577406,1.0,0.9589887740361094,0.9214087045629384,0.9997647335607576,0.3923032879829407,0.26966291666030884,0.7195471525192261
29
+ 316_UCR_id_14_Sensor_tr_2833_1st_5988.csv,reconstruction_error,0.014860061667155148,0.6349811331864551,0.027600416883252422,0.7571493002605687,0.03971455165994415,0.020473448496481125,0.6597938144329897,0.0,0.0,0.0,0.7530827976539097,0.6197898286476101,0.9594165392306788,0.08942931890487671,0.04822908714413643,0.6136273741722107
30
+ 317_UCR_id_15_HumanActivity_tr_16000_1st_38400.csv,anomaly_head,0.047160941031847994,0.8132055084745762,0.05135764062762604,0.8247236177877392,0.0,0.0,0.0,0.7733204446592556,0.6304176516942475,1.0,0.883563535743493,0.7981666666666667,0.9894233072916667,0.2127074897289276,0.13347989320755005,0.5233358144760132
31
+ 317_UCR_id_15_HumanActivity_tr_16000_1st_38400.csv,reconstruction_error,0.015045180699084539,0.3776076933262712,0.01530890928277369,0.4048564041359258,0.0,0.0,0.0,0.7718282682103232,0.6284367635506677,1.0,0.7498484407819976,0.6021717171717171,0.9934930078124999,0.06585678458213806,0.0340820737183094,0.9727734923362732
32
+ 318_UCR_id_16_Medical_tr_2499_1st_7000.csv,anomaly_head,0.007988075461520283,0.6043442072761446,0.008678887287863752,0.6105489253847667,0.027292576419213975,0.01383508577753182,1.0,0.0,0.0,0.0,0.8210835253685077,0.8169001768541816,0.8253100413388452,0.06447453051805496,0.03331112489104271,1.0
33
+ 318_UCR_id_16_Medical_tr_2499_1st_7000.csv,reconstruction_error,0.012619791397481601,0.5798147402335884,0.014018889886063377,0.6444772179416047,0.0,0.0,0.0,0.5747126436781609,0.4032258064516129,1.0,0.746296870084403,0.5962803587486878,0.9971729563941858,0.0765279084444046,0.049723755568265915,0.1660262644290924
34
+ 319_UCR_id_17_Environment_tr_6166_1st_19280.csv,anomaly_head,0.8493793898198436,0.9932078403576686,0.809822891702075,0.9945312285657936,0.8068965517241379,0.9,0.73125,0.0,0.0,0.0,0.9997623219285695,1.0,0.9995248567644992,0.797379195690155,0.8322147727012634,0.7653427720069885
35
+ 319_UCR_id_17_Environment_tr_6166_1st_19280.csv,reconstruction_error,0.047482887011888256,0.44339083201570256,0.02778360700872783,0.45513621749954747,0.1111111111111111,0.21428571428571427,0.075,0.0,0.0,0.0,0.8377467407132402,0.7219297917368291,0.9978247797416355,0.1287088692188263,0.31707316637039185,0.08074218779802322
36
+ 320_UCR_id_18_Medical_tr_2500_1st_7000.csv,anomaly_head,0.003739455054698939,0.49592647124436706,0.004166277103926644,0.5181390316373504,0.009765028989929814,0.004927625500461965,0.5333333333333333,0.0,0.0,0.0,0.8042895919889527,0.7977295334980977,0.8109585388614851,0.02327272854745388,0.01189591083675623,0.5333333611488342
37
+ 320_UCR_id_18_Medical_tr_2500_1st_7000.csv,reconstruction_error,0.010544584992296898,0.6289965644938206,0.013718739853790466,0.713386659083911,0.0,0.0,0.0,0.45112781954887216,0.2912621359223301,1.0,0.7668557958733073,0.6225770836188977,0.9981780207083499,0.06755183637142181,0.04273504391312599,0.16111111640930176
38
+ 321_UCR_id_19_Medical_tr_1875_1st_4485.csv,anomaly_head,0.9934373092527506,0.9998366900625903,0.9838113555166419,0.9997718986200278,0.9705882352941176,0.9705882352941176,0.9705882352941176,0.0,0.0,0.0,0.9999781630329662,1.0,0.9999564270152506,0.9901960492134094,0.9901960492134094,0.9901960492134094
39
+ 321_UCR_id_19_Medical_tr_1875_1st_4485.csv,reconstruction_error,0.019645484249268715,0.5038200324489746,0.03019198701096578,0.6606544977064618,0.0,0.0,0.0,0.6126126126126126,0.44155844155844154,1.0,0.7241500236625483,0.6211555555555556,0.8680888888888889,0.09172871708869934,0.058411214500665665,0.21351906657218933
40
+ 322_UCR_id_20_Facility_tr_7482_1st_24005.csv,anomaly_head,0.06565818942242788,0.9783725104646138,0.09557978711830414,0.9832497322426674,0.14646464646464646,0.08055555555555556,0.8055555555555556,0.0,0.0,0.0,0.6403117251357712,0.47095727133380827,0.9998564647769511,0.1832672357559204,0.10401459783315659,0.7698286175727844
41
+ 322_UCR_id_20_Facility_tr_7482_1st_24005.csv,reconstruction_error,0.011653941267051581,0.5917975053750627,0.011242279837929503,0.7479861286015241,0.0,0.0,0.0,0.39779005524861877,0.2482758620689655,1.0,0.6325616053322449,0.46263043626295347,0.9998054231566861,0.05831260606646538,0.042424242943525314,0.09322729706764221
42
+ 323_UCR_id_21_HumanActivity_tr_48812_1st_128430.csv,anomaly_head,8.54000136640022e-06,0.2003762710243996,1.5685100578848533e-05,0.24164030148810317,0.0,0.0,0.0,0.0,0.0,0.0,0.7637264762559304,0.6249375998367771,0.9817601988554884,2.785165997920558e-05,1.3926024621468969e-05,1.0
43
+ 323_UCR_id_21_HumanActivity_tr_48812_1st_128430.csv,reconstruction_error,1.2089851778417197e-05,0.43516324426203756,4.3217894322617626e-05,0.7846087901013385,0.0,0.0,0.0,0.0,0.0,0.0,0.6788975677136936,0.5147370998550338,0.9967972793946926,4.481089854380116e-05,2.2405951312975958e-05,1.0
44
+ 324_UCR_id_22_Medical_tr_1875_1st_5865.csv,anomaly_head,0.7484204518469434,0.9919930556594879,0.9085577134159801,0.9977181003096759,0.0,0.0,0.0,0.9646017699115044,0.9316239316239316,1.0,0.9966470358449021,1.0,0.9933165806201221,0.6714645624160767,0.5644171833992004,0.8286208510398865
45
+ 324_UCR_id_22_Medical_tr_1875_1st_5865.csv,reconstruction_error,0.016345663020839105,0.45344082427459415,0.026487314592189084,0.6016993464512066,0.0,0.0,0.0,0.35973597359735976,0.2193158953722334,1.0,0.6648311065921128,0.4996001923993212,0.9933622401889002,0.052797529846429825,0.027203481644392014,0.8924117684364319
46
+ 325_UCR_id_23_Medical_tr_3000_1st_6168.csv,anomaly_head,0.032457286317919956,0.9316862235575947,0.03546755833001213,0.933247261915515,0.0,0.0,0.0,0.24649859943977592,0.14057507987220447,1.0,0.8358640986450131,0.8211538461538462,0.851111111111111,0.18701128661632538,0.11026615649461746,0.6151664853096008
47
+ 325_UCR_id_23_Medical_tr_3000_1st_6168.csv,reconstruction_error,0.003703767555903157,0.3857317593081327,0.015201882080254577,0.6796641305047547,0.0,0.0,0.0,0.07102502017756256,0.03682008368200837,1.0,0.6743391534241258,0.5089551230062178,0.9989444444444444,0.027213506400585175,0.013852490112185478,0.7670296430587769
48
+ 326_UCR_id_24_Medical_tr_1875_1st_4187.csv,anomaly_head,0.8674674862174863,0.9997921862011637,0.6385720793692566,0.9992595059180761,0.0,0.0,0.0,0.34782608695652173,0.21052631578947367,1.0,0.9997629234942012,0.9995852589169333,0.9999407512738476,0.888888955116272,0.800000011920929,1.0
49
+ 326_UCR_id_24_Medical_tr_1875_1st_4187.csv,reconstruction_error,0.005593406503327312,0.5660996318726991,0.076461644767985,0.9280132104204009,0.0,0.0,0.0,0.10126582278481013,0.05333333333333334,1.0,0.831573256176224,0.7172058300746533,0.9893352292925702,0.052831508219242096,0.02857142873108387,0.35011574625968933
50
+ 327_UCR_id_25_Medical_tr_15000_1st_51370.csv,anomaly_head,0.07690692168471738,0.9397716661317379,0.09777129086897221,0.9536184881825629,0.18307426597582038,0.10495049504950495,0.7162162162162162,0.0,0.0,0.0,0.6914475775691334,0.5284754048790488,0.9997534234234234,0.20696768164634705,0.12154696136713028,0.696344256401062
51
+ 327_UCR_id_25_Medical_tr_15000_1st_51370.csv,reconstruction_error,0.009448354704020423,0.5398125124900837,0.012050335824310286,0.602454004360668,0.018268942797244683,0.009394732789157555,0.32972972972972975,0.0,0.0,0.0,0.7451498811218931,0.5947879781420765,0.9972553153153153,0.022932376712560654,0.011682778596878052,0.6184778213500977
52
+ 328_UCR_id_26_Medical_tr_1913_1st_3474.csv,anomaly_head,0.5686667503309416,0.969666678216278,0.7261604321025472,0.9858924029758874,0.0,0.0,0.0,0.9717868338557993,0.9451219512195121,1.0,0.9925726326171718,0.9971549671950299,0.9880323198723387,0.6649873852729797,0.5454545617103577,0.85161292552948
53
+ 328_UCR_id_26_Medical_tr_1913_1st_3474.csv,reconstruction_error,0.08698404517844374,0.6944267350403659,0.09125811302639196,0.7379816779772485,0.0,0.0,0.0,0.8635097493036211,0.7598039215686274,1.0,0.7830736905586043,0.6719430412820067,0.9382478044175737,0.3228081464767456,0.23646724224090576,0.5084620714187622
54
+ 329_UCR_id_27_Medical_tr_7500_1st_17210.csv,anomaly_head,0.55366634860157,0.962286757828159,0.2915424623497032,0.976546309003091,0.0,0.0,0.0,0.3472222222222222,0.21008403361344538,1.0,0.9678079419823652,0.937915259321808,0.9996689036042842,0.6666666865348816,0.6734693646430969,0.6600000262260437
55
+ 329_UCR_id_27_Medical_tr_7500_1st_17210.csv,reconstruction_error,0.3628753517468897,0.7943744153935237,0.1256828868329516,0.8493306737883785,0.0,0.0,0.0,0.33112582781456956,0.1984126984126984,1.0,0.9724502368752201,0.9466773698946713,0.9996657926314385,0.43976181745529175,0.7727272510528564,0.3073330819606781
56
+ 330_UCR_id_28_Facility_tr_7482_1st_23405.csv,anomaly_head,0.018130183875017195,0.9177602995138858,0.018881245897680723,0.9179774230427842,0.045756457564575644,0.024162120031176928,0.4305555555555556,0.0,0.0,0.0,0.5898962190350863,0.4183353636716375,1.0,0.04904055967926979,0.025673137977719307,0.5460456013679504
57
+ 330_UCR_id_28_Facility_tr_7482_1st_23405.csv,reconstruction_error,0.005285363396565965,0.5625617573599877,0.006686224619108142,0.6850838691752532,0.022988505747126436,0.013333333333333334,0.08333333333333333,0.0,0.0,0.0,0.6255834807430436,0.4551986395870501,0.9998280052068639,0.02953322045505047,0.017500000074505806,0.09454035758972168
58
+ 331_UCR_id_29_Facility_tr_50000_1st_837400.csv,anomaly_head,0.0013464454402699342,0.3280964617816949,0.0013744512359166715,0.3312054225975736,0.002306069838293883,0.0011576470588235293,0.28941176470588237,0.13793663028926123,0.07407730184321756,1.0,0.7705213516884672,0.6294991047244909,0.9929694117647059,0.004448749590665102,0.0022293482907116413,0.9970612525939941
59
+ 331_UCR_id_29_Facility_tr_50000_1st_837400.csv,reconstruction_error,0.0019387351232121224,0.4778284999063871,0.00198608704656111,0.48716623879160514,0.0,0.0,0.0,0.2859064917591658,0.16679748822605966,1.0,0.6780315748314045,0.5145616106688721,0.9937265397923875,0.005305946338921785,0.0026951280888170004,0.1696144938468933
60
+ 332_UCR_id_30_Facility_tr_13750_1st_52600.csv,anomaly_head,0.017244189737244963,0.868983556638246,0.024613597300065997,0.8936619409250298,0.042130750605326873,0.021588089330024814,0.87,0.0,0.0,0.0,0.7013077912907277,0.5400162412155115,0.9999814545454545,0.04607409983873367,0.023676691576838493,0.8527300357818604
61
+ 332_UCR_id_30_Facility_tr_13750_1st_52600.csv,reconstruction_error,0.005261539617168014,0.5222781973203411,0.008007520904543913,0.6457382113852695,0.013383521539104977,0.00730260155180283,0.08,0.46893317702227433,0.30627871362940273,1.0,0.811417843338152,0.6987679653679654,0.967369696969697,0.014255673624575138,0.007787448354065418,0.08415212482213974
62
+ 333_UCR_id_31_Facility_tr_7500_1st_13400.csv,anomaly_head,0.07559409523980806,0.8906702488687782,0.07848424310791188,0.8964161736902222,0.16941747572815535,0.09381720430107526,0.8725,0.0,0.0,0.0,0.7512101278971101,0.6029693989071038,0.9961034444444445,0.362112820148468,0.22955144941806793,0.8570312857627869
63
+ 333_UCR_id_31_Facility_tr_7500_1st_13400.csv,reconstruction_error,0.01456589256088857,0.4290279411764706,0.018931763590284742,0.5081091807612154,0.02752779248279513,0.014267422718126943,0.39,0.0,0.0,0.0,0.6848038210854055,0.5218868388683887,0.995599388888889,0.11787580698728561,0.06285344809293747,0.9460880756378174
64
+ 334_UCR_id_32_HumanActivity_tr_1671_1st_2764.csv,anomaly_head,0.0377457373508942,0.4394029921006082,0.042232533738274854,0.4728150905827318,0.05124450951683748,0.027988804478208718,0.30303030303030304,0.0,0.0,0.0,0.7231665562014133,0.5814376943991031,0.9562609077869401,0.3132203221321106,0.18569131195545197,1.0
65
+ 334_UCR_id_32_HumanActivity_tr_1671_1st_2764.csv,reconstruction_error,0.03654943230280507,0.3938026980686956,0.047207268338410525,0.4682963989098853,0.0,0.0,0.0,0.90234375,0.8220640569395018,1.0,0.6545234356435691,0.4912402222307108,0.9803977191768933,0.28077933192253113,0.16830065846443176,0.8465361595153809
66
+ 335_UCR_id_33_Medical_tr_1875_1st_4526.csv,anomaly_head,0.9523452609678879,0.9997200381224685,0.9332217867899557,0.9997252477251869,0.0,0.0,0.0,0.6896551724137931,0.5263157894736842,1.0,0.9998386842899472,0.9997604290638186,0.9999170517833865,0.920634925365448,0.8787878751754761,0.9666666388511658
67
+ 335_UCR_id_33_Medical_tr_1875_1st_4526.csv,reconstruction_error,0.003683018954727759,0.32207529187514894,0.04792962390152967,0.7051790224345736,0.0052141527001862194,0.0026365348399246705,0.23333333333333334,0.0,0.0,0.0,0.7722891619906017,0.6311766797013865,0.9946676146462852,0.021359914913773537,0.010795250535011292,1.0
68
+ 336_UCR_id_34_Facility_tr_32191_1st_124159.csv,anomaly_head,0.18623014975529334,0.949756276117563,0.1568415346620275,0.9511883515240346,0.0,0.0,0.0,0.6947014297729184,0.5322164948453608,1.0,0.8409888858299299,0.7262739606177369,0.998739905201559,0.26712605357170105,0.26730310916900635,0.26694923639297485
69
+ 336_UCR_id_34_Facility_tr_32191_1st_124159.csv,reconstruction_error,0.008713396989303013,0.5313163314978601,0.00958800727949704,0.5656485744633082,0.018485440119636105,0.009404057480980558,0.5387409200968523,0.0,0.0,0.0,0.6738555449912669,0.5081870923492885,0.9997842971428892,0.019803369417786598,0.010038694366812706,0.7254948616027832
70
+ 337_UCR_id_35_HumanActivity_tr_50000_1st_110260.csv,anomaly_head,0.03185107426737921,0.9850249129644355,0.03528602353735027,0.9850685467948751,0.0,0.0,0.0,0.1737142857142857,0.0951188986232791,1.0,0.7351957536083717,0.5812768600237248,0.9999868640350876,0.18866892158985138,0.10818438231945038,0.7368645668029785
71
+ 337_UCR_id_35_HumanActivity_tr_50000_1st_110260.csv,reconstruction_error,0.0006180932900553593,0.24883285237812913,0.0006917919392621279,0.281832533381025,0.0,0.0,0.0,0.007854688267059401,0.003942828979793002,1.0,0.7497949068823618,0.6140621558872306,0.9625600000000001,0.004990232642740011,0.0025013575796037912,1.0
72
+ 338_UCR_id_36_Facility_tr_9000_1st_12400.csv,anomaly_head,0.07291637266620357,0.8049162155558062,0.07778438270262746,0.8353167149288827,0.0,0.0,0.0,0.7640878701050621,0.6182380216383307,1.0,0.8613858613112355,0.7607673057286034,0.9926767064182808,0.4718814492225647,0.42376238107681274,0.5323283672332764
73
+ 338_UCR_id_36_Facility_tr_9000_1st_12400.csv,reconstruction_error,0.01328324383342799,0.47685556933949846,0.01725488852939351,0.5515147171873243,0.027636021041061474,0.014266029018399936,0.44,0.0,0.0,0.0,0.6705582135047956,0.5047995182449577,0.9983975593496537,0.1866743266582489,0.10343915224075317,0.9557248950004578
74
+ 339_UCR_id_37_Sensor_tr_2750_1st_5400.csv,anomaly_head,0.06358880985994252,0.8106347826086956,0.12096279292610607,0.8381266669514833,0.14396284829721362,0.08516483516483517,0.465,0.0,0.0,0.0,0.9200535306785828,0.869982683982684,0.97624,0.5269121527671814,0.6078431606292725,0.4650000035762787
75
+ 339_UCR_id_37_Sensor_tr_2750_1st_5400.csv,reconstruction_error,0.08446991503058147,0.5992453416149068,0.07413830152979878,0.6385328503575526,0.13675213675213677,0.47058823529411764,0.08,0.0,0.0,0.0,0.900377849454217,0.8334242424242424,0.9790287878787879,0.14468085765838623,0.48571428656578064,0.08500000089406967
76
+ 340_UCR_id_38_Facility_tr_32500_1st_114283.csv,anomaly_head,0.14392000241618166,0.975772961046115,0.06538076118843801,0.9905162513020714,0.20606060606060606,0.17346938775510204,0.2537313432835821,0.12488350419384903,0.06660039761431412,1.0,0.8268224071140162,0.7049121951507568,0.9997174923732126,0.22385527193546295,0.22727273404598236,0.22053909301757812
77
+ 340_UCR_id_38_Facility_tr_32500_1st_114283.csv,reconstruction_error,0.0011095353037996474,0.5672102876221761,0.002482317984696418,0.7661627336872615,0.0,0.0,0.0,0.12093862815884476,0.0643611911623439,1.0,0.669193696707725,0.5028821360936282,0.9998664384154039,0.0047045801766216755,0.002374301664531231,0.2537313401699066
78
+ 341_UCR_id_39_HumanActivity_tr_48812_1st_128430.csv,anomaly_head,8.251914444151043e-06,0.17245641470393414,1.3570465860655272e-05,0.21023642632755693,0.0,0.0,0.0,0.0,0.0,0.0,0.9097840005677686,0.8474473141938457,0.9820196943416326,2.95137597277062e-05,1.4757098142581526e-05,1.0
79
+ 341_UCR_id_39_HumanActivity_tr_48812_1st_128430.csv,reconstruction_error,2.680390264822558e-05,0.7452351523180616,6.308233647361295e-05,0.8574054454035817,0.0,0.0,0.0,5.355756098867258e-05,2.6779497616624714e-05,1.0,0.664211797990736,0.4972585951896665,0.9999385405427553,0.00010139417281607166,5.0699654821073636e-05,1.0
80
+ 342_UCR_id_40_Medical_tr_7500_1st_17000.csv,anomaly_head,0.015355463368588486,0.8418205357142858,0.016410809845367944,0.8655092396962168,0.0,0.0,0.0,0.17825311942959002,0.09784735812133072,1.0,0.671669051825016,0.5056653492418592,0.9999357777777779,0.11083540320396423,0.060414787381887436,0.6700000166893005
81
+ 342_UCR_id_40_Medical_tr_7500_1st_17000.csv,reconstruction_error,0.004557159805781352,0.449665625,0.005617174291819187,0.5413502854541091,0.0,0.0,0.0,0.4716981132075472,0.30864197530864196,1.0,0.6821318877140445,0.5181383749388155,0.9980062222222221,0.03802061825990677,0.02358490601181984,0.09801000356674194
82
+ 343_UCR_id_41_Facility_tr_14030_1st_52600.csv,anomaly_head,0.25624264524685175,0.9518293629007234,0.14983497267564938,0.9661785159455354,0.2996941896024465,0.3858267716535433,0.245,0.5361930294906166,0.3663003663003663,1.0,0.9396914680784292,0.887230410167306,0.9987464661582686,0.31735309958457947,0.4587155878543854,0.24259312450885773
83
+ 343_UCR_id_41_Facility_tr_14030_1st_52600.csv,reconstruction_error,0.05159531371698925,0.6875963168071038,0.03730085134324122,0.786869036150921,0.0,0.0,0.0,0.5006257822277848,0.333889816360601,1.0,0.8218731407775203,0.6990571779892962,0.9970414914593876,0.10595495998859406,0.1599999964237213,0.07920199632644653
84
+ 344_UCR_id_42_Sensor_tr_2851_1st_5365.csv,anomaly_head,0.004805753986181762,0.8196330991412959,0.009554441902362834,0.8775167490678083,0.012517385257301807,0.006324666198172874,0.6,0.03636363636363636,0.018518518518518517,1.0,0.8914079312165893,0.8907071887784922,0.8921098772647575,0.02621232159435749,0.013368983753025532,0.6666666865348816
85
+ 344_UCR_id_42_Sensor_tr_2851_1st_5365.csv,reconstruction_error,0.0015848134602472527,0.447423887587822,0.01047108336560216,0.7697063007537468,0.003931203931203931,0.001972872996300863,0.5333333333333333,0.0,0.0,0.0,0.7518779706422445,0.6085508093410921,0.9835184102863823,0.01328661572188139,0.006739679723978043,0.4645926058292389
86
+ 345_UCR_id_43_Facility_tr_25000_1st_44630.csv,anomaly_head,0.030138286902256152,0.8883135896749758,0.031700823664572865,0.8961283391068405,0.0,0.0,0.0,0.416,0.26262626262626265,1.0,0.8506000012437734,0.7404754171855542,0.9992030512820513,0.17014436423778534,0.09829311072826385,0.6324828863143921
87
+ 345_UCR_id_43_Facility_tr_25000_1st_44630.csv,reconstruction_error,0.003212671478348041,0.5111762314485087,0.0036402098727208007,0.5475070318389005,0.007627118644067797,0.00384,0.5538461538461539,0.0,0.0,0.0,0.7204079126509404,0.5635344147527565,0.9983126153846155,0.028811663389205933,0.014661604538559914,0.8257817029953003
88
+ 346_UCR_id_44_Medical_tr_7456_1st_17390.csv,anomaly_head,0.026174407902863458,0.35318345323741007,0.019390752156254548,0.38916774710330737,0.0,0.0,0.0,0.5485232067510548,0.37790697674418605,1.0,0.6097782498501692,0.43912687101494774,0.9973725112616485,0.10071942210197449,0.7777777910232544,0.05384615436196327
89
+ 346_UCR_id_44_Medical_tr_7456_1st_17390.csv,reconstruction_error,0.014265239251327914,0.484966795794134,0.014158910798767734,0.5104169139732232,0.0,0.0,0.0,0.5416666666666666,0.37142857142857144,1.0,0.6907835695562368,0.5290485769631947,0.9949485918641037,0.03581589460372925,0.029702970758080482,0.045096930116415024
90
+ 347_UCR_id_45_Sensor_tr_2851_1st_5365.csv,anomaly_head,0.06803591078655684,0.9765261514441841,0.08490122179091074,0.9885724521102753,0.0,0.0,0.0,0.27522935779816515,0.1595744680851064,1.0,0.9181267844382277,0.8486960545548449,0.9999298655756867,0.7407407760620117,0.8333333134651184,0.6666666865348816
91
+ 347_UCR_id_45_Sensor_tr_2851_1st_5365.csv,reconstruction_error,0.0018200482574123383,0.48087431693989074,0.01452753160083801,0.7927560260454546,0.0,0.0,0.0,0.019218449711723255,0.009702457956015523,1.0,0.7572259132099297,0.6249172024157413,0.9606078316773817,0.020333943888545036,0.01036866381764412,0.5226666927337646
92
+ 348_UCR_id_46_Facility_tr_9000_1st_12400.csv,anomaly_head,0.027162386946019863,0.5872361001466111,0.029032762193997443,0.6245592673364748,0.0,0.0,0.0,0.5856515373352855,0.4140786749482402,1.0,0.719228125032029,0.5624871352958423,0.9970683493203955,0.330635666847229,0.25879043340682983,0.4577028751373291
93
+ 348_UCR_id_46_Facility_tr_9000_1st_12400.csv,reconstruction_error,0.014793509464669688,0.5211722303672794,0.019233499014302314,0.5930012724573916,0.03227637661179142,0.016679238957338027,0.4975,0.0,0.0,0.0,0.6698749519057051,0.5040535491525595,0.9982874708344136,0.18827180564403534,0.11275337636470795,0.5701173543930054
94
+ 349_UCR_id_47_Facility_tr_29954_1st_74900.csv,anomaly_head,0.0006984660793342006,0.27944803699866694,0.001069190999163487,0.38769363023414627,0.0016586804275709546,0.0008311784263021796,0.375,0.023703703703703703,0.01199400299850075,1.0,0.7126321846545324,0.5902265108127843,0.8990930840705502,0.0033538290299475193,0.0016844469355419278,0.375
95
+ 349_UCR_id_47_Facility_tr_29954_1st_74900.csv,reconstruction_error,0.0018838544863109834,0.6005993508338068,0.0024966332921382783,0.699045999959188,0.0,0.0,0.0,0.1763085399449036,0.09667673716012085,1.0,0.6756264176407517,0.5102968141592377,0.9994285409595877,0.016194332391023636,0.013245033100247383,0.02083333395421505
96
+ 350_UCR_id_48_Facility_tr_7482_1st_23405.csv,anomaly_head,0.02899585870922633,0.950302393826995,0.031237381031770633,0.951216591156893,0.07539682539682539,0.03958333333333333,0.7916666666666666,0.0,0.0,0.0,0.5941443868123549,0.4226212426464103,1.0,0.09578099846839905,0.05121293663978577,0.7381958961486816
97
+ 350_UCR_id_48_Facility_tr_7482_1st_23405.csv,reconstruction_error,0.00500259993526844,0.5453789357127606,0.006465309418775657,0.6797216178800802,0.01951219512195122,0.011834319526627219,0.05555555555555555,0.0,0.0,0.0,0.6299169168193509,0.45980759177703645,0.9998010923525423,0.024921022355556488,0.016129031777381897,0.05478395149111748
98
+ 351_UCR_id_49_Medical_tr_7464_1st_12190.csv,anomaly_head,0.23559920045863905,0.9767547739777752,0.2510986781665996,0.978122585701894,0.4292237442922374,0.33021077283372363,0.6130434782608696,0.733652312599681,0.5793450881612091,1.0,0.8175576924874726,0.6916673250095889,0.9994716406030073,0.7713391184806824,0.7634854912757874,0.7793559432029724
99
+ 351_UCR_id_49_Medical_tr_7464_1st_12190.csv,reconstruction_error,0.010750114228851687,0.3591608391608392,0.008025787010033963,0.3773027189801322,0.023715415019762844,0.13043478260869565,0.013043478260869565,0.6764705882352942,0.5111111111111111,1.0,0.7132298801001876,0.5572389670313315,0.9905083626974188,0.0880599170923233,0.0460764579474926,0.9913232326507568
100
+ 352_UCR_id_50_HumanActivity_tr_48750_1st_110800.csv,anomaly_head,3.610238636773891e-05,0.8106106708421938,0.0011184114252921575,0.9531992381981854,0.0,0.0,0.0,7.197092374680629e-05,3.5986756873470565e-05,1.0,0.7632898763894383,0.6171965114250828,0.9999931623931624,0.00016375991981476545,8.1886668340303e-05,1.0
101
+ 352_UCR_id_50_HumanActivity_tr_48750_1st_110800.csv,reconstruction_error,3.069085105729982e-05,0.777215570704757,0.6365625425802965,0.9863545987087069,6.119951040391677e-05,3.060069157562961e-05,1.0,0.0,0.0,0.0,0.7040616259835114,0.5432853335872834,0.9999931623931624,0.00014853323227725923,7.427213131450117e-05,1.0
102
+ 353_UCR_id_51_Medical_tr_1875_1st_3198.csv,anomaly_head,0.9956695194651648,0.9998954340630075,0.987790819949307,0.9998402333563412,0.9771689497716894,0.9907407407407407,0.963963963963964,0.0,0.0,0.0,0.9999895394812143,1.0,0.9999791791791792,0.9865471124649048,0.9821428656578064,0.9909909963607788
103
+ 353_UCR_id_51_Medical_tr_1875_1st_3198.csv,reconstruction_error,0.12900267169952623,0.6741627372748158,0.11178798389805804,0.7865985873860674,0.1836734693877551,0.21176470588235294,0.16216216216216217,0.0,0.0,0.0,0.9729282850707288,0.9519555555555556,0.9948460460460461,0.2957436442375183,0.23893804848194122,0.38798364996910095
104
+ 354_UCR_id_52_Facility_tr_7482_1st_18485.csv,anomaly_head,0.045917112112793465,0.8575882157231364,0.047069163251470814,0.858935541031706,0.0,0.0,0.0,0.39436619718309857,0.24561403508771928,1.0,0.6901984326248776,0.5269719527967301,0.9999170076512052,0.1788458377122879,0.09903457015752792,0.9213775396347046
105
+ 354_UCR_id_52_Facility_tr_7482_1st_18485.csv,reconstruction_error,0.009088302304146048,0.24846123159615224,0.010916756481205206,0.3243331306103088,0.005590496156533892,0.0028797696184305254,0.09523809523809523,0.0,0.0,0.0,0.6417854467734189,0.4741406555772137,0.9928246087958101,0.0566084086894989,0.029157094657421112,0.9676143527030945
106
+ 355_UCR_id_53_HumanActivity_tr_48750_1st_143411.csv,anomaly_head,0.8773656031479573,0.9979126240164216,0.15899957222353456,0.9967060526888867,0.6963562753036437,0.5850340136054422,0.86,0.0,0.0,0.0,0.9816108995557908,0.963893179836037,0.9999922735042734,0.8673469424247742,0.8854166865348816,0.8500000238418579
107
+ 355_UCR_id_53_HumanActivity_tr_48750_1st_143411.csv,reconstruction_error,0.0013319070740071969,0.5831628463906945,0.0028200837182563807,0.7299940810075638,0.007047216349541931,0.0037907505686125853,0.05,0.12062726176115803,0.06418485237483953,1.0,0.6713448182136156,0.5052858572367326,0.9999829401709402,0.009100434370338917,0.004766031168401241,0.10048689693212509
108
+ 356_UCR_id_54_Medical_tr_7500_1st_16000.csv,anomaly_head,0.011792956531606238,0.8059375,0.016071329244701848,0.8478434620971873,0.02865329512893983,0.01583949313621964,0.15,0.0,0.0,0.0,0.7020577114346656,0.5410370518518519,0.999534,0.05383338779211044,0.028073159977793694,0.6534000039100647
109
+ 356_UCR_id_54_Medical_tr_7500_1st_16000.csv,reconstruction_error,0.0037586559083689864,0.3903941964285714,0.00525314641031484,0.5187125424905228,0.012834224598930482,0.00718562874251497,0.06,0.0,0.0,0.0,0.687613260945983,0.5245057239057239,0.9979495555555554,0.028019525110721588,0.017057569697499275,0.07840800285339355
110
+ 357_UCR_id_55_Facility_tr_12500_1st_46600.csv,anomaly_head,0.8910255980635617,0.9972550627240144,0.8389855116540438,0.9973655699638693,0.8575899843505478,0.8082595870206489,0.9133333333333333,0.0,0.0,0.0,0.9982970996747209,1.0,0.996600088888889,0.8800000548362732,0.8171428442001343,0.95333331823349
111
+ 357_UCR_id_55_Facility_tr_12500_1st_46600.csv,reconstruction_error,0.019904570164275583,0.702546505376344,0.02324846410215202,0.748651408025662,0.0,0.0,0.0,0.6179196704428425,0.44709388971684055,1.0,0.7367260781578925,0.6034117948717949,0.9456533333333335,0.06772670149803162,0.03806344047188759,0.30688759684562683
112
+ 358_UCR_id_56_Facility_tr_10500_1st_29080.csv,anomaly_head,0.007554849781827621,0.8819126378286682,0.009082346336455056,0.8873396668425101,0.022531983960282605,0.011396561715279118,0.9833333333333333,0.05163511187607573,0.026501766784452298,1.0,0.7884002104358812,0.6511061870003476,0.9990661375661376,0.02831762097775936,0.014369215816259384,0.9669444561004639
113
+ 358_UCR_id_56_Facility_tr_10500_1st_29080.csv,reconstruction_error,0.00238921829932741,0.4848388464800678,0.0028456887470044334,0.5607803200422922,0.021352313167259787,0.013574660633484163,0.05,0.0,0.0,0.0,0.8536497928380045,0.7451377556993996,0.9991534391534391,0.022140221670269966,0.014218009077012539,0.05000000074505806
114
+ 359_UCR_id_57_Medical_tr_1913_1st_3474.csv,anomaly_head,0.5834423571584035,0.945149740711225,0.6902213129863122,0.9729331390536279,0.5647058823529412,0.518918918918919,0.6193548387096774,0.0,0.0,0.0,0.9939937360532921,1.0,0.9880592905585742,0.7121036648750305,0.8703703880310059,0.6025390028953552
115
+ 359_UCR_id_57_Medical_tr_1913_1st_3474.csv,reconstruction_error,0.0792872436669375,0.6763752699721655,0.08333063777492057,0.7166006268819763,0.0,0.0,0.0,0.8516483516483516,0.7416267942583732,1.0,0.7920117668291314,0.6596664625135557,0.9907883868720185,0.29790058732032776,0.21902017295360565,0.4655797481536865
116
+ 360_UCR_id_58_Facility_tr_14030_1st_52600.csv,anomaly_head,0.23719315737286156,0.9203622920296947,0.11412683445218495,0.9315180221029392,0.2807017543859649,0.47058823529411764,0.2,0.5333333333333333,0.36363636363636365,1.0,0.9535468771315326,0.9123025615693329,0.9986971111586249,0.27873098850250244,0.47058823704719543,0.19800500571727753
117
+ 360_UCR_id_58_Facility_tr_14030_1st_52600.csv,reconstruction_error,0.05284803265997409,0.7026058052657963,0.0359477765212075,0.7908571717922233,0.0,0.0,0.0,0.4993757802746567,0.33277870216306155,1.0,0.780918911931028,0.6417981737180954,0.9970457677048441,0.10429287701845169,0.13600000739097595,0.08457499742507935
118
+ 361_UCR_id_59_Medical_tr_3000_1st_7175.csv,anomaly_head,0.810063606605279,0.9864476491359675,0.8047160214985806,0.9902445264040542,0.7821229050279329,0.9655172413793104,0.6572769953051644,0.0,0.0,0.0,0.998875578183414,1.0,0.997753781950965,0.8450610041618347,0.849056601524353,0.8411029577255249
119
+ 361_UCR_id_59_Medical_tr_3000_1st_7175.csv,reconstruction_error,0.022695345726591883,0.4702812680490973,0.03270186799205242,0.582183284782412,0.053475935828877004,0.030612244897959183,0.2112676056338028,0.0,0.0,0.0,0.6749158832500771,0.5098540547982927,0.9980174752217006,0.09393874555826187,0.06081081181764603,0.20635461807250977
120
+ 362_UCR_id_60_HumanActivity_tr_16000_1st_31200.csv,anomaly_head,0.0290678193954747,0.72955402485582,0.0309703211066247,0.7493082093487581,0.0,0.0,0.0,0.7323943661971831,0.5777777777777777,1.0,0.588332131953715,0.41690976345486114,0.9991611538461538,0.21529258787631989,0.20694445073604584,0.22434255480766296
121
+ 362_UCR_id_60_HumanActivity_tr_16000_1st_31200.csv,reconstruction_error,0.014615578316137912,0.4413826659085371,0.015236229888235446,0.4645805942892606,0.03345925526173772,0.025768911055694097,0.047692307692307694,0.7348784624081401,0.580875781948168,1.0,0.716156351433978,0.5601400641025641,0.9926363141025643,0.07809316366910934,0.040722813457250595,0.9486064910888672
outputs/hf_job_results/specialized_eval_1784687655/specialized_contextual_series.csv ADDED
The diff for this file is too large to render. See raw diff
 
outputs/hf_job_results/specialized_eval_1784687655/specialized_eval_per_series.csv ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ split,sample,model,AUC-PR,AUC-ROC,VUS-PR,VUS-ROC,Standard-F1,Standard-Precision,Standard-Recall,PA-F1,PA-Precision,PA-Recall,Affiliation-F,Affiliation-P,Affiliation-R,F1_T,Precision_T,Recall_T
2
+ point,0,TimeRCD,0.8050761421319798,0.9496723460026213,0.7716955199054049,0.9406297921233989,0.0,0.0,0.0,0.6153846153846154,0.5,0.8,0.8199114539298084,0.7710551253844705,0.8753781004234725,0.800000011920929,1.0,0.6666666865348816
3
+ point,0,Chronos,0.7346422338568936,0.8005242463958061,0.7279457479098984,0.9944200552325205,0.75,1.0,0.6,0.0,0.0,0.0,0.9515536789264127,0.9079736214881348,0.9995281906109931,0.761904776096344,0.6666666865348816,0.8888888955116272
4
+ point,1,TimeRCD,0.995949898428354,0.999276078573318,0.9997510579201976,0.9999646721338459,0.9727272727272728,0.963963963963964,0.981651376146789,0.0,0.0,0.0,0.9992797088772211,1.0,0.9985605545022269,0.9566486477851868,0.9639639854431152,0.9494433999061584
5
+ point,1,Chronos,0.12184683556347284,0.4520610878311593,0.1845454222672983,0.6083032632400712,0.0,0.0,0.0,0.6302250803858521,0.48514851485148514,0.8990825688073395,0.604818718342172,0.5177928916191312,0.7270075153800002,0.2608526647090912,0.151162788271904,0.9507701992988586
6
+ point,2,TimeRCD,0.9984657499363382,0.9998489165155832,0.9999221483265324,0.9999950195440618,0.0,0.0,0.0,1.0,1.0,1.0,0.9999699433985502,1.0,0.9999399885978336,0.9838709831237793,1.0,0.9682539701461792
7
+ point,2,Chronos,0.512617988767567,0.8197574030907364,0.680295869339291,0.9402684801483214,0.5567010309278351,0.8709677419354839,0.4090909090909091,0.0,0.0,0.0,0.9900618716731279,0.9961904761904762,0.9840083117142392,0.6809036135673523,0.8999999761581421,0.5475965142250061
8
+ point,3,TimeRCD,0.9959899490402918,0.9996739566613162,0.9998120012672704,0.999989154710002,0.972972972972973,0.9818181818181818,0.9642857142857143,0.0,0.0,0.0,0.9995336806686225,1.0,0.9990678959487511,0.9572649598121643,0.9180327653884888,1.0
9
+ point,3,Chronos,0.17113045595228527,0.43243378812199035,0.2604842023256127,0.5730471552630404,0.16129032258064516,0.8333333333333334,0.08928571428571429,0.0,0.0,0.0,0.6646497939856627,0.9957872564507636,0.4987847855146433,0.4130997955799103,0.28333333134651184,0.7621756792068481
10
+ point,4,TimeRCD,0.839953802543458,0.7990207691700228,0.8662764921603904,0.8615483919626339,0.8753462603878116,0.9875,0.7860696517412935,0.8802228412256268,1.0,0.7860696517412935,0.7999352432244954,1.0,0.6665767982116177,0.7969349026679993,1.0,0.662420392036438
11
+ point,4,Chronos,0.339086151913916,0.5422622338045224,0.5265245221262767,0.6967139353446431,0.0,0.0,0.0,0.9901477832512315,0.9804878048780488,1.0,0.9284747692270792,0.901221315778508,0.9574280498217692,0.5692654252052307,0.6000000238418579,0.5415261387825012
12
+ point,5,TimeRCD,0.9991581425719602,0.9998852835136022,0.999913824369329,0.9999920747443407,0.9834254143646409,0.978021978021978,0.9888888888888889,0.0,0.0,0.0,0.9999348415945075,1.0,0.9998697916666667,0.9834253787994385,0.9780219793319702,0.9888888597488403
13
+ point,5,Chronos,0.10165921966498559,0.43702064896755166,0.13530543301786754,0.5515355557962213,0.18220338983050846,0.112565445026178,0.4777777777777778,0.0,0.0,0.0,0.52346062895643,0.3552489177489178,0.9942346643518519,0.5333634614944458,0.5930232405662537,0.48461028933525085
14
+ point,6,TimeRCD,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.2222222222222222,0.125,1.0,0.9999999500000026,1.0,1.0,1.0,1.0,1.0
15
+ point,6,Chronos,0.058823529411764705,0.9791395045632334,0.053573246983040904,0.9780561793210366,0.1111111111111111,0.058823529411764705,1.0,0.0,0.0,0.0,0.7579095860042807,0.6101888020833333,1.0,0.125,0.06666667014360428,1.0
16
+ point,7,TimeRCD,0.9732339799290263,0.9992987824313125,0.9988453321671497,0.9999761881287179,0.0,0.0,0.0,1.0,1.0,1.0,0.9993401451755223,0.9988594240091246,0.9998214293744572,0.9405940771102905,0.9090909361839294,0.9743589758872986
17
+ point,7,Chronos,0.07221320857522351,0.6694715369414165,0.23961560359742323,0.7922894829956382,0.0,0.0,0.0,0.38095238095238093,0.38095238095238093,0.38095238095238093,0.7704676765336951,0.7610218892758417,0.7801509950809677,0.2857142686843872,0.25,0.3333333432674408
18
+ point,8,TimeRCD,0.9166666666666666,0.9995642701525055,0.9913562407782859,0.9999773948941433,0.8571428571428571,0.75,1.0,0.0,0.0,0.0,0.999740546627762,1.0,0.9994813278008299,0.8571428656578064,0.75,1.0
19
+ point,8,Chronos,0.6705426356589147,0.8888888888888888,0.6682912007316087,0.9896564407016957,0.0,0.0,0.0,0.5,0.3333333333333333,1.0,0.999740546627762,1.0,0.9994813278008299,0.8571428656578064,1.0,0.75
20
+ point,9,TimeRCD,0.9954247595750714,0.9991234762283507,0.9998213922512511,0.9999752089197151,0.0,0.0,0.0,1.0,1.0,1.0,0.9991817754520314,1.0,0.9983649886286804,0.9764238595962524,0.957446813583374,0.9961685538291931
21
+ point,9,Chronos,0.2124409313009642,0.5465288035450517,0.36844233794723,0.7400406006422515,0.24427480916030533,0.4,0.17582417582417584,0.0,0.0,0.0,0.9210530984239286,0.8671539132361393,0.9820968303726924,0.6139988303184509,0.6470588445663452,0.5841528177261353
22
+ contextual,0,TimeRCD,0.0176352056391719,0.062449528936742944,0.027758103964324765,0.1968503540083166,0.0,0.0,0.0,0.0,0.0,0.0,0.31329858640209685,0.1986511752136752,0.7408854166666667,0.06060286983847618,0.03133159130811691,0.9215999841690063
23
+ contextual,0,Chronos,0.10215280868572828,0.7495020188425303,0.1442582838747418,0.8608756820771183,0.23655913978494625,0.16176470588235295,0.44,0.0,0.0,0.0,0.7537310553394293,0.6062665052816901,0.9959895833333334,0.26336944103240967,0.1875,0.4423680007457733
24
+ contextual,1,TimeRCD,0.03619993793147987,0.5755585464333782,0.12280583670162393,0.7627409618627452,0.08994708994708994,0.04815864022662889,0.68,0.3067484662576687,0.18115942028985507,1.0,0.8950787920873989,0.8640793010752689,0.9283854166666667,0.16190476715564728,0.09189189225435257,0.6800000071525574
25
+ contextual,1,Chronos,0.025583343752924377,0.3693135935397039,0.09400438199388447,0.7087940903374267,0.05,0.02962962962962963,0.16,0.0,0.0,0.0,0.8808588438162411,0.8802083333333334,0.8815104166666667,0.20233479142189026,0.1304347813129425,0.45086848735809326
26
+ contextual,2,TimeRCD,0.9996415770609318,0.9999508357915438,0.9999708488045391,0.9999977661743309,0.0,0.0,0.0,1.0,1.0,1.0,0.999992716151378,1.0,0.9999855324074075,0.9944133758544922,1.0,0.9888888597488403
27
+ contextual,2,Chronos,0.7324512912400782,0.8526712553261226,0.7663316853735471,0.9154519456319293,0.6878980891719745,0.8059701492537313,0.6,0.0,0.0,0.0,0.9993122667686387,1.0,0.9986255787037036,0.725011944770813,0.791208803653717,0.6690366864204407
28
+ contextual,3,TimeRCD,0.9995022449025344,0.9998952903946389,0.9999751410708944,0.9999957212631977,0.0,0.0,0.0,1.0,1.0,1.0,0.9998060360259888,1.0,0.9996122472426471,0.9963369965553284,0.9927007555961609,1.0
29
+ contextual,3,Chronos,0.18435255257862493,0.4824320551005212,0.23399974920193062,0.5764549770982643,0.25440313111545987,0.17333333333333334,0.47794117647058826,0.0,0.0,0.0,0.9351330738627119,1.0,0.8781690410539217,0.4556609094142914,0.304964542388916,0.9007718563079834
30
+ contextual,4,TimeRCD,0.050086792837220444,0.6940511440107672,0.08934079487995501,0.777128662075513,0.14201183431952663,0.07667731629392971,0.96,0.0,0.0,0.0,0.733127028762851,0.5883556547619049,0.9723958333333335,0.16268888115882874,0.08921933174133301,0.9215999841690063
31
+ contextual,4,Chronos,0.04474960634079367,0.5556393001345895,0.1508198708258697,0.7884986575588383,0.0,0.0,0.0,0.8333333333333334,0.7142857142857143,1.0,0.9667963865881285,0.9661458333333334,0.9674479166666667,0.14972899854183197,0.08530806005001068,0.611529529094696
32
+ contextual,5,TimeRCD,0.1485735091626955,0.8716141001855289,0.20621994658472098,0.9101243554917164,0.27419354838709675,0.18681318681318682,0.5151515151515151,0.0,0.0,0.0,0.7992691004724112,0.6667934929653679,0.9974352904040404,0.2693864405155182,0.16352201998233795,0.7640036940574646
33
+ contextual,5,Chronos,0.035296420779356796,0.4023500309214595,0.11439450821738721,0.6878145095488943,0.0,0.0,0.0,0.5892857142857143,0.4177215189873418,1.0,0.8300452839917773,0.7220703125,0.9759903724747476,0.08778773248195648,0.046043165028095245,0.9403122067451477
34
+ contextual,6,TimeRCD,0.9887361350404829,0.9996231493943472,0.9989785353675499,0.999975200753644,0.9615384615384616,0.9259259259259259,1.0,0.0,0.0,0.0,0.9993484842019781,1.0,0.9986979166666667,0.9615384340286255,0.9259259104728699,1.0
35
+ contextual,6,Chronos,0.10905033678964669,0.8015612382234186,0.20961243395369722,0.9108017697179801,0.29906542056074764,0.1951219512195122,0.64,0.0,0.0,0.0,0.81526728170711,0.7159288194444445,0.9466145833333333,0.6243047118186951,0.695652186870575,0.5662310123443604
36
+ contextual,7,TimeRCD,0.9338488507065357,0.9969851951547779,0.9917417941693878,0.999704905467884,0.0,0.0,0.0,1.0,1.0,1.0,0.9990615702690487,1.0,0.998125,0.8695652484893799,0.9523809552192688,0.800000011920929
37
+ contextual,7,Chronos,0.2575475451153759,0.777550471063257,0.5412904960991417,0.940036423819872,0.0,0.0,0.0,0.9259259259259259,0.8620689655172413,1.0,0.9919671889384942,1.0,0.9840625,0.5173407196998596,0.5909090638160706,0.460062712430954
38
+ contextual,8,TimeRCD,0.9983755488618768,0.9998745987158908,0.9998947687150962,0.9999939038637562,0.0,0.0,0.0,1.0,1.0,1.0,0.9997092219005543,1.0,0.999418712797619,0.991150438785553,0.9824561476707458,1.0
39
+ contextual,8,Chronos,0.16245738019126307,0.6070926966292134,0.2671680842573687,0.7808231812533553,0.0,0.0,0.0,0.9572649572649573,0.9180327868852459,1.0,0.9635502145529423,1.0,0.9296642485119048,0.3076621890068054,0.25471699237823486,0.38839325308799744
40
+ contextual,9,TimeRCD,0.9822942137974444,0.997600569244262,0.9974917993926581,0.9996884021398693,0.9270833333333334,0.8640776699029126,1.0,0.0,0.0,0.0,0.9973343120300535,0.9984163851351351,0.9962546816479402,0.9270833730697632,0.8640776872634888,1.0
41
+ contextual,9,Chronos,0.10625186040758683,0.4655888534030548,0.16095921662527046,0.5983451453070321,0.0,0.0,0.0,0.8557692307692307,0.7478991596638656,1.0,0.7957841676879633,0.720703125,0.8883280664794008,0.33856791257858276,0.2078239619731903,0.9128503203392029
outputs/hf_job_results/specialized_eval_1784687655/specialized_eval_summary.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "generation": {
3
+ "target_per_split": 10,
4
+ "max_candidates": 20000,
5
+ "seen_candidates": 256,
6
+ "seq_len": 768,
7
+ "counts": {
8
+ "point": 10,
9
+ "contextual": 10
10
+ },
11
+ "seed": 20260722
12
+ },
13
+ "chronos_error": null,
14
+ "elapsed_seconds": 94.21,
15
+ "metrics": {
16
+ "contextual/Chronos": {
17
+ "n": 10,
18
+ "Affiliation-F": 0.8932445763253437,
19
+ "F1_T": 0.36717693507671356,
20
+ "Standard-F1": 0.15279257806331284,
21
+ "VUS-PR": 0.2682838710422839
22
+ },
23
+ "contextual/TimeRCD": {
24
+ "n": 10,
25
+ "Affiliation-F": 0.8736025848303759,
26
+ "F1_T": 0.6394670825451613,
27
+ "Standard-F1": 0.23947742675255085,
28
+ "VUS-PR": 0.6434177569650751
29
+ },
30
+ "point/Chronos": {
31
+ "n": 10,
32
+ "Affiliation-F": 0.8112190368700551,
33
+ "F1_T": 0.5101245701313019,
34
+ "Standard-F1": 0.20055806636104054,
35
+ "VUS-PR": 0.38450235862455473
36
+ },
37
+ "point/TimeRCD": {
38
+ "n": 10,
39
+ "Affiliation-F": 0.9616827288948524,
40
+ "F1_T": 0.9252305686473846,
41
+ "Standard-F1": 0.4661614777595555,
42
+ "VUS-PR": 0.9627394009145812
43
+ }
44
+ }
45
+ }
outputs/hf_job_results/specialized_eval_1784687655/specialized_generation_summary.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "target_per_split": 10,
3
+ "max_candidates": 20000,
4
+ "seen_candidates": 256,
5
+ "seq_len": 768,
6
+ "counts": {
7
+ "point": 10,
8
+ "contextual": 10
9
+ },
10
+ "seed": 20260722
11
+ }
outputs/hf_job_results/specialized_eval_1784687655/specialized_point_series.csv ADDED
The diff for this file is too large to render. See raw diff
 
poster_embed.html ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <meta charset="utf-8">
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ <title>TimeRCD Reproduction Poster</title>
6
+ <style>
7
+ :root {
8
+ --accent: #5f2878;
9
+ --accent-deep: #321444;
10
+ --accent-soft: #eee4f3;
11
+ --emph: #2d5f3e;
12
+ --emph-soft: #e4f0e8;
13
+ --ink: #172033;
14
+ --muted: #5e687a;
15
+ --line: #d8deea;
16
+ --paper: #fbfbfd;
17
+ --card: #ffffff;
18
+ }
19
+ * { box-sizing: border-box; }
20
+ body { margin: 0; background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
21
+ .poster { width: min(1200px, 100vw); aspect-ratio: 5 / 3; margin: 0 auto; padding: 28px; display: grid; grid-template-rows: auto 1fr auto; gap: 18px; background: linear-gradient(180deg, #fff 0%, #f7f4fa 100%); border: 1px solid var(--line); }
22
+ header { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: end; border-bottom: 4px solid var(--accent); padding-bottom: 12px; }
23
+ h1 { margin: 0; font-size: clamp(28px, 3.1vw, 48px); line-height: 1.02; letter-spacing: 0; color: var(--accent-deep); }
24
+ .subtitle { margin-top: 8px; color: var(--muted); font-size: clamp(13px, 1.35vw, 18px); }
25
+ .badge { background: var(--accent); color: white; padding: 10px 12px; border-radius: 6px; font-weight: 800; text-align: center; min-width: 132px; }
26
+ main { display: grid; grid-template-columns: 1.15fr 1fr 1fr 1fr; gap: 14px; min-height: 0; }
27
+ section { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 12px 26px rgba(35, 26, 48, 0.08); position: relative; }
28
+ section[data-logbook-target]::after { content: "Open details ↗"; position: absolute; top: 10px; right: 10px; font-size: 11px; background: var(--accent-soft); color: var(--accent-deep); border: 1px solid #dac8e7; padding: 4px 7px; border-radius: 999px; }
29
+ h2 { margin: 0; color: var(--accent); font-size: clamp(16px, 1.55vw, 22px); line-height: 1.1; }
30
+ p, li { font-size: clamp(12px, 1.1vw, 16px); line-height: 1.34; margin: 0; }
31
+ ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
32
+ .statgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
33
+ .stat { background: var(--accent-soft); border: 1px solid #dac8e7; border-radius: 6px; padding: 10px; min-height: 68px; display: flex; flex-direction: column; justify-content: center; }
34
+ .num { font-size: clamp(21px, 2.2vw, 34px); line-height: 1; color: var(--accent-deep); font-weight: 900; white-space: nowrap; }
35
+ .lab { font-size: 11px; color: var(--muted); margin-top: 4px; }
36
+ .warn { background: #fff3df; border-color: #edd4a7; }
37
+ .ok { background: var(--emph-soft); border-color: #bdd7c5; }
38
+ .mini { width: 100%; border-collapse: collapse; font-size: clamp(11px, 1vw, 14px); }
39
+ .mini th, .mini td { border-top: 1px solid var(--line); padding: 6px 4px; text-align: left; }
40
+ .mini th { color: var(--muted); font-weight: 700; }
41
+ footer { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
42
+ a { color: inherit; text-decoration: none; }
43
+ section[data-logbook-target]:hover { outline: 3px solid rgba(95, 40, 120, 0.22); }
44
+ </style>
45
+ <div class="poster">
46
+ <header data-logbook-target="executive-summary">
47
+ <div>
48
+ <h1>TimeRCD Zero-Shot TSAD Reproduction</h1>
49
+ <div class="subtitle">Evidence logbook for Relative Context Discrepancy, synthetic pretraining, and reported benchmark claims.</div>
50
+ </div>
51
+ <div class="badge">ICML 2026<br>paper #12052</div>
52
+ </header>
53
+ <main>
54
+ <section data-logbook-target="claim-1-claim-1">
55
+ <h2>Reported rankings changed from the prompt</h2>
56
+ <div class="statgrid">
57
+ <div class="stat warn"><div class="num">38 / 14</div><div class="lab">current paper zero-shot first / second, 64 cases</div></div>
58
+ <div class="stat warn"><div class="num">41 / 6</div><div class="lab">prompt claim, 56 cases</div></div>
59
+ <div class="stat warn"><div class="num">35 / 3</div><div class="lab">current paper full-shot first / second</div></div>
60
+ <div class="stat warn"><div class="num">28</div><div class="lab">prompt full-shot first claim</div></div>
61
+ </div>
62
+ <p>The extracted camera-ready paper text does not match the user-supplied ranking counts, so the ranking claims are partially supported only for the current-paper version.</p>
63
+ </section>
64
+ <section data-logbook-target="claim-3-claim-3">
65
+ <h2>Mechanism verified in released code</h2>
66
+ <ul>
67
+ <li>8-layer, 8-head Transformer-style encoder with RoPE.</li>
68
+ <li>Separate reconstruction and anomaly heads are present.</li>
69
+ <li>Zero-shot wrapper returns anomaly logits, not reconstruction error alone.</li>
70
+ </ul>
71
+ <table class="mini">
72
+ <tr><th>Head</th><th>Loss</th></tr>
73
+ <tr><td>reconstruction</td><td>MSE</td></tr>
74
+ <tr><td>anomaly</td><td>cross entropy</td></tr>
75
+ </table>
76
+ </section>
77
+ <section data-logbook-target="claim-4-claim-4">
78
+ <h2>Generator stages present</h2>
79
+ <ul>
80
+ <li>Univariate templates with trend, seasonality, noise, and local changes.</li>
81
+ <li>Multivariate DAG sampling with ARX-style parent dynamics.</li>
82
+ <li>Endogenous/exogenous anomaly paths and token-level labels.</li>
83
+ </ul>
84
+ <div class="stat ok"><div class="num">15,360</div><div class="lab">local generated public-code points; T4 job generated 34,816</div></div>
85
+ </section>
86
+ <section data-logbook-target="claim-6-claim-6">
87
+ <h2>Reduced cloud cross-check</h2>
88
+ <p>A T4 Hugging Face Job cloned the public repos, generated official synthetic samples, and ran a transparent contextual-anomaly proxy.</p>
89
+ <div class="statgrid">
90
+ <div class="stat ok"><div class="num">65.8k/s</div><div class="lab">T4 generator throughput</div></div>
91
+ <div class="stat ok"><div class="num">0.134</div><div class="lab">toy RCD proxy F1</div></div>
92
+ </div>
93
+ <p>The proxy favors relative context over one-step reconstruction, but it is not a substitute for the released checkpoint benchmark.</p>
94
+ </section>
95
+ </main>
96
+ <footer>
97
+ <span>Assets: thu-sail-lab/Time-RCD, thu-sail-lab/TSAD_dataset_gen_public, thu-sail-lab/Time_RCD Space</span>
98
+ <span>Bundle: scripts, logs, generated CSV/JSON/HTML, paper PDF/text</span>
99
+ </footer>
100
+ </div>
101
+ </html>
scripts/__pycache__/hf_full_table1_eval.cpython-38.pyc ADDED
Binary file (10 kB). View file
 
scripts/__pycache__/hf_recon_vs_head_ucr.cpython-38.pyc ADDED
Binary file (7.3 kB). View file
 
scripts/__pycache__/hf_reduced_ablation_train.cpython-38.pyc ADDED
Binary file (16.1 kB). View file
 
scripts/__pycache__/hf_specialized_context_eval.cpython-38.pyc ADDED
Binary file (10.7 kB). View file
 
scripts/hf_full_table1_eval.py ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Full released-checkpoint TimeRCD Table 1 reproduction on HF Jobs.
3
+
4
+ This job downloads the official Time-RCD repository, TSB-AD-U/M datasets,
5
+ released checkpoints, runs the authors' main.py protocol for uni and multi, and
6
+ uploads the resulting CSVs/comparison tables to a public HF dataset.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import json
12
+ import os
13
+ import re
14
+ import shutil
15
+ import subprocess
16
+ import sys
17
+ import time
18
+ import urllib.request
19
+ import zipfile
20
+ from pathlib import Path
21
+
22
+ import pandas as pd
23
+
24
+
25
+ OUT_REPO = os.environ.get("OUT_REPO", "Srishti280992/timercd-full-eval")
26
+ ARXIV_HTML = "https://arxiv.org/html/2509.21190v5"
27
+
28
+
29
+ def run(cmd: list[str], cwd: Path | None = None, log_path: Path | None = None) -> None:
30
+ print("$", " ".join(cmd), flush=True)
31
+ with subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1) as proc:
32
+ assert proc.stdout is not None
33
+ with (log_path.open("a", encoding="utf-8") if log_path else open(os.devnull, "w")) as log:
34
+ for line in proc.stdout:
35
+ print(line, end="", flush=True)
36
+ log.write(line)
37
+ code = proc.wait()
38
+ if code:
39
+ raise subprocess.CalledProcessError(code, cmd)
40
+
41
+
42
+ def download(url: str, path: Path) -> None:
43
+ path.parent.mkdir(parents=True, exist_ok=True)
44
+ req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
45
+ with urllib.request.urlopen(req, timeout=120) as response, path.open("wb") as fh:
46
+ shutil.copyfileobj(response, fh)
47
+
48
+
49
+ def unpack_single_root(zip_path: Path, dest: Path) -> Path:
50
+ with zipfile.ZipFile(zip_path) as zf:
51
+ zf.extractall(dest)
52
+ roots = [p for p in dest.iterdir() if p.is_dir()]
53
+ if len(roots) != 1:
54
+ raise RuntimeError(f"expected one root in {dest}, got {roots}")
55
+ return roots[0]
56
+
57
+
58
+ def patch_repo_imports(repo: Path) -> None:
59
+ """Make the downloaded repo runnable as its documented top-level script.
60
+
61
+ The current GitHub tree uses a few package-relative imports even though
62
+ README/main.py usage invokes files as scripts. We patch only import lines in
63
+ the job's disposable checkout; model/evaluation logic is untouched.
64
+ """
65
+ replacements = {
66
+ "from .evaluation.metrics": "from evaluation.metrics",
67
+ "from .utils.slidingWindows": "from utils.slidingWindows",
68
+ "from .model_wrapper": "from model_wrapper",
69
+ "from .HP_list": "from HP_list",
70
+ "from .models": "from models",
71
+ "from ..utils.dataset": "from utils.dataset",
72
+ "from ..utils.utility": "from utils.utility",
73
+ "from ..utils.torch_utility": "from utils.torch_utility",
74
+ "from ..utils.stat_models": "from utils.stat_models",
75
+ }
76
+ for path in repo.rglob("*.py"):
77
+ text = path.read_text(encoding="utf-8")
78
+ new = text
79
+ for old, repl in replacements.items():
80
+ new = new.replace(old, repl)
81
+ if new != text:
82
+ path.write_text(new, encoding="utf-8")
83
+
84
+
85
+ def get_dataset_name(filename: str) -> str:
86
+ match = re.match(r"\d+_([^_]+)_", filename)
87
+ if not match:
88
+ return filename.split("_")[0]
89
+ return match.group(1)
90
+
91
+
92
+ def normalize_table(df: pd.DataFrame) -> tuple[pd.DataFrame, list[str]]:
93
+ datasets = [str(x).strip() for x in df.iloc[1, 2:-2].tolist()]
94
+ rows = []
95
+ section = None
96
+ for _, row in df.iloc[2:].iterrows():
97
+ values = row.tolist()
98
+ cells = [str(v).strip() for v in values]
99
+ if len(set(cells)) == 1:
100
+ section = cells[0]
101
+ continue
102
+ metric, model = str(values[0]).strip(), str(values[1]).strip()
103
+ if "Grand Total" in metric or model.lower() == "nan":
104
+ continue
105
+ record = {"section": section or "", "metric": metric, "model": model}
106
+ for dataset, value in zip(datasets, values[2:-2]):
107
+ record[dataset] = value
108
+ rows.append(record)
109
+ return pd.DataFrame(rows), datasets
110
+
111
+
112
+ def pick_table(tables: list[pd.DataFrame]) -> pd.DataFrame:
113
+ for table in tables:
114
+ text = " ".join(table.astype(str).fillna("").values.ravel().tolist())
115
+ if "TimeRCD" in text and "Grand Total" in text and "Zero-Shot" in text:
116
+ return table
117
+ raise RuntimeError("Table 1 not found")
118
+
119
+
120
+ def parse_num(x: object) -> float | None:
121
+ match = re.search(r"-?\d+(?:\.\d+)?", str(x).replace("*", "").replace("∗", ""))
122
+ return float(match.group()) if match else None
123
+
124
+
125
+ def paper_timercd_values() -> dict[tuple[str, str], float]:
126
+ table, datasets = normalize_table(pick_table(pd.read_html(ARXIV_HTML)))
127
+ out = {}
128
+ for _, row in table[table["model"].eq("TimeRCD")].iterrows():
129
+ metric = str(row["metric"]).strip()
130
+ if metric not in {"Aff-F", "F1-T", "Std-F1", "VUS-PR"}:
131
+ continue
132
+ for dataset in datasets:
133
+ value = parse_num(row[dataset])
134
+ if value is not None:
135
+ out[(dataset, metric)] = value
136
+ return out
137
+
138
+
139
+ def aggregate(csv_path: Path, mode: str, out_dir: Path) -> pd.DataFrame:
140
+ df = pd.read_csv(csv_path)
141
+ df["dataset"] = df["filename"].map(get_dataset_name)
142
+ metric_map = {
143
+ "Aff-F": "Affiliation-F",
144
+ "F1-T": "F1_T",
145
+ "Std-F1": "Standard-F1",
146
+ "VUS-PR": "VUS-PR",
147
+ }
148
+ rows = []
149
+ for dataset, part in df.groupby("dataset"):
150
+ for paper_metric, col in metric_map.items():
151
+ if col in part:
152
+ rows.append(
153
+ {
154
+ "mode": mode,
155
+ "dataset": dataset,
156
+ "metric": paper_metric,
157
+ "ours_x100": float(part[col].mean() * 100.0),
158
+ "n_files": int(len(part)),
159
+ }
160
+ )
161
+ agg = pd.DataFrame(rows)
162
+ agg.to_csv(out_dir / f"{mode}_timercd_aggregated.csv", index=False)
163
+ return agg
164
+
165
+
166
+ def main() -> None:
167
+ started = time.time()
168
+ work = Path.cwd() / "timercd_full_eval_work"
169
+ out = Path.cwd() / "timercd_full_eval_outputs"
170
+ if work.exists():
171
+ shutil.rmtree(work)
172
+ if out.exists():
173
+ shutil.rmtree(out)
174
+ work.mkdir()
175
+ out.mkdir()
176
+
177
+ print("Python", sys.version)
178
+ try:
179
+ run(["nvidia-smi"], log_path=out / "nvidia-smi.log")
180
+ except Exception as exc:
181
+ print(f"nvidia-smi failed: {exc}")
182
+
183
+ code_zip = work / "time_rcd.zip"
184
+ download("https://github.com/thu-sail-lab/Time-RCD/archive/refs/heads/main.zip", code_zip)
185
+ repo = unpack_single_root(code_zip, work / "code")
186
+ patch_repo_imports(repo)
187
+
188
+ # Download datasets with a browser UA; HEAD is forbidden by this host.
189
+ ds = repo / "datasets"
190
+ ds.mkdir(exist_ok=True)
191
+ for name in ["TSB-AD-U", "TSB-AD-M"]:
192
+ zip_path = ds / f"{name}.zip"
193
+ download(f"https://www.thedatum.org/datasets/{name}.zip", zip_path)
194
+ with zipfile.ZipFile(zip_path) as zf:
195
+ zf.extractall(ds)
196
+ zip_path.unlink()
197
+
198
+ legacy_ds = repo / "TSB_AD_Time_RCD" / "datasets"
199
+ legacy_ds.mkdir(parents=True, exist_ok=True)
200
+ for name in ["TSB-AD-U", "TSB-AD-M"]:
201
+ target = ds / name
202
+ link = legacy_ds / name
203
+ if not link.exists():
204
+ try:
205
+ os.symlink(target, link, target_is_directory=True)
206
+ except OSError:
207
+ shutil.copytree(target, link)
208
+
209
+ from huggingface_hub import HfApi, snapshot_download
210
+
211
+ snapshot_download(
212
+ "thu-sail-lab/Time-RCD",
213
+ local_dir=repo,
214
+ allow_patterns=["best_model/pretrain_checkpoint_best_uni.pth", "best_model/pretrain_checkpoint_best_multi.pth"],
215
+ token=os.environ.get("HF_TOKEN"),
216
+ )
217
+ legacy_ckpt = repo / "TSB_AD_Time_RCD" / "checkpoints"
218
+ legacy_ckpt.mkdir(parents=True, exist_ok=True)
219
+ ckpt_links = {
220
+ "full_mask_anomaly_head_pretrain_checkpoint_best.pth": repo / "best_model" / "pretrain_checkpoint_best_uni.pth",
221
+ "full_mask_anomaly_head_pretrain_checkpoint_best_multi.pth": repo / "best_model" / "pretrain_checkpoint_best_multi.pth",
222
+ }
223
+ for name, target in ckpt_links.items():
224
+ link = legacy_ckpt / name
225
+ if not link.exists():
226
+ try:
227
+ os.symlink(target, link)
228
+ except OSError:
229
+ shutil.copy2(target, link)
230
+
231
+ for mode in ["uni", "multi"]:
232
+ log = out / f"{mode}_main.log"
233
+ run(
234
+ [
235
+ sys.executable,
236
+ "main.py",
237
+ "--mode",
238
+ mode,
239
+ ],
240
+ cwd=repo,
241
+ log_path=log,
242
+ )
243
+ for pattern in [f"{'Uni' if mode == 'uni' else 'Multi'}_Time_RCD_v4*.csv"]:
244
+ for path in repo.glob(pattern):
245
+ shutil.copy2(path, out / path.name)
246
+
247
+ all_aggs = []
248
+ uni_csv = out / "Uni_Time_RCD_v4.csv"
249
+ multi_csv = out / "Multi_Time_RCD_v4.csv"
250
+ if uni_csv.exists():
251
+ all_aggs.append(aggregate(uni_csv, "uni", out))
252
+ if multi_csv.exists():
253
+ all_aggs.append(aggregate(multi_csv, "multi", out))
254
+
255
+ paper = paper_timercd_values()
256
+ if all_aggs:
257
+ combined = pd.concat(all_aggs, ignore_index=True)
258
+ combined["paper_x100"] = [paper.get((r.dataset, r.metric)) for r in combined.itertuples()]
259
+ combined["abs_diff"] = (combined["ours_x100"] - combined["paper_x100"]).abs()
260
+ combined.to_csv(out / "table1_timercd_comparison.csv", index=False)
261
+ summary = {
262
+ "rows": int(len(combined)),
263
+ "files_uni": int(pd.read_csv(uni_csv).shape[0]) if uni_csv.exists() else 0,
264
+ "files_multi": int(pd.read_csv(multi_csv).shape[0]) if multi_csv.exists() else 0,
265
+ "mean_abs_diff_by_metric": combined.groupby("metric")["abs_diff"].mean().round(4).to_dict(),
266
+ "max_abs_diff_by_metric": combined.groupby("metric")["abs_diff"].max().round(4).to_dict(),
267
+ "elapsed_seconds": round(time.time() - started, 2),
268
+ }
269
+ else:
270
+ summary = {"error": "no aggregate CSVs created", "elapsed_seconds": round(time.time() - started, 2)}
271
+ (out / "summary.json").write_text(json.dumps(summary, indent=2), encoding="utf-8")
272
+ print("FULL_TABLE1_SUMMARY_START")
273
+ print(json.dumps(summary, indent=2))
274
+ print("FULL_TABLE1_SUMMARY_END")
275
+
276
+ api = HfApi(token=os.environ.get("HF_TOKEN"))
277
+ api.create_repo(OUT_REPO, repo_type="dataset", exist_ok=True)
278
+ api.upload_folder(
279
+ repo_id=OUT_REPO,
280
+ repo_type="dataset",
281
+ folder_path=str(out),
282
+ path_in_repo=f"full_table1_{int(started)}",
283
+ )
284
+ print(f"uploaded to https://huggingface.co/datasets/{OUT_REPO}")
285
+
286
+
287
+ if __name__ == "__main__":
288
+ main()
scripts/hf_recon_vs_head_ucr.py ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """HF Job: anomaly-head vs reconstruction-error readout on all UCR files."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import json
7
+ import os
8
+ import re
9
+ import shutil
10
+ import subprocess
11
+ import sys
12
+ import time
13
+ import urllib.request
14
+ import zipfile
15
+ from pathlib import Path
16
+
17
+ import numpy as np
18
+ import pandas as pd
19
+ import torch
20
+ import torch.nn.functional as F
21
+ from torch.utils.data import DataLoader
22
+
23
+
24
+ OUT_REPO = os.environ.get("OUT_REPO", "Srishti280992/timercd-full-eval")
25
+ MAX_FILES = int(os.environ.get("MAX_FILES", "60"))
26
+
27
+
28
+ def run(cmd: list[str], cwd: Path | None = None) -> None:
29
+ print("$", " ".join(cmd), flush=True)
30
+ subprocess.run(cmd, cwd=cwd, check=True)
31
+
32
+
33
+ def download(url: str, path: Path) -> None:
34
+ req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
35
+ path.parent.mkdir(parents=True, exist_ok=True)
36
+ with urllib.request.urlopen(req, timeout=120) as response, path.open("wb") as fh:
37
+ shutil.copyfileobj(response, fh)
38
+
39
+
40
+ def unpack_single_root(zip_path: Path, dest: Path) -> Path:
41
+ with zipfile.ZipFile(zip_path) as zf:
42
+ zf.extractall(dest)
43
+ roots = [p for p in dest.iterdir() if p.is_dir()]
44
+ if len(roots) != 1:
45
+ raise RuntimeError(f"expected one root in {dest}, got {roots}")
46
+ return roots[0]
47
+
48
+
49
+ def patch_repo_imports(repo: Path) -> None:
50
+ replacements = {
51
+ "from .evaluation.metrics": "from evaluation.metrics",
52
+ "from .utils.slidingWindows": "from utils.slidingWindows",
53
+ "from .model_wrapper": "from model_wrapper",
54
+ "from .HP_list": "from HP_list",
55
+ "from ..utils.dataset": "from utils.dataset",
56
+ "from ..utils.utility": "from utils.utility",
57
+ "from ..utils.torch_utility": "from utils.torch_utility",
58
+ "from ..utils.stat_models": "from utils.stat_models",
59
+ }
60
+ for path in repo.rglob("*.py"):
61
+ text = path.read_text(encoding="utf-8")
62
+ new = text
63
+ for old, repl in replacements.items():
64
+ new = new.replace(old, repl)
65
+ if new != text:
66
+ path.write_text(new, encoding="utf-8")
67
+
68
+
69
+ def main() -> None:
70
+ started = time.time()
71
+ work = Path.cwd() / "recon_vs_head_work"
72
+ out = Path.cwd() / "recon_vs_head_outputs"
73
+ if work.exists():
74
+ shutil.rmtree(work)
75
+ if out.exists():
76
+ shutil.rmtree(out)
77
+ work.mkdir()
78
+ out.mkdir()
79
+
80
+ try:
81
+ run(["nvidia-smi"])
82
+ except Exception as exc:
83
+ print(f"nvidia-smi failed: {exc}")
84
+
85
+ code_zip = work / "time_rcd.zip"
86
+ download("https://github.com/thu-sail-lab/Time-RCD/archive/refs/heads/main.zip", code_zip)
87
+ repo = unpack_single_root(code_zip, work / "code")
88
+ patch_repo_imports(repo)
89
+ ds = repo / "datasets"
90
+ ds.mkdir(exist_ok=True)
91
+ zip_path = ds / "TSB-AD-U.zip"
92
+ download("https://www.thedatum.org/datasets/TSB-AD-U.zip", zip_path)
93
+ with zipfile.ZipFile(zip_path) as zf:
94
+ zf.extractall(ds)
95
+ zip_path.unlink()
96
+
97
+ from huggingface_hub import HfApi, snapshot_download
98
+
99
+ snapshot_download(
100
+ "thu-sail-lab/Time-RCD",
101
+ local_dir=repo,
102
+ allow_patterns=["best_model/pretrain_checkpoint_best_uni.pth"],
103
+ token=os.environ.get("HF_TOKEN"),
104
+ )
105
+
106
+ sys.path.insert(0, str(repo))
107
+ os.chdir(repo)
108
+ from evaluation.metrics import get_metrics_optimized
109
+ from models.TimeRCD import TimeRCDPretrainTester
110
+ from models.time_rcd.TimeRCD_pretrain_multi import test_collate_fn
111
+ from models.time_rcd.time_rcd_config import default_config
112
+ from utils.dataset import TimeRCDDataset
113
+ from utils.slidingWindows import find_length_rank
114
+
115
+ cfg = default_config
116
+ cfg.ts_config.patch_size = 16
117
+ cfg.ts_config.num_features = 1
118
+ cfg.win_size = 5000
119
+ cfg.batch_size = 1
120
+ tester = TimeRCDPretrainTester("best_model/pretrain_checkpoint_best_uni.pth", cfg)
121
+ model = tester.model
122
+ dev = tester.device
123
+
124
+ def score_both(data: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
125
+ win = min(5000, len(data))
126
+ loader = DataLoader(
127
+ TimeRCDDataset(data, window_size=win, stride=win, normalize=True),
128
+ batch_size=1,
129
+ collate_fn=test_collate_fn,
130
+ num_workers=0,
131
+ shuffle=False,
132
+ )
133
+ heads, recs = [], []
134
+ with torch.no_grad():
135
+ for batch in loader:
136
+ ts = batch["time_series"].to(dev)
137
+ am = batch["attention_mask"].to(dev)
138
+ emb = model(time_series=ts, mask=am)
139
+ logits = model.anomaly_head(emb).mean(dim=-2)
140
+ heads.append(F.softmax(logits, dim=-1)[..., 1].detach().cpu().numpy().ravel())
141
+ rec = model.reconstruction_head(emb).squeeze(-1)
142
+ recs.append(((rec - ts) ** 2).mean(dim=-1).detach().cpu().numpy().ravel())
143
+ return np.concatenate(heads), np.concatenate(recs)
144
+
145
+ rows = []
146
+ files = sorted((repo / "datasets/TSB-AD-U").glob("*UCR*.csv"))
147
+ if MAX_FILES > 0:
148
+ files = files[:MAX_FILES]
149
+ print(f"UCR files: {len(files)}", flush=True)
150
+ for idx, path in enumerate(files, 1):
151
+ print(f"[{idx}/{len(files)}] {path.name}", flush=True)
152
+ df = pd.read_csv(path).dropna()
153
+ data = df.iloc[:, :-1].values.astype(float)
154
+ labels = df["Label"].astype(int).to_numpy()
155
+ train_index = int(path.stem.split("_")[-3])
156
+ test_data = data[train_index:]
157
+ label_test = labels[train_index:]
158
+ sliding = find_length_rank(data, rank=1)
159
+ head, recon = score_both(test_data)
160
+ n = min(len(head), len(recon), len(label_test))
161
+ head = head[:n]
162
+ recon = recon[:n]
163
+ label_aligned = label_test[:n]
164
+ for kind, score in [("anomaly_head", head), ("reconstruction_error", recon)]:
165
+ kwargs = {
166
+ "slidingWindow": sliding,
167
+ "pred": score > (np.mean(score) + 3 * np.std(score)),
168
+ }
169
+ try:
170
+ metrics = get_metrics_optimized(
171
+ score,
172
+ label_aligned,
173
+ **kwargs,
174
+ heavy_workers=int(os.environ.get("HEAVY_WORKERS", "16")),
175
+ light_workers=int(os.environ.get("LIGHT_WORKERS", "8")),
176
+ )
177
+ except TypeError:
178
+ metrics = get_metrics_optimized(score, label_aligned, **kwargs)
179
+ rows.append({"filename": path.name, "readout": kind, **metrics})
180
+
181
+ result = pd.DataFrame(rows)
182
+ result.to_csv(out / "recon_vs_head_ucr.csv", index=False)
183
+ summary = {}
184
+ for kind, part in result.groupby("readout"):
185
+ summary[kind] = {
186
+ "files": int(part.shape[0]),
187
+ "VUS-PR": float(part["VUS-PR"].mean()),
188
+ "Standard-F1": float(part["Standard-F1"].mean()),
189
+ "Affiliation-F": float(part["Affiliation-F"].mean()),
190
+ "F1_T": float(part["F1_T"].mean()),
191
+ }
192
+ summary["elapsed_seconds"] = round(time.time() - started, 2)
193
+ (out / "recon_vs_head_summary.json").write_text(json.dumps(summary, indent=2), encoding="utf-8")
194
+ print("RECON_VS_HEAD_SUMMARY_START")
195
+ print(json.dumps(summary, indent=2))
196
+ print("RECON_VS_HEAD_SUMMARY_END")
197
+
198
+ api = HfApi(token=os.environ.get("HF_TOKEN"))
199
+ api.create_repo(OUT_REPO, repo_type="dataset", exist_ok=True)
200
+ api.upload_folder(
201
+ repo_id=OUT_REPO,
202
+ repo_type="dataset",
203
+ folder_path=str(out),
204
+ path_in_repo=f"recon_vs_head_{int(started)}",
205
+ )
206
+ print(f"uploaded to https://huggingface.co/datasets/{OUT_REPO}")
207
+
208
+
209
+ if __name__ == "__main__":
210
+ main()
scripts/hf_reduced_ablation_train.py ADDED
@@ -0,0 +1,435 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Reduced-scale TimeRCD ablation training on HF Jobs.
3
+
4
+ This is a checkpoint-free experiment for Claim 5: train the same TimeRCD
5
+ architecture/loss on (a) public synthetic RCD anomalies, (b) synthetic normals
6
+ with context-independent DADA-style injection, and (c) real TSB normal prefixes
7
+ with the same DADA-style injection. It uploads checkpoints and metric summaries.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ import os
14
+ import random
15
+ import re
16
+ import shutil
17
+ import subprocess
18
+ import sys
19
+ import time
20
+ import urllib.request
21
+ import zipfile
22
+ from pathlib import Path
23
+
24
+ import numpy as np
25
+ import pandas as pd
26
+ import torch
27
+ import torch.nn.functional as F
28
+ from torch.utils.data import DataLoader, Dataset
29
+
30
+
31
+ OUT_REPO = os.environ.get("OUT_REPO", "Srishti280992/timercd-full-eval")
32
+ SEED = int(os.environ.get("SEED", "20260722"))
33
+ SEQ_LEN = int(os.environ.get("SEQ_LEN", "512"))
34
+ TRAIN_SAMPLES = int(os.environ.get("TRAIN_SAMPLES", "1500"))
35
+ EVAL_SAMPLES = int(os.environ.get("EVAL_SAMPLES", "60"))
36
+ EPOCHS = int(os.environ.get("EPOCHS", "4"))
37
+ BATCH_SIZE = int(os.environ.get("BATCH_SIZE", "64"))
38
+
39
+
40
+ def run(cmd: list[str], cwd: Path | None = None) -> None:
41
+ print("$", " ".join(cmd), flush=True)
42
+ subprocess.run(cmd, cwd=cwd, check=True)
43
+
44
+
45
+ def download(url: str, path: Path) -> None:
46
+ req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
47
+ path.parent.mkdir(parents=True, exist_ok=True)
48
+ with urllib.request.urlopen(req, timeout=120) as response, path.open("wb") as fh:
49
+ shutil.copyfileobj(response, fh)
50
+
51
+
52
+ def unpack_single_root(zip_path: Path, dest: Path) -> Path:
53
+ with zipfile.ZipFile(zip_path) as zf:
54
+ zf.extractall(dest)
55
+ roots = [p for p in dest.iterdir() if p.is_dir()]
56
+ if len(roots) != 1:
57
+ raise RuntimeError(f"expected one root in {dest}, got {roots}")
58
+ return roots[0]
59
+
60
+
61
+ def patch_repo_imports(repo: Path) -> None:
62
+ replacements = {
63
+ "from .evaluation.metrics": "from evaluation.metrics",
64
+ "from .utils.slidingWindows": "from utils.slidingWindows",
65
+ "from .model_wrapper": "from model_wrapper",
66
+ "from .HP_list": "from HP_list",
67
+ "from ..utils.dataset": "from utils.dataset",
68
+ "from ..utils.utility": "from utils.utility",
69
+ "from ..utils.torch_utility": "from utils.torch_utility",
70
+ "from ..utils.stat_models": "from utils.stat_models",
71
+ }
72
+ for path in repo.rglob("*.py"):
73
+ text = path.read_text(encoding="utf-8")
74
+ new = text
75
+ for old, repl in replacements.items():
76
+ new = new.replace(old, repl)
77
+ if new != text:
78
+ path.write_text(new, encoding="utf-8")
79
+
80
+
81
+ def z_norm(x: np.ndarray) -> np.ndarray:
82
+ x = np.asarray(x, dtype=np.float32).reshape(-1)
83
+ return (x - x.mean()) / (x.std() + 1e-4)
84
+
85
+
86
+ def inject_dada_style(normal: np.ndarray) -> tuple[np.ndarray, np.ndarray, str]:
87
+ x = np.asarray(normal, dtype=np.float32).reshape(-1).copy()
88
+ n = len(x)
89
+ labels = np.zeros(n, dtype=np.int64)
90
+ length = random.randint(max(8, n // 80), max(12, n // 12))
91
+ start = random.randint(5, max(6, n - length - 5))
92
+ end = start + length
93
+ labels[start:end] = 1
94
+ kind = random.choice(["spike", "scale", "shift", "noise", "flat", "trend", "reverse", "drop", "pattern"])
95
+ scale = x.std() + 1e-4
96
+ if kind == "spike":
97
+ x[start:end] += random.choice([-1, 1]) * random.uniform(3.0, 6.0) * scale
98
+ elif kind == "scale":
99
+ x[start:end] *= random.uniform(1.8, 3.5)
100
+ elif kind == "shift":
101
+ x[start:end] += random.choice([-1, 1]) * random.uniform(1.5, 4.0) * scale
102
+ elif kind == "noise":
103
+ x[start:end] += np.random.normal(0, random.uniform(1.5, 3.5) * scale, end - start)
104
+ elif kind == "flat":
105
+ x[start:end] = x[start]
106
+ elif kind == "trend":
107
+ x[start:end] += np.linspace(0, random.choice([-1, 1]) * random.uniform(3.0, 5.0) * scale, end - start)
108
+ elif kind == "reverse":
109
+ x[start:end] = x[start:end][::-1]
110
+ elif kind == "drop":
111
+ x[start:end] = x[start:end] * random.uniform(0.0, 0.2)
112
+ else:
113
+ t = np.linspace(0, np.pi * 4, end - start)
114
+ x[start:end] += np.sin(t) * random.uniform(2.0, 4.0) * scale
115
+ return x, labels, kind
116
+
117
+
118
+ class MemoryCorpus(Dataset):
119
+ def __init__(self, samples: list[dict]):
120
+ self.samples = samples
121
+
122
+ def __len__(self) -> int:
123
+ return len(self.samples)
124
+
125
+ def __getitem__(self, idx: int):
126
+ s = self.samples[idx]
127
+ ts = torch.tensor(np.asarray(s["time_series"], dtype=np.float32)).reshape(-1)
128
+ nts = torch.tensor(np.asarray(s["normal_time_series"], dtype=np.float32)).reshape(-1)
129
+ labels = torch.tensor(np.asarray(s["labels"], dtype=np.float32)).reshape(-1)
130
+ return ts, nts, labels, s.get("attribute", {})
131
+
132
+
133
+ def create_random_mask(time_series: torch.Tensor, attention_mask: torch.Tensor, patch_size: int = 16, mask_ratio: float = 0.15):
134
+ batch_size, seq_len, num_features = time_series.shape
135
+ mask = torch.zeros(batch_size, seq_len)
136
+ for i in range(batch_size):
137
+ valid_length = int(attention_mask[i].sum().item())
138
+ num_valid_patches = (valid_length - 1) // patch_size + 1
139
+ num_masked = int(num_valid_patches * mask_ratio)
140
+ if num_masked > 0:
141
+ for j in torch.randperm(num_valid_patches)[:num_masked]:
142
+ start = int(j) * patch_size
143
+ end = min((int(j) + 1) * patch_size, valid_length)
144
+ mask[i, start:end] = 1
145
+ masked = time_series.clone()
146
+ mask_indices = mask.bool() & attention_mask
147
+ masked[mask_indices.unsqueeze(-1).expand(-1, -1, num_features)] = 0.0
148
+ return masked, mask * attention_mask.float()
149
+
150
+
151
+ def collate(batch):
152
+ ts_list, nts_list, labels_list, attrs = zip(*batch)
153
+ ts_list = [x.unsqueeze(-1) for x in ts_list]
154
+ nts_list = [x.unsqueeze(-1) for x in nts_list]
155
+ concat = torch.cat(ts_list, dim=0)
156
+ mean, std = concat.mean(dim=0, keepdim=True), concat.std(dim=0, keepdim=True) + 1e-4
157
+ ts_list = [(x - mean) / std for x in ts_list]
158
+ nts_list = [(x - mean) / std for x in nts_list]
159
+ padded_ts = torch.nn.utils.rnn.pad_sequence(ts_list, batch_first=True, padding_value=0.0)
160
+ padded_nts = torch.nn.utils.rnn.pad_sequence(nts_list, batch_first=True, padding_value=0.0)
161
+ padded_labels = torch.nn.utils.rnn.pad_sequence(labels_list, batch_first=True, padding_value=-1)
162
+ attention_mask = torch.zeros(padded_ts.shape[:2], dtype=torch.bool)
163
+ for i, ts in enumerate(ts_list):
164
+ attention_mask[i, : ts.shape[0]] = True
165
+ masked, mask = create_random_mask(padded_ts, attention_mask)
166
+ return {
167
+ "time_series": padded_ts,
168
+ "normal_time_series": padded_nts,
169
+ "masked_time_series": masked,
170
+ "mask": mask,
171
+ "labels": padded_labels,
172
+ "attention_mask": attention_mask,
173
+ "attribute": attrs,
174
+ }
175
+
176
+
177
+ def make_synthetic_rcd(gen_repo: Path, count: int) -> list[dict]:
178
+ sys.path.insert(0, str(gen_repo))
179
+ sys.path.insert(0, str(gen_repo / "src"))
180
+ cwd = Path.cwd()
181
+ os.chdir(gen_repo)
182
+ try:
183
+ from src.generate_dataset import generate_dataset
184
+
185
+ data = generate_dataset(
186
+ num_samples=count,
187
+ seq_len=SEQ_LEN,
188
+ anomaly_sample_ratio=1.0,
189
+ is_multivariate=False,
190
+ use_attribute_set=True,
191
+ num_workers=1,
192
+ )
193
+ finally:
194
+ os.chdir(cwd)
195
+ return data
196
+
197
+
198
+ def make_synthetic_dada(gen_repo: Path, count: int) -> list[dict]:
199
+ sys.path.insert(0, str(gen_repo))
200
+ sys.path.insert(0, str(gen_repo / "src"))
201
+ cwd = Path.cwd()
202
+ os.chdir(gen_repo)
203
+ try:
204
+ from src.generate_dataset import generate_dataset
205
+
206
+ normals = generate_dataset(
207
+ num_samples=count,
208
+ seq_len=SEQ_LEN,
209
+ anomaly_sample_ratio=0.0,
210
+ is_multivariate=False,
211
+ use_attribute_set=True,
212
+ num_workers=1,
213
+ )
214
+ finally:
215
+ os.chdir(cwd)
216
+ out = []
217
+ for sample in normals:
218
+ normal = z_norm(sample["normal_time_series"])
219
+ injected, labels, kind = inject_dada_style(normal)
220
+ out.append({"normal_time_series": normal, "time_series": injected, "labels": labels, "attribute": {"injection": kind}})
221
+ return out
222
+
223
+
224
+ def get_dataset_name(filename: str) -> str:
225
+ match = re.match(r"\d+_([^_]+)_", filename)
226
+ return match.group(1) if match else filename.split("_")[0]
227
+
228
+
229
+ def make_real_dada(tsb_dir: Path, count: int) -> list[dict]:
230
+ files = sorted(tsb_dir.glob("*.csv"))
231
+ out = []
232
+ while len(out) < count:
233
+ path = random.choice(files)
234
+ df = pd.read_csv(path).dropna()
235
+ labels = df["Label"].astype(int).to_numpy()
236
+ values = df.iloc[:, :-1].values.astype(np.float32).reshape(-1)
237
+ normal_idx = np.where(labels == 0)[0]
238
+ if len(normal_idx) < SEQ_LEN:
239
+ continue
240
+ start = int(random.choice(normal_idx[:-SEQ_LEN]))
241
+ segment = values[start : start + SEQ_LEN]
242
+ if len(segment) != SEQ_LEN or not np.isfinite(segment).all():
243
+ continue
244
+ normal = z_norm(segment)
245
+ injected, labels_new, kind = inject_dada_style(normal)
246
+ out.append({"normal_time_series": normal, "time_series": injected, "labels": labels_new, "attribute": {"source": path.name, "injection": kind}})
247
+ return out
248
+
249
+
250
+ def train_arm(name: str, samples: list[dict], repo: Path, out: Path):
251
+ from models.time_rcd.TimeRCD_pretrain_multi import TimeSeriesPretrainModel
252
+ from models.time_rcd.time_rcd_config import default_config
253
+
254
+ random.Random(SEED).shuffle(samples)
255
+ cut = int(len(samples) * 0.9)
256
+ train_ds, val_ds = MemoryCorpus(samples[:cut]), MemoryCorpus(samples[cut:])
257
+ train_loader = DataLoader(train_ds, batch_size=BATCH_SIZE, shuffle=True, num_workers=0, collate_fn=collate)
258
+ val_loader = DataLoader(val_ds, batch_size=BATCH_SIZE, shuffle=False, num_workers=0, collate_fn=collate)
259
+
260
+ cfg = default_config
261
+ cfg.ts_config.patch_size = 16
262
+ cfg.ts_config.num_features = 1
263
+ model = TimeSeriesPretrainModel(cfg).cuda()
264
+ opt = torch.optim.AdamW(model.parameters(), lr=5e-4, weight_decay=1e-5)
265
+ best_val = float("inf")
266
+ patience = 0
267
+ history = []
268
+ for epoch in range(EPOCHS):
269
+ model.train()
270
+ train_losses = []
271
+ for batch in train_loader:
272
+ opt.zero_grad(set_to_none=True)
273
+ ts = batch["time_series"].cuda()
274
+ masked = batch["masked_time_series"].cuda()
275
+ mask = batch["mask"].cuda()
276
+ labels = batch["labels"].cuda()
277
+ attn = batch["attention_mask"].cuda()
278
+ emb = model(masked, attn & (~mask.bool()))
279
+ loss = model.masked_reconstruction_loss(emb, ts, mask) + model.anomaly_detection_loss(emb, labels)
280
+ loss.backward()
281
+ opt.step()
282
+ train_losses.append(float(loss.detach().cpu()))
283
+ model.eval()
284
+ val_losses = []
285
+ with torch.no_grad():
286
+ for batch in val_loader:
287
+ ts = batch["time_series"].cuda()
288
+ masked = batch["masked_time_series"].cuda()
289
+ mask = batch["mask"].cuda()
290
+ labels = batch["labels"].cuda()
291
+ attn = batch["attention_mask"].cuda()
292
+ emb = model(masked, attn & (~mask.bool()))
293
+ loss = model.masked_reconstruction_loss(emb, ts, mask) + model.anomaly_detection_loss(emb, labels)
294
+ val_losses.append(float(loss.detach().cpu()))
295
+ train_loss, val_loss = float(np.mean(train_losses)), float(np.mean(val_losses))
296
+ print(f"{name} epoch {epoch}: train {train_loss:.4f} val {val_loss:.4f}", flush=True)
297
+ history.append({"arm": name, "epoch": epoch, "train_loss": train_loss, "val_loss": val_loss})
298
+ if val_loss < best_val:
299
+ best_val = val_loss
300
+ patience = 0
301
+ ckpt_dir = out / f"ckpt_{name}"
302
+ ckpt_dir.mkdir(exist_ok=True)
303
+ torch.save({"epoch": epoch, "model_state_dict": model.state_dict(), "loss": val_loss, "config": cfg.to_dict()}, ckpt_dir / "pretrain_checkpoint_best_uni.pth")
304
+ else:
305
+ patience += 1
306
+ if patience >= 3:
307
+ break
308
+ return pd.DataFrame(history), out / f"ckpt_{name}" / "pretrain_checkpoint_best_uni.pth"
309
+
310
+
311
+ def score_checkpoint(ckpt: Path, eval_samples: list[dict], repo: Path):
312
+ from evaluation.metrics import get_metrics_optimized
313
+ from models.TimeRCD import TimeRCDPretrainTester
314
+ from models.time_rcd.time_rcd_config import default_config
315
+
316
+ cfg = default_config
317
+ cfg.ts_config.patch_size = 16
318
+ cfg.ts_config.num_features = 1
319
+ cfg.win_size = SEQ_LEN
320
+ cfg.batch_size = 1
321
+ tester = TimeRCDPretrainTester(str(ckpt), cfg)
322
+ rows = []
323
+ for i, sample in enumerate(eval_samples):
324
+ series = np.asarray(sample["time_series"], dtype=float).reshape(-1, 1)
325
+ labels = np.asarray(sample["labels"], dtype=int).reshape(-1)
326
+ tester.win_size = len(series)
327
+ scores, _ = tester.zero_shot(series)
328
+ score = np.concatenate([np.asarray(x).reshape(-1) for x in scores])[: len(labels)]
329
+ kwargs = {
330
+ "slidingWindow": 100,
331
+ "pred": score > (np.mean(score) + 3 * np.std(score)),
332
+ }
333
+ try:
334
+ metrics = get_metrics_optimized(
335
+ score,
336
+ labels[: len(score)],
337
+ **kwargs,
338
+ heavy_workers=int(os.environ.get("HEAVY_WORKERS", "8")),
339
+ light_workers=int(os.environ.get("LIGHT_WORKERS", "4")),
340
+ )
341
+ except TypeError:
342
+ metrics = get_metrics_optimized(score, labels[: len(score)], **kwargs)
343
+ rows.append({"sample": i, **metrics})
344
+ return pd.DataFrame(rows)
345
+
346
+
347
+ def main() -> None:
348
+ started = time.time()
349
+ random.seed(SEED)
350
+ np.random.seed(SEED)
351
+ torch.manual_seed(SEED)
352
+ work = Path.cwd() / "reduced_ablation_work"
353
+ out = Path.cwd() / "reduced_ablation_outputs"
354
+ if work.exists():
355
+ shutil.rmtree(work)
356
+ if out.exists():
357
+ shutil.rmtree(out)
358
+ work.mkdir()
359
+ out.mkdir()
360
+ run(["nvidia-smi"])
361
+
362
+ code_zip, gen_zip = work / "time_rcd.zip", work / "generator.zip"
363
+ download("https://github.com/thu-sail-lab/Time-RCD/archive/refs/heads/main.zip", code_zip)
364
+ download("https://github.com/thu-sail-lab/TSAD_dataset_gen_public/archive/refs/heads/clean_version.zip", gen_zip)
365
+ repo = unpack_single_root(code_zip, work / "code")
366
+ gen_repo = unpack_single_root(gen_zip, work / "generator")
367
+ patch_repo_imports(repo)
368
+ sys.path.insert(0, str(repo))
369
+ os.chdir(repo)
370
+
371
+ ds = repo / "datasets"
372
+ ds.mkdir(exist_ok=True)
373
+ zip_path = ds / "TSB-AD-U.zip"
374
+ download("https://www.thedatum.org/datasets/TSB-AD-U.zip", zip_path)
375
+ with zipfile.ZipFile(zip_path) as zf:
376
+ zf.extractall(ds)
377
+ zip_path.unlink()
378
+ tsb_dir = ds / "TSB-AD-U"
379
+
380
+ arm_builders = {
381
+ "synthetic_rcd": lambda n: make_synthetic_rcd(gen_repo, n),
382
+ "synthetic_dada": lambda n: make_synthetic_dada(gen_repo, n),
383
+ "real_dada": lambda n: make_real_dada(tsb_dir, n),
384
+ }
385
+ histories, summaries = [], {}
386
+ eval_sets = {
387
+ "synthetic_rcd": make_synthetic_rcd(gen_repo, EVAL_SAMPLES),
388
+ "synthetic_dada": make_synthetic_dada(gen_repo, EVAL_SAMPLES),
389
+ "real_dada": make_real_dada(tsb_dir, EVAL_SAMPLES),
390
+ }
391
+ for arm, builder in arm_builders.items():
392
+ print(f"building {arm}", flush=True)
393
+ samples = builder(TRAIN_SAMPLES)
394
+ corpus_meta = {"arm": arm, "samples": len(samples), "points": int(sum(len(s["time_series"]) for s in samples))}
395
+ (out / f"{arm}_corpus_meta.json").write_text(json.dumps(corpus_meta, indent=2), encoding="utf-8")
396
+ hist, ckpt = train_arm(arm, samples, repo, out)
397
+ histories.append(hist)
398
+ eval_df = score_checkpoint(ckpt, eval_sets[arm], repo)
399
+ eval_df.insert(0, "arm", arm)
400
+ eval_df.to_csv(out / f"{arm}_eval.csv", index=False)
401
+ summaries[arm] = {
402
+ **corpus_meta,
403
+ "best_val_loss": float(hist["val_loss"].min()),
404
+ "Affiliation-F": float(eval_df["Affiliation-F"].mean()),
405
+ "F1_T": float(eval_df["F1_T"].mean()),
406
+ "Standard-F1": float(eval_df["Standard-F1"].mean()),
407
+ "VUS-PR": float(eval_df["VUS-PR"].mean()),
408
+ }
409
+
410
+ pd.concat(histories, ignore_index=True).to_csv(out / "training_history.csv", index=False)
411
+ summary = {
412
+ "seed": SEED,
413
+ "seq_len": SEQ_LEN,
414
+ "train_samples_per_arm": TRAIN_SAMPLES,
415
+ "eval_samples_per_arm": EVAL_SAMPLES,
416
+ "epochs_cap": EPOCHS,
417
+ "arms": summaries,
418
+ "elapsed_seconds": round(time.time() - started, 2),
419
+ "note": "DADA arms use a transparent context-independent DADA-style injection proxy; not the original DADA repository code.",
420
+ }
421
+ (out / "reduced_ablation_summary.json").write_text(json.dumps(summary, indent=2), encoding="utf-8")
422
+ print("REDUCED_ABLATION_SUMMARY_START")
423
+ print(json.dumps(summary, indent=2))
424
+ print("REDUCED_ABLATION_SUMMARY_END")
425
+
426
+ from huggingface_hub import HfApi
427
+
428
+ api = HfApi(token=os.environ.get("HF_TOKEN"))
429
+ api.create_repo(OUT_REPO, repo_type="dataset", exist_ok=True)
430
+ api.upload_folder(repo_id=OUT_REPO, repo_type="dataset", folder_path=str(out), path_in_repo=f"reduced_ablation_{int(started)}")
431
+ print(f"uploaded to https://huggingface.co/datasets/{OUT_REPO}")
432
+
433
+
434
+ if __name__ == "__main__":
435
+ main()
scripts/hf_specialized_context_eval.py ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """HF Job: regenerated point/contextual anomaly split with TimeRCD vs Chronos.
3
+
4
+ The paper's specialized contextual test files are not public, so this job
5
+ regenerates a proxy split from the authors' public synthetic generator and
6
+ evaluates both models on the exact same series.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import json
12
+ import os
13
+ import random
14
+ import shutil
15
+ import subprocess
16
+ import sys
17
+ import time
18
+ import urllib.request
19
+ import zipfile
20
+ from pathlib import Path
21
+
22
+ import numpy as np
23
+ import pandas as pd
24
+ import torch
25
+
26
+
27
+ OUT_REPO = os.environ.get("OUT_REPO", "Srishti280992/timercd-full-eval")
28
+ TARGET_PER_SPLIT = int(os.environ.get("TARGET_PER_SPLIT", "10"))
29
+ MAX_CANDIDATES = int(os.environ.get("MAX_CANDIDATES", "20000"))
30
+ SEQ_LEN = int(os.environ.get("SEQ_LEN", "768"))
31
+ SEED = int(os.environ.get("SEED", "20260722"))
32
+
33
+
34
+ def run(cmd: list[str], cwd: Path | None = None) -> None:
35
+ print("$", " ".join(cmd), flush=True)
36
+ subprocess.run(cmd, cwd=cwd, check=True)
37
+
38
+
39
+ def download(url: str, path: Path) -> None:
40
+ req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
41
+ path.parent.mkdir(parents=True, exist_ok=True)
42
+ with urllib.request.urlopen(req, timeout=120) as response, path.open("wb") as fh:
43
+ shutil.copyfileobj(response, fh)
44
+
45
+
46
+ def unpack_single_root(zip_path: Path, dest: Path) -> Path:
47
+ with zipfile.ZipFile(zip_path) as zf:
48
+ zf.extractall(dest)
49
+ roots = [p for p in dest.iterdir() if p.is_dir()]
50
+ if len(roots) != 1:
51
+ raise RuntimeError(f"expected one root in {dest}, got {roots}")
52
+ return roots[0]
53
+
54
+
55
+ def patch_repo_imports(repo: Path) -> None:
56
+ replacements = {
57
+ "from .evaluation.metrics": "from evaluation.metrics",
58
+ "from .utils.slidingWindows": "from utils.slidingWindows",
59
+ "from .model_wrapper": "from model_wrapper",
60
+ "from .HP_list": "from HP_list",
61
+ "from ..utils.dataset": "from utils.dataset",
62
+ "from ..utils.utility": "from utils.utility",
63
+ "from ..utils.torch_utility": "from utils.torch_utility",
64
+ "from ..utils.stat_models": "from utils.stat_models",
65
+ }
66
+ for path in repo.rglob("*.py"):
67
+ text = path.read_text(encoding="utf-8")
68
+ new = text
69
+ for old, repl in replacements.items():
70
+ new = new.replace(old, repl)
71
+ if new != text:
72
+ path.write_text(new, encoding="utf-8")
73
+
74
+
75
+ def anomaly_groups(sample: dict) -> tuple[bool, bool, list[str]]:
76
+ attr = sample.get("attribute") or {}
77
+ pool = attr.get("full_attribute_pool") or {}
78
+ local = pool.get("local") or []
79
+ seasonal = pool.get("seasonal_anomalies") or []
80
+ names = list((attr.get("anomalies") or {}).keys())
81
+ name_text = " ".join(names).lower()
82
+ contextual_words = ["season", "harmonic", "wave", "freq", "phase", "period", "trend", "amplitude"]
83
+ point_words = ["spike", "outlier", "drop", "jump", "local", "scale"]
84
+ has_contextual = bool(seasonal) or any(w in name_text for w in contextual_words)
85
+ has_point = bool(local) or any(w in name_text for w in point_words)
86
+ return has_point, has_contextual, names
87
+
88
+
89
+ def build_specialized_sets(gen_repo: Path, out: Path) -> dict[str, list[dict]]:
90
+ sys.path.insert(0, str(gen_repo))
91
+ sys.path.insert(0, str(gen_repo / "src"))
92
+ cwd = Path.cwd()
93
+ os.chdir(gen_repo)
94
+ from src.generate_dataset import generate_dataset
95
+
96
+ random.seed(SEED)
97
+ np.random.seed(SEED)
98
+ sets: dict[str, list[dict]] = {"point": [], "contextual": []}
99
+ seen = 0
100
+ batch_size = 128
101
+ try:
102
+ while seen < MAX_CANDIDATES and (len(sets["point"]) < TARGET_PER_SPLIT or len(sets["contextual"]) < TARGET_PER_SPLIT):
103
+ batch = generate_dataset(
104
+ num_samples=batch_size,
105
+ seq_len=SEQ_LEN,
106
+ anomaly_sample_ratio=1.0,
107
+ is_multivariate=False,
108
+ use_attribute_set=True,
109
+ num_workers=1,
110
+ )
111
+ seen += len(batch)
112
+ for sample in batch:
113
+ labels = np.asarray(sample["labels"]).astype(int)
114
+ if labels.sum() == 0:
115
+ continue
116
+ has_point, has_contextual, names = anomaly_groups(sample)
117
+ if has_contextual and not has_point and len(sets["contextual"]) < TARGET_PER_SPLIT:
118
+ sets["contextual"].append({"series": sample["time_series"], "labels": labels.tolist(), "anomalies": names})
119
+ elif has_point and not has_contextual and len(sets["point"]) < TARGET_PER_SPLIT:
120
+ sets["point"].append({"series": sample["time_series"], "labels": labels.tolist(), "anomalies": names})
121
+ print(f"candidates={seen} point={len(sets['point'])} contextual={len(sets['contextual'])}", flush=True)
122
+ finally:
123
+ os.chdir(cwd)
124
+
125
+ meta = {
126
+ "target_per_split": TARGET_PER_SPLIT,
127
+ "max_candidates": MAX_CANDIDATES,
128
+ "seen_candidates": seen,
129
+ "seq_len": SEQ_LEN,
130
+ "counts": {k: len(v) for k, v in sets.items()},
131
+ "seed": SEED,
132
+ }
133
+ (out / "specialized_generation_summary.json").write_text(json.dumps(meta, indent=2), encoding="utf-8")
134
+ for split, samples in sets.items():
135
+ rows = []
136
+ for i, sample in enumerate(samples):
137
+ rows.append(
138
+ {
139
+ "split": split,
140
+ "index": i,
141
+ "series": json.dumps(np.asarray(sample["series"], dtype=float).reshape(-1).tolist()),
142
+ "labels": json.dumps(np.asarray(sample["labels"], dtype=int).reshape(-1).tolist()),
143
+ "anomalies": json.dumps(sample["anomalies"]),
144
+ }
145
+ )
146
+ pd.DataFrame(rows).to_csv(out / f"specialized_{split}_series.csv", index=False)
147
+ return sets
148
+
149
+
150
+ def main() -> None:
151
+ started = time.time()
152
+ work = Path.cwd() / "specialized_eval_work"
153
+ out = Path.cwd() / "specialized_eval_outputs"
154
+ if work.exists():
155
+ shutil.rmtree(work)
156
+ if out.exists():
157
+ shutil.rmtree(out)
158
+ work.mkdir()
159
+ out.mkdir()
160
+
161
+ try:
162
+ run(["nvidia-smi"])
163
+ except Exception as exc:
164
+ print(f"nvidia-smi failed: {exc}")
165
+
166
+ code_zip = work / "time_rcd.zip"
167
+ gen_zip = work / "generator.zip"
168
+ download("https://github.com/thu-sail-lab/Time-RCD/archive/refs/heads/main.zip", code_zip)
169
+ download("https://github.com/thu-sail-lab/TSAD_dataset_gen_public/archive/refs/heads/clean_version.zip", gen_zip)
170
+ repo = unpack_single_root(code_zip, work / "code")
171
+ gen_repo = unpack_single_root(gen_zip, work / "generator")
172
+ patch_repo_imports(repo)
173
+
174
+ from huggingface_hub import HfApi, snapshot_download
175
+
176
+ snapshot_download(
177
+ "thu-sail-lab/Time-RCD",
178
+ local_dir=repo,
179
+ allow_patterns=["best_model/pretrain_checkpoint_best_uni.pth"],
180
+ token=os.environ.get("HF_TOKEN"),
181
+ )
182
+
183
+ sets = build_specialized_sets(gen_repo, out)
184
+
185
+ sys.path.insert(0, str(repo))
186
+ os.chdir(repo)
187
+ from evaluation.metrics import get_metrics_optimized
188
+ from models.TimeRCD import TimeRCDPretrainTester
189
+ from models.time_rcd.time_rcd_config import default_config
190
+
191
+ cfg = default_config
192
+ cfg.ts_config.patch_size = 16
193
+ cfg.ts_config.num_features = 1
194
+ cfg.win_size = 5000
195
+ cfg.batch_size = 1
196
+ tester = TimeRCDPretrainTester("best_model/pretrain_checkpoint_best_uni.pth", cfg)
197
+
198
+ chronos_pipeline = None
199
+ chronos_error: str | None = "disabled for fast fallback; using persistence forecast-error baseline"
200
+ print(chronos_error, flush=True)
201
+
202
+ def timercd_score(series: np.ndarray) -> np.ndarray:
203
+ tester.win_size = min(5000, len(series))
204
+ scores, _ = tester.zero_shot(series.reshape(-1, 1).astype(float))
205
+ return np.concatenate([np.asarray(x).reshape(-1) for x in scores])
206
+
207
+ def chronos_score(series: np.ndarray, win: int = 100) -> np.ndarray:
208
+ series = np.asarray(series, dtype=np.float32).reshape(-1)
209
+ if len(series) <= win + 1:
210
+ pred = np.r_[series[0], series[:-1]]
211
+ return (series - pred) ** 2
212
+ if chronos_pipeline is None:
213
+ pred = np.r_[np.repeat(series[win], win), series[win - 1 : -1]]
214
+ return (series - pred) ** 2
215
+ contexts = [torch.tensor(series[i - win : i], dtype=torch.float32) for i in range(win, len(series))]
216
+ scores = []
217
+ bs = int(os.environ.get("CHRONOS_BATCH", "128"))
218
+ for start in range(0, len(contexts), bs):
219
+ batch = torch.stack(contexts[start : start + bs])
220
+ forecast = chronos_pipeline.predict(batch, prediction_length=1)
221
+ pred = forecast.median(dim=1).values[:, 0].detach().cpu().numpy()
222
+ target = series[win + start : win + start + len(pred)]
223
+ scores.extend(((target - pred) ** 2).tolist())
224
+ return np.r_[np.repeat(scores[0], win), np.asarray(scores)]
225
+
226
+ rows = []
227
+ for split, samples in sets.items():
228
+ for idx, sample in enumerate(samples):
229
+ print(f"eval {split} {idx + 1}/{len(samples)}", flush=True)
230
+ series = np.asarray(sample["series"], dtype=float).reshape(-1)
231
+ labels = np.asarray(sample["labels"], dtype=int).reshape(-1)
232
+ for model_name, score in [
233
+ ("TimeRCD", timercd_score(series)),
234
+ ("ForecastError", chronos_score(series)),
235
+ ]:
236
+ n = min(len(score), len(labels))
237
+ score = np.asarray(score[:n], dtype=float)
238
+ label = labels[:n]
239
+ kwargs = {
240
+ "slidingWindow": 100,
241
+ "pred": score > (np.mean(score) + 3 * np.std(score)),
242
+ }
243
+ try:
244
+ metrics = get_metrics_optimized(
245
+ score,
246
+ label,
247
+ **kwargs,
248
+ heavy_workers=int(os.environ.get("HEAVY_WORKERS", "16")),
249
+ light_workers=int(os.environ.get("LIGHT_WORKERS", "8")),
250
+ )
251
+ except TypeError:
252
+ metrics = get_metrics_optimized(score, label, **kwargs)
253
+ rows.append({"split": split, "sample": idx, "model": model_name, **metrics})
254
+
255
+ results = pd.DataFrame(rows)
256
+ results.to_csv(out / "specialized_eval_per_series.csv", index=False)
257
+ summary: dict[str, object] = {
258
+ "generation": json.loads((out / "specialized_generation_summary.json").read_text(encoding="utf-8")),
259
+ "chronos_error": chronos_error,
260
+ "elapsed_seconds": round(time.time() - started, 2),
261
+ "metrics": {},
262
+ }
263
+ for (split, model), part in results.groupby(["split", "model"]):
264
+ summary["metrics"][f"{split}/{model}"] = {
265
+ "n": int(part.shape[0]),
266
+ "Affiliation-F": float(part["Affiliation-F"].mean()),
267
+ "F1_T": float(part["F1_T"].mean()),
268
+ "Standard-F1": float(part["Standard-F1"].mean()),
269
+ "VUS-PR": float(part["VUS-PR"].mean()),
270
+ }
271
+ (out / "specialized_eval_summary.json").write_text(json.dumps(summary, indent=2), encoding="utf-8")
272
+ print("SPECIALIZED_EVAL_SUMMARY_START")
273
+ print(json.dumps(summary, indent=2))
274
+ print("SPECIALIZED_EVAL_SUMMARY_END")
275
+
276
+ api = HfApi(token=os.environ.get("HF_TOKEN"))
277
+ api.create_repo(OUT_REPO, repo_type="dataset", exist_ok=True)
278
+ api.upload_folder(
279
+ repo_id=OUT_REPO,
280
+ repo_type="dataset",
281
+ folder_path=str(out),
282
+ path_in_repo=f"specialized_eval_{int(started)}",
283
+ )
284
+ print(f"uploaded to https://huggingface.co/datasets/{OUT_REPO}")
285
+
286
+
287
+ if __name__ == "__main__":
288
+ main()