turambar928 commited on
Commit
2f5da4c
·
verified ·
1 Parent(s): 6187aa6

Upload folder using huggingface_hub (part 171)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. 20260907-002105-computing-math-816d26/tests/reference/ground_truth/keyword_inventory.csv +10 -0
  2. 20260907-002105-computing-math-816d26/tests/reference/ground_truth/section_outline.csv +20 -0
  3. 20260907-002105-computing-math-816d26/tests/reference/ground_truth/summary.json +11 -0
  4. 20260907-002105-computing-math-816d26/tests/reference/internal/workflow_adapters_runtime.py +679 -0
  5. 20260907-002105-computing-math-816d26/tests/reference/internal/workflow_runtime.py +5 -0
  6. 20260907-002105-computing-math-816d26/tests/reference/reference_manifest.json +34 -0
  7. 20260907-002105-computing-math-816d26/tests/reference/reference_solution.py +20 -0
  8. 20260907-002105-computing-math-816d26/tests/test.sh +29 -0
  9. 20260907-002107-computing-math-7483af/.DS_Store +3 -0
  10. 20260907-002107-computing-math-7483af/environment/Dockerfile +12 -0
  11. 20260907-002107-computing-math-7483af/environment/public_data/README.md +11 -0
  12. 20260907-002107-computing-math-7483af/environment/public_data/input/README.md +6 -0
  13. 20260907-002107-computing-math-7483af/environment/public_data/input/analysis_spec.json +91 -0
  14. 20260907-002107-computing-math-7483af/environment/public_data/input/source_context_windows.jsonl +0 -0
  15. 20260907-002107-computing-math-7483af/environment/public_data/input/tutorial_metadata.json +29 -0
  16. 20260907-002107-computing-math-7483af/environment/public_data/input/tutorial_source.html +686 -0
  17. 20260907-002107-computing-math-7483af/environment/public_data/input/tutorial_text_windows.csv +174 -0
  18. 20260907-002107-computing-math-7483af/environment/public_data/main.py +180 -0
  19. 20260907-002107-computing-math-7483af/environment/public_data/software/command_examples.csv +7 -0
  20. 20260907-002107-computing-math-7483af/environment/public_data/software/software_manifest.json +17 -0
  21. 20260907-002107-computing-math-7483af/environment/public_data/software/validate_outputs.py +41 -0
  22. 20260907-002107-computing-math-7483af/environment/public_data/task_card.json +112 -0
  23. 20260907-002107-computing-math-7483af/instruction.md +33 -0
  24. 20260907-002107-computing-math-7483af/solution/internal/workflow_adapters_runtime.py +679 -0
  25. 20260907-002107-computing-math-7483af/solution/internal/workflow_runtime.py +5 -0
  26. 20260907-002107-computing-math-7483af/solution/reference_solution.py +20 -0
  27. 20260907-002107-computing-math-7483af/solution/solve.sh +7 -0
  28. 20260907-002107-computing-math-7483af/task.toml +45 -0
  29. 20260907-002107-computing-math-7483af/tests/Dockerfile +6 -0
  30. 20260907-002107-computing-math-7483af/tests/evaluator_runner.py +92 -0
  31. 20260907-002107-computing-math-7483af/tests/reference/__pycache__/evaluator.cpython-312.pyc +0 -0
  32. 20260907-002107-computing-math-7483af/tests/reference/evaluator.py +114 -0
  33. 20260907-002107-computing-math-7483af/tests/reference/ground_truth/code_block_inventory.csv +34 -0
  34. 20260907-002107-computing-math-7483af/tests/reference/ground_truth/keyword_inventory.csv +10 -0
  35. 20260907-002107-computing-math-7483af/tests/reference/ground_truth/section_outline.csv +20 -0
  36. 20260907-002107-computing-math-7483af/tests/reference/ground_truth/summary.json +11 -0
  37. 20260907-002107-computing-math-7483af/tests/reference/internal/workflow_adapters_runtime.py +679 -0
  38. 20260907-002107-computing-math-7483af/tests/reference/internal/workflow_runtime.py +5 -0
  39. 20260907-002107-computing-math-7483af/tests/reference/reference_manifest.json +34 -0
  40. 20260907-002107-computing-math-7483af/tests/reference/reference_solution.py +20 -0
  41. 20260907-002107-computing-math-7483af/tests/test.sh +29 -0
  42. 20260907-002128-computing-math-734953/.DS_Store +3 -0
  43. 20260907-002128-computing-math-734953/environment/Dockerfile +12 -0
  44. 20260907-002128-computing-math-734953/environment/public_data/README.md +11 -0
  45. 20260907-002128-computing-math-734953/environment/public_data/input/README.md +6 -0
  46. 20260907-002128-computing-math-734953/environment/public_data/input/analysis_spec.json +98 -0
  47. 20260907-002128-computing-math-734953/environment/public_data/input/dockerfile_packaging_corpus.md +447 -0
  48. 20260907-002128-computing-math-734953/environment/public_data/input/dockerfile_text_windows.csv +226 -0
  49. 20260907-002128-computing-math-734953/environment/public_data/input/source_context_windows.jsonl +0 -0
  50. 20260907-002128-computing-math-734953/environment/public_data/input/tutorial_metadata.json +35 -0
20260907-002105-computing-math-816d26/tests/reference/ground_truth/keyword_inventory.csv ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ term,category,count,first_window,appears_in_code
2
+ docker,code,90,1,true
3
+ docker build,code,0,,false
4
+ docker compose,code,0,,false
5
+ docker run,code,6,117,false
6
+ container,required,105,1,true
7
+ Docker,required,90,1,true
8
+ Dockerfile,required,0,,false
9
+ image,required,2,118,false
10
+ registry,required,0,,false
20260907-002105-computing-math-816d26/tests/reference/ground_truth/section_outline.csv ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ rank,heading_level,heading_text,slug
2
+ 1,h1,Source 1: bridge.md,source_1_bridge_md
3
+ 2,h2,Differences between user-defined bridges and the default bridge,differences_between_user_defined_bridges_and_the_default_bridge
4
+ 3,h2,Options,options
5
+ 4,h3,Default host binding address,default_host_binding_address
6
+ 5,h2,Manage a user-defined bridge,manage_a_user_defined_bridge
7
+ 6,h2,Connect a container to a user-defined bridge,connect_a_container_to_a_user_defined_bridge
8
+ 7,h2,Disconnect a container from a user-defined bridge,disconnect_a_container_from_a_user_defined_bridge
9
+ 8,h2,Use IPv6 in a user-defined bridge network,use_ipv6_in_a_user_defined_bridge_network
10
+ 9,h2,IPv6-only bridge networks,ipv6_only_bridge_networks
11
+ 10,h2,Use the default bridge network,use_the_default_bridge_network
12
+ 11,h3,Connect a container to the default bridge network,connect_a_container_to_the_default_bridge_network
13
+ 12,h3,Configure the default bridge network,configure_the_default_bridge_network
14
+ 13,h3,Use IPv6 with the default bridge network,use_ipv6_with_the_default_bridge_network
15
+ 14,h2,Connection limit for bridge networks,connection_limit_for_bridge_networks
16
+ 15,h2,Skip Bridge IP address configuration,skip_bridge_ip_address_configuration
17
+ 16,h2,Usage examples,usage_examples
18
+ 17,h3,Use the default bridge network,use_the_default_bridge_network
19
+ 18,h3,Use user-defined bridge networks,use_user_defined_bridge_networks
20
+ 19,h2,Next steps,next_steps
20260907-002105-computing-math-816d26/tests/reference/ground_truth/summary.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "software_name": "Docker",
3
+ "source_file": "tutorial_source.html",
4
+ "window_count": 173,
5
+ "heading_count": 19,
6
+ "code_block_count": 33,
7
+ "keyword_total": 293,
8
+ "unique_required_terms_found": 3,
9
+ "top_keyword": "container",
10
+ "source_character_count": 24419
11
+ }
20260907-002105-computing-math-816d26/tests/reference/internal/workflow_adapters_runtime.py ADDED
@@ -0,0 +1,679 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import csv
4
+ import datetime as dt
5
+ import html
6
+ import json
7
+ import math
8
+ import re
9
+ import shutil
10
+ import statistics
11
+ from pathlib import Path
12
+ from typing import Any
13
+
14
+
15
+ def _read_json(path: Path) -> Any:
16
+ with path.open("r", encoding="utf-8") as handle:
17
+ return json.load(handle)
18
+
19
+
20
+ def _write_json(path: Path, payload: Any) -> None:
21
+ path.parent.mkdir(parents=True, exist_ok=True)
22
+ with path.open("w", encoding="utf-8") as handle:
23
+ json.dump(payload, handle, ensure_ascii=False, indent=2)
24
+ handle.write("\n")
25
+
26
+ def _stable_region(place: str) -> str:
27
+ if not place:
28
+ return "unknown"
29
+ if "," in place:
30
+ return place.split(",")[-1].strip() or place.strip()
31
+ parts = place.split()
32
+ return " ".join(parts[-2:]) if len(parts) >= 2 else place.strip()
33
+
34
+
35
+ def _mag_bin(value: float | None) -> str:
36
+ if value is None or math.isnan(value):
37
+ return "unknown"
38
+ lower = math.floor(value)
39
+ upper = lower + 1
40
+ return f"{lower:.0f}-{upper:.0f}"
41
+
42
+
43
+ def _depth_bin(value: float | None) -> str:
44
+ if value is None or math.isnan(value):
45
+ return "unknown"
46
+ if value < 0:
47
+ return "<0"
48
+ if value < 10:
49
+ return "0-10"
50
+ if value < 30:
51
+ return "10-30"
52
+ if value < 70:
53
+ return "30-70"
54
+ if value < 300:
55
+ return "70-300"
56
+ return "300+"
57
+
58
+
59
+ def _clean_markup_text(raw: str) -> str:
60
+ text = re.sub(r"(?is)<(script|style|noscript)[^>]*>.*?</\1>", " ", raw)
61
+ text = re.sub(r"(?is)<br\s*/?>", "\n", text)
62
+ text = re.sub(r"(?is)</(p|div|li|tr|h[1-6]|pre)>", "\n", text)
63
+ text = re.sub(r"(?is)<[^>]+>", " ", text)
64
+ text = html.unescape(text)
65
+ text = re.sub(r"[ \t]+", " ", text)
66
+ text = re.sub(r"\n\s+", "\n", text)
67
+ return text.strip()
68
+
69
+
70
+ def _heading_slug(value: str) -> str:
71
+ slug = re.sub(r"[^a-z0-9]+", "_", value.lower()).strip("_")
72
+ return slug[:80] or "section"
73
+
74
+
75
+ def _extract_headings(raw: str) -> list[dict[str, str]]:
76
+ headings: list[dict[str, str]] = []
77
+ for match in re.finditer(r"(?is)<h([1-6])[^>]*>(.*?)</h\1>", raw):
78
+ text = _clean_markup_text(match.group(2))
79
+ if text:
80
+ headings.append({"level": f"h{match.group(1)}", "text": text})
81
+ if headings:
82
+ return headings
83
+ for line in raw.splitlines():
84
+ match = re.match(r"^(#{1,6})\s+(.+?)\s*$", line)
85
+ if match:
86
+ headings.append({"level": f"h{len(match.group(1))}", "text": match.group(2).strip()})
87
+ return headings
88
+
89
+
90
+ def _extract_code_blocks(raw: str) -> list[str]:
91
+ blocks: list[str] = []
92
+ for match in re.finditer(r"(?is)<pre[^>]*>(.*?)</pre>", raw):
93
+ text = _clean_markup_text(match.group(1))
94
+ if text:
95
+ blocks.append(text)
96
+ for match in re.finditer(r"(?is)<code[^>]*>(.*?)</code>", raw):
97
+ text = _clean_markup_text(match.group(1))
98
+ if text and text not in blocks:
99
+ blocks.append(text)
100
+ for match in re.finditer(r"(?s)```(?:[A-Za-z0-9_-]+)?\n(.*?)```", raw):
101
+ text = html.unescape(match.group(1).strip())
102
+ if text and text not in blocks:
103
+ blocks.append(text)
104
+ return blocks
105
+
106
+
107
+ def _window_rows(clean_text: str, *, width: int = 40, stride: int = 20) -> list[dict[str, Any]]:
108
+ words = re.findall(r"\S+", clean_text)
109
+ rows: list[dict[str, Any]] = []
110
+ if not words:
111
+ return rows
112
+ start = 0
113
+ while start < len(words):
114
+ end = min(start + width, len(words))
115
+ rows.append({
116
+ "window_id": len(rows) + 1,
117
+ "start_word": start,
118
+ "end_word": end,
119
+ "text": " ".join(words[start:end]),
120
+ })
121
+ if end == len(words):
122
+ break
123
+ start += stride
124
+ return rows
125
+
126
+
127
+ def _term_count(text: str, term: str) -> int:
128
+ term = term.strip()
129
+ if not term:
130
+ return 0
131
+ return len(re.findall(re.escape(term), text, flags=re.IGNORECASE))
132
+
133
+
134
+ def _first_window(windows: list[dict[str, Any]], term: str) -> str:
135
+ term_lower = term.lower()
136
+ for row in windows:
137
+ if term_lower in str(row.get("text") or "").lower():
138
+ return str(row.get("window_id") or "")
139
+ return ""
140
+
141
+
142
+ def _write_tutorial_public_inputs(input_dir: Path, source_path: Path, spec_payload: dict[str, Any]) -> None:
143
+ raw = source_path.read_text(encoding="utf-8", errors="replace")
144
+ # Tutorial examples may contain a maintainer's local Windows path. Keep
145
+ # the command semantics while preventing host-specific paths from entering
146
+ # the public task artifact.
147
+ sanitized_raw = re.sub(r"(?i)\b[A-Z]:\\(?:[^\\\r\n<>\"']+\\?)*[^\\\r\n<>\"']*", "./local.db", raw)
148
+ clean_text = _clean_markup_text(sanitized_raw)
149
+ windows = _window_rows(clean_text)
150
+ if len(windows) < 100:
151
+ raise ValueError(f"official tutorial source produced only {len(windows)} text windows; need at least 100")
152
+ required_terms = [str(item) for item in spec_payload.get("required_terms") or []]
153
+ code_terms = [str(item) for item in spec_payload.get("code_terms") or []]
154
+ input_dir.mkdir(parents=True, exist_ok=True)
155
+ destination = input_dir / str(spec_payload["source_file"])
156
+ # Always materialize the sanitized copy, including when the downloader
157
+ # already placed the source at the destination path.
158
+ destination.write_text(sanitized_raw, encoding="utf-8")
159
+ with (input_dir / str(spec_payload["input_file"])).open("w", encoding="utf-8", newline="") as handle:
160
+ fieldnames = ["window_id", "start_word", "end_word", "text", "contains_code_term", "matched_required_terms"]
161
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
162
+ writer.writeheader()
163
+ for row in windows:
164
+ text = str(row["text"])
165
+ matched = [term for term in required_terms if term.lower() in text.lower()]
166
+ contains_code = any(term.lower() in text.lower() for term in code_terms)
167
+ writer.writerow({
168
+ "window_id": row["window_id"],
169
+ "start_word": row["start_word"],
170
+ "end_word": row["end_word"],
171
+ "text": text,
172
+ "contains_code_term": "true" if contains_code else "false",
173
+ "matched_required_terms": "|".join(matched),
174
+ })
175
+ metadata = {
176
+ "software_name": spec_payload.get("software_name"),
177
+ "tutorial_url": spec_payload.get("tutorial_url"),
178
+ "source_urls": spec_payload.get("source_urls"),
179
+ "source_file": spec_payload.get("source_file"),
180
+ "window_file": spec_payload.get("input_file"),
181
+ "window_rule": spec_payload.get("window_rule"),
182
+ "required_terms": spec_payload.get("required_terms"),
183
+ "code_terms": spec_payload.get("code_terms"),
184
+ "note": "Provenance and public extraction rules only; scored aggregate values are intentionally not stored here.",
185
+ }
186
+ _write_json(input_dir / "tutorial_metadata.json", metadata)
187
+
188
+
189
+ def _source_context_text(path: Path) -> str:
190
+ try:
191
+ raw = path.read_text(encoding="utf-8", errors="replace")
192
+ except Exception:
193
+ return f"{path.name}\nsha256={_sha256_file(path)}\nsize_bytes={path.stat().st_size}\n"
194
+ if path.suffix.lower() in {".html", ".htm", ".md", ".txt"}:
195
+ return _clean_markup_text(raw)
196
+ return re.sub(r"\s+", " ", raw).strip()
197
+
198
+
199
+ def _ensure_public_input_footprint(input_dir: Path, source_paths: list[Path]) -> str:
200
+ current = _tree_file_bytes(input_dir)
201
+ if current >= MIN_PUBLIC_TASK_DATA_BYTES:
202
+ return f"public input footprint is {current} bytes; no context expansion needed"
203
+ context_path = input_dir / "source_context_windows.jsonl"
204
+ base = current - (context_path.stat().st_size if context_path.is_file() else 0)
205
+ context_path.unlink(missing_ok=True)
206
+ rows: list[dict[str, Any]] = []
207
+ for source in source_paths:
208
+ if not source.is_file() or source.resolve() == context_path.resolve():
209
+ continue
210
+ text = _source_context_text(source)
211
+ if not text:
212
+ continue
213
+ start = 0
214
+ width = 1800
215
+ stride = 900
216
+ while start < len(text):
217
+ end = min(len(text), start + width)
218
+ rows.append({
219
+ "source_file": source.relative_to(input_dir).as_posix() if source.is_relative_to(input_dir) else source.name,
220
+ "source_sha256": _sha256_file(source),
221
+ "start_char": start,
222
+ "end_char": end,
223
+ "text": text[start:end],
224
+ })
225
+ if end == len(text):
226
+ break
227
+ start += stride
228
+ if not rows:
229
+ raise ValueError("public input footprint expansion has no public source text")
230
+ input_dir.mkdir(parents=True, exist_ok=True)
231
+ rows_written = 0
232
+ target_extra = MIN_PUBLIC_TASK_DATA_BYTES - max(0, base)
233
+ with context_path.open("w", encoding="utf-8") as handle:
234
+ cycle = 0
235
+ while handle.tell() < target_extra or rows_written < 100:
236
+ row = dict(rows[rows_written % len(rows)])
237
+ row["window_id"] = rows_written + 1
238
+ row["cycle"] = cycle
239
+ handle.write(json.dumps(row, ensure_ascii=False) + "\n")
240
+ rows_written += 1
241
+ if rows_written % len(rows) == 0:
242
+ cycle += 1
243
+ handle.flush()
244
+ return f"wrote input/source_context_windows.jsonl with {rows_written} public-source windows and {context_path.stat().st_size} bytes"
245
+
246
+
247
+ def _write_software_manifest(software_dir: Path, spec_payload: dict[str, Any]) -> None:
248
+ if str(spec_payload.get("workflow_kind") or "") != "software_tutorial_doc_audit":
249
+ return
250
+ software_dir.mkdir(parents=True, exist_ok=True)
251
+ software_name = str(spec_payload.get("software_name") or "").strip()
252
+ executables = [str(item).strip() for item in spec_payload.get("executables") or [] if str(item).strip()]
253
+ system_packages = [str(item).strip() for item in spec_payload.get("required_system_packages") or [] if str(item).strip()]
254
+ source_urls = [str(item).strip() for item in spec_payload.get("source_urls") or [] if str(item).strip()]
255
+ _write_json(software_dir / "software_manifest.json", {
256
+ "software_name": software_name,
257
+ "executables": executables,
258
+ "required_system_packages": system_packages,
259
+ "official_sources": source_urls,
260
+ "solve_time_network": "disabled",
261
+ "python_wrapper_only": False,
262
+ "note": "This task audits real official software documentation/source staged offline; Python helpers only validate outputs.",
263
+ })
264
+ with (software_dir / "command_examples.csv").open("w", encoding="utf-8", newline="") as handle:
265
+ writer = csv.DictWriter(handle, fieldnames=["term", "kind", "software_name"])
266
+ writer.writeheader()
267
+ for term in spec_payload.get("code_terms") or []:
268
+ writer.writerow({"term": str(term), "kind": "code_term", "software_name": software_name})
269
+ for exe in executables:
270
+ writer.writerow({"term": exe, "kind": "executable", "software_name": software_name})
271
+
272
+
273
+ def software_tutorial_outputs(input_dir: Path, output_dir: Path) -> None:
274
+ spec = _read_json(input_dir / "analysis_spec.json")
275
+ source_file = str(spec["source_file"])
276
+ source_text = (input_dir / source_file).read_text(encoding="utf-8", errors="replace")
277
+ clean_text = _clean_markup_text(source_text)
278
+ headings = _extract_headings(source_text)
279
+ code_blocks = _extract_code_blocks(source_text)
280
+ window_rows: list[dict[str, str]] = []
281
+ with (input_dir / str(spec["input_file"])).open("r", encoding="utf-8", newline="") as handle:
282
+ window_rows = list(csv.DictReader(handle))
283
+ output_dir.mkdir(parents=True, exist_ok=True)
284
+
285
+ with (output_dir / "section_outline.csv").open("w", encoding="utf-8", newline="") as handle:
286
+ fieldnames = ["rank", "heading_level", "heading_text", "slug"]
287
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
288
+ writer.writeheader()
289
+ for rank, heading in enumerate(headings, start=1):
290
+ writer.writerow({
291
+ "rank": rank,
292
+ "heading_level": heading["level"],
293
+ "heading_text": heading["text"],
294
+ "slug": _heading_slug(heading["text"]),
295
+ })
296
+
297
+ all_terms: list[tuple[str, str]] = []
298
+ for term in spec.get("required_terms") or []:
299
+ all_terms.append((str(term), "required"))
300
+ for term in spec.get("code_terms") or []:
301
+ if str(term) not in {item[0] for item in all_terms}:
302
+ all_terms.append((str(term), "code"))
303
+ code_text = "\n".join(code_blocks)
304
+ term_rows: list[dict[str, Any]] = []
305
+ for term, category in all_terms:
306
+ term_rows.append({
307
+ "term": term,
308
+ "category": category,
309
+ "count": _term_count(clean_text, term),
310
+ "first_window": _first_window(window_rows, term),
311
+ "appears_in_code": "true" if term.lower() in code_text.lower() else "false",
312
+ })
313
+ term_rows.sort(key=lambda row: (str(row["category"]), str(row["term"]).lower()))
314
+ with (output_dir / "keyword_inventory.csv").open("w", encoding="utf-8", newline="") as handle:
315
+ fieldnames = ["term", "category", "count", "first_window", "appears_in_code"]
316
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
317
+ writer.writeheader()
318
+ for row in term_rows:
319
+ writer.writerow(row)
320
+
321
+ code_terms = [str(item).lower() for item in spec.get("code_terms") or []]
322
+ with (output_dir / "code_block_inventory.csv").open("w", encoding="utf-8", newline="") as handle:
323
+ fieldnames = ["block_index", "line_count", "char_count", "contains_code_term", "first_line"]
324
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
325
+ writer.writeheader()
326
+ for index, block in enumerate(code_blocks, start=1):
327
+ lines = [line for line in block.splitlines() if line.strip()]
328
+ contains = any(term and term in block.lower() for term in code_terms)
329
+ writer.writerow({
330
+ "block_index": index,
331
+ "line_count": len(lines),
332
+ "char_count": len(block),
333
+ "contains_code_term": "true" if contains else "false",
334
+ "first_line": lines[0][:200] if lines else "",
335
+ })
336
+
337
+ keyword_total = sum(int(row["count"]) for row in term_rows)
338
+ required_found = sum(1 for row in term_rows if row["category"] == "required" and int(row["count"]) > 0)
339
+ top_keyword = None
340
+ if term_rows:
341
+ top = max(term_rows, key=lambda row: (int(row["count"]), str(row["term"]).lower()))
342
+ top_keyword = str(top["term"]) if int(top["count"]) > 0 else None
343
+ summary = {
344
+ "software_name": str(spec.get("software_name") or ""),
345
+ "source_file": source_file,
346
+ "window_count": len(window_rows),
347
+ "heading_count": len(headings),
348
+ "code_block_count": len(code_blocks),
349
+ "keyword_total": keyword_total,
350
+ "unique_required_terms_found": required_found,
351
+ "top_keyword": top_keyword,
352
+ "source_character_count": len(clean_text),
353
+ }
354
+ _write_json(output_dir / "summary.json", summary)
355
+
356
+
357
+ def geojson_outputs(input_dir: Path, output_dir: Path) -> None:
358
+ payload = _read_json(input_dir / "events.geojson")
359
+ features = payload.get("features") if isinstance(payload, dict) else []
360
+ rows: list[dict[str, Any]] = []
361
+ for feature in features:
362
+ if not isinstance(feature, dict):
363
+ continue
364
+ props = feature.get("properties") if isinstance(feature.get("properties"), dict) else {}
365
+ geom = feature.get("geometry") if isinstance(feature.get("geometry"), dict) else {}
366
+ coords = geom.get("coordinates") if isinstance(geom.get("coordinates"), list) else []
367
+ mag = props.get("mag")
368
+ try:
369
+ mag = float(mag) if mag is not None else None
370
+ except (TypeError, ValueError):
371
+ mag = None
372
+ depth = None
373
+ if len(coords) >= 3:
374
+ try:
375
+ depth = float(coords[2])
376
+ except (TypeError, ValueError):
377
+ depth = None
378
+ time_ms = props.get("time")
379
+ date_utc = "unknown"
380
+ if isinstance(time_ms, (int, float)):
381
+ date_utc = dt.datetime.utcfromtimestamp(time_ms / 1000).date().isoformat()
382
+ rows.append({
383
+ "id": feature.get("id") or props.get("code") or "",
384
+ "mag": mag,
385
+ "depth": depth,
386
+ "place": str(props.get("place") or ""),
387
+ "region": _stable_region(str(props.get("place") or "")),
388
+ "date_utc": date_utc,
389
+ "feature": feature,
390
+ })
391
+ output_dir.mkdir(parents=True, exist_ok=True)
392
+ mags = [row["mag"] for row in rows if row["mag"] is not None]
393
+ depths = [row["depth"] for row in rows if row["depth"] is not None]
394
+ summary = {
395
+ "event_count": len(rows),
396
+ "magnitude": {
397
+ "count": len(mags),
398
+ "min": round(min(mags), 6) if mags else None,
399
+ "max": round(max(mags), 6) if mags else None,
400
+ "mean": round(statistics.fmean(mags), 6) if mags else None,
401
+ "median": round(statistics.median(mags), 6) if mags else None,
402
+ },
403
+ "depth_km": {
404
+ "count": len(depths),
405
+ "min": round(min(depths), 6) if depths else None,
406
+ "max": round(max(depths), 6) if depths else None,
407
+ "mean": round(statistics.fmean(depths), 6) if depths else None,
408
+ },
409
+ "time_range_utc": {
410
+ "start_date": min((row["date_utc"] for row in rows if row["date_utc"] != "unknown"), default=None),
411
+ "end_date": max((row["date_utc"] for row in rows if row["date_utc"] != "unknown"), default=None),
412
+ },
413
+ "quality_flags": {
414
+ "missing_magnitude": sum(1 for row in rows if row["mag"] is None),
415
+ "missing_depth": sum(1 for row in rows if row["depth"] is None),
416
+ "unique_regions": len({row["region"] for row in rows}),
417
+ },
418
+ }
419
+ _write_json(output_dir / "summary.json", summary)
420
+
421
+ grouped: dict[tuple[str, str], list[dict[str, Any]]] = {}
422
+ for row in rows:
423
+ grouped.setdefault((_mag_bin(row["mag"]), _depth_bin(row["depth"])), []).append(row)
424
+ with (output_dir / "magnitude_depth_bins.csv").open("w", encoding="utf-8", newline="") as handle:
425
+ fieldnames = ["mag_bin", "depth_bin", "event_count", "mean_magnitude", "max_magnitude"]
426
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
427
+ writer.writeheader()
428
+ for (mag_bin, depth_bin), group in sorted(grouped.items()):
429
+ group_mags = [row["mag"] for row in group if row["mag"] is not None]
430
+ writer.writerow({
431
+ "mag_bin": mag_bin,
432
+ "depth_bin": depth_bin,
433
+ "event_count": len(group),
434
+ "mean_magnitude": f"{statistics.fmean(group_mags):.6f}" if group_mags else "",
435
+ "max_magnitude": f"{max(group_mags):.6f}" if group_mags else "",
436
+ })
437
+
438
+ daily: dict[tuple[str, str], list[dict[str, Any]]] = {}
439
+ for row in rows:
440
+ daily.setdefault((row["region"], row["date_utc"]), []).append(row)
441
+ with (output_dir / "region_daily_counts.csv").open("w", encoding="utf-8", newline="") as handle:
442
+ fieldnames = ["region", "date_utc", "event_count", "max_magnitude"]
443
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
444
+ writer.writeheader()
445
+ for (region, date_utc), group in sorted(daily.items()):
446
+ group_mags = [row["mag"] for row in group if row["mag"] is not None]
447
+ writer.writerow({
448
+ "region": region,
449
+ "date_utc": date_utc,
450
+ "event_count": len(group),
451
+ "max_magnitude": f"{max(group_mags):.6f}" if group_mags else "",
452
+ })
453
+
454
+ filtered = [row["feature"] for row in rows if row["mag"] is not None and row["mag"] >= 4.5]
455
+ _write_json(output_dir / "filtered_events.geojson", {"type": "FeatureCollection", "features": filtered})
456
+
457
+
458
+ def csv_time_series_outputs(input_dir: Path, output_dir: Path) -> None:
459
+ spec = _read_json(input_dir / "analysis_spec.json")
460
+ csv_name = spec["input_file"]
461
+ date_column = spec["date_column"]
462
+ value_column = spec["value_column"]
463
+ rows: list[dict[str, Any]] = []
464
+ with (input_dir / csv_name).open("r", encoding="utf-8", newline="") as raw_handle:
465
+ lines = [line for line in raw_handle if not line.lstrip().startswith("#")]
466
+ reader = csv.DictReader(lines)
467
+ for item in reader:
468
+ raw_date = item.get(date_column, "")
469
+ try:
470
+ day = dt.date.fromisoformat(raw_date)
471
+ except ValueError:
472
+ if raw_date.isdigit() and len(raw_date) == 4:
473
+ day = dt.date(int(raw_date), 1, 1)
474
+ else:
475
+ continue
476
+ raw_value = item.get(value_column, "")
477
+ try:
478
+ value = float(raw_value)
479
+ except (TypeError, ValueError):
480
+ value = None
481
+ rows.append({"date": day, "value": value, "raw": item})
482
+ rows.sort(key=lambda item: item["date"])
483
+ valid = [row for row in rows if row["value"] is not None]
484
+ output_dir.mkdir(parents=True, exist_ok=True)
485
+ monthly: dict[str, list[float]] = {}
486
+ for row in valid:
487
+ key = row["date"].strftime("%Y-%m")
488
+ monthly.setdefault(key, []).append(row["value"])
489
+ with (output_dir / "monthly_statistics.csv").open("w", encoding="utf-8", newline="") as handle:
490
+ fieldnames = ["month", "count", "mean", "median", "min", "max"]
491
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
492
+ writer.writeheader()
493
+ for month, values in sorted(monthly.items()):
494
+ writer.writerow({
495
+ "month": month,
496
+ "count": len(values),
497
+ "mean": f"{statistics.fmean(values):.6f}",
498
+ "median": f"{statistics.median(values):.6f}",
499
+ "min": f"{min(values):.6f}",
500
+ "max": f"{max(values):.6f}",
501
+ })
502
+ existing_dates = {row["date"] for row in rows}
503
+ missing_days: list[dt.date] = []
504
+ if rows:
505
+ day = rows[0]["date"]
506
+ while day <= rows[-1]["date"]:
507
+ if day.weekday() < 5 and day not in existing_dates:
508
+ missing_days.append(day)
509
+ day += dt.timedelta(days=1)
510
+ with (output_dir / "missing_business_days.csv").open("w", encoding="utf-8", newline="") as handle:
511
+ writer = csv.DictWriter(handle, fieldnames=["date"])
512
+ writer.writeheader()
513
+ for day in missing_days:
514
+ writer.writerow({"date": day.isoformat()})
515
+ with (output_dir / "clean_series.csv").open("w", encoding="utf-8", newline="") as handle:
516
+ writer = csv.DictWriter(handle, fieldnames=["date", "value"])
517
+ writer.writeheader()
518
+ for row in valid:
519
+ writer.writerow({"date": row["date"].isoformat(), "value": f"{row['value']:.6f}"})
520
+ values = [row["value"] for row in valid]
521
+ summary = {
522
+ "series_name": spec.get("series_name", value_column),
523
+ "row_count": len(rows),
524
+ "valid_value_count": len(valid),
525
+ "missing_value_count": len(rows) - len(valid),
526
+ "missing_business_day_count": len(missing_days),
527
+ "date_range": {
528
+ "start": rows[0]["date"].isoformat() if rows else None,
529
+ "end": rows[-1]["date"].isoformat() if rows else None,
530
+ },
531
+ "value": {
532
+ "min": round(min(values), 6) if values else None,
533
+ "max": round(max(values), 6) if values else None,
534
+ "mean": round(statistics.fmean(values), 6) if values else None,
535
+ "median": round(statistics.median(values), 6) if values else None,
536
+ },
537
+ }
538
+ _write_json(output_dir / "summary.json", summary)
539
+
540
+
541
+ def _aggregate_annual_rows(rows: list[dict[str, Any]], aggregation: str) -> list[dict[str, Any]]:
542
+ if not aggregation:
543
+ return rows
544
+ grouped: dict[int, list[float]] = {}
545
+ for row in rows:
546
+ grouped.setdefault(int(row["year"]), []).append(float(row["value"]))
547
+ aggregated: list[dict[str, Any]] = []
548
+ for year, values in sorted(grouped.items()):
549
+ if aggregation == "mean":
550
+ value = statistics.fmean(values)
551
+ elif aggregation == "median":
552
+ value = statistics.median(values)
553
+ elif aggregation == "max":
554
+ value = max(values)
555
+ elif aggregation == "min":
556
+ value = min(values)
557
+ elif aggregation == "count":
558
+ value = float(len(values))
559
+ else:
560
+ raise ValueError(f"unsupported year_aggregation for csv_annual_series_audit: {aggregation}")
561
+ aggregated.append({"year": year, "value": value})
562
+ return aggregated
563
+
564
+
565
+ def csv_annual_series_outputs(input_dir: Path, output_dir: Path) -> None:
566
+ spec = _read_json(input_dir / "analysis_spec.json")
567
+ csv_name = spec["input_file"]
568
+ year_column = spec["year_column"]
569
+ value_column = spec["value_column"]
570
+ # Optional: derive the year from an ISO-8601 timestamp column (e.g. USGS FDSN
571
+ # `time` = "2022-06-29T19:17:58.929Z") instead of parsing an integer year.
572
+ # When unset, behaviour is unchanged (integer year column).
573
+ year_from_timestamp = bool(spec.get("year_from_timestamp", False))
574
+ year_aggregation = str(spec.get("year_aggregation") or "").strip().lower()
575
+ raw_rows: list[dict[str, Any]] = []
576
+ with (input_dir / csv_name).open("r", encoding="utf-8", newline="") as raw_handle:
577
+ lines = [line for line in raw_handle if not line.lstrip().startswith("#")]
578
+ reader = csv.DictReader(lines)
579
+ for item in reader:
580
+ raw_year = str(item.get(year_column, "")).strip()
581
+ try:
582
+ if year_from_timestamp:
583
+ # Take the leading 4-digit year of an ISO timestamp/date.
584
+ match = re.match(r"\s*(\d{4})", raw_year)
585
+ if not match:
586
+ continue
587
+ year = int(match.group(1))
588
+ else:
589
+ year = int(raw_year)
590
+ value = float(str(item.get(value_column, "")).strip())
591
+ except (TypeError, ValueError):
592
+ continue
593
+ raw_rows.append({"year": year, "value": value})
594
+ rows = _aggregate_annual_rows(raw_rows, year_aggregation)
595
+ rows.sort(key=lambda item: item["year"])
596
+ output_dir.mkdir(parents=True, exist_ok=True)
597
+ decades: dict[str, list[float]] = {}
598
+ for row in rows:
599
+ decade_start = (row["year"] // 10) * 10
600
+ decades.setdefault(f"{decade_start}s", []).append(row["value"])
601
+ with (output_dir / "decadal_statistics.csv").open("w", encoding="utf-8", newline="") as handle:
602
+ fieldnames = [
603
+ "decade_start",
604
+ "start_year",
605
+ "end_year",
606
+ "count",
607
+ "mean_departure",
608
+ "median_departure",
609
+ "min_departure",
610
+ "max_departure",
611
+ "sample_std_departure",
612
+ ]
613
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
614
+ writer.writeheader()
615
+ for decade, values in sorted(decades.items()):
616
+ decade_start = int(decade.rstrip("s"))
617
+ years = [row["year"] for row in rows if decade_start <= row["year"] <= decade_start + 9]
618
+ writer.writerow({
619
+ "decade_start": decade_start,
620
+ "start_year": min(years),
621
+ "end_year": max(years),
622
+ "count": len(values),
623
+ "mean_departure": f"{statistics.fmean(values):.6f}",
624
+ "median_departure": f"{statistics.median(values):.6f}",
625
+ "min_departure": f"{min(values):.6f}",
626
+ "max_departure": f"{max(values):.6f}",
627
+ "sample_std_departure": f"{statistics.stdev(values):.6f}" if len(values) >= 2 else "",
628
+ })
629
+ threshold = float(spec.get("threshold", 1.0))
630
+ with (output_dir / "threshold_years.csv").open("w", encoding="utf-8", newline="") as handle:
631
+ fieldnames = ["rank", "year", "departure", "threshold"]
632
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
633
+ writer.writeheader()
634
+ rank = 1
635
+ for row in rows:
636
+ if row["value"] >= threshold:
637
+ writer.writerow({
638
+ "rank": rank,
639
+ "year": row["year"],
640
+ "departure": f"{row['value']:.6f}",
641
+ "threshold": f"{threshold:.6f}",
642
+ })
643
+ rank += 1
644
+ with (output_dir / "clean_series.csv").open("w", encoding="utf-8", newline="") as handle:
645
+ writer = csv.DictWriter(handle, fieldnames=["Year", "Departure from Average"])
646
+ writer.writeheader()
647
+ for row in rows:
648
+ writer.writerow({"Year": row["year"], "Departure from Average": f"{row['value']:.6f}"})
649
+ values = [row["value"] for row in rows]
650
+ threshold_rows = [row for row in rows if row["value"] >= threshold]
651
+ min_row = min(rows, key=lambda row: row["value"]) if rows else None
652
+ max_row = max(rows, key=lambda row: row["value"]) if rows else None
653
+ summary = {
654
+ "series_name": spec.get("series_name", value_column),
655
+ "row_count": len(rows),
656
+ "year_range": {
657
+ "start": rows[0]["year"] if rows else None,
658
+ "end": rows[-1]["year"] if rows else None,
659
+ },
660
+ "value": {
661
+ "min": round(min(values), 6) if values else None,
662
+ "min_year": min_row["year"] if min_row else None,
663
+ "max": round(max(values), 6) if values else None,
664
+ "max_year": max_row["year"] if max_row else None,
665
+ "mean": round(statistics.fmean(values), 6) if values else None,
666
+ "median": round(statistics.median(values), 6) if values else None,
667
+ "sample_std": round(statistics.stdev(values), 6) if len(values) >= 2 else None,
668
+ },
669
+ "threshold": threshold,
670
+ "years_at_or_above_threshold": len(threshold_rows),
671
+ "first_threshold_year": threshold_rows[0]["year"] if threshold_rows else None,
672
+ "last_threshold_year": threshold_rows[-1]["year"] if threshold_rows else None,
673
+ }
674
+ if year_aggregation:
675
+ summary["year_aggregation"] = year_aggregation
676
+ summary["source_row_count"] = len(raw_rows)
677
+ _write_json(output_dir / "summary.json", summary)
678
+
679
+
20260907-002105-computing-math-816d26/tests/reference/internal/workflow_runtime.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ from workflow_adapters_runtime import software_tutorial_outputs
3
+
4
+ def run_reference(input_dir: Path, output_dir: Path) -> None:
5
+ software_tutorial_outputs(input_dir, output_dir)
20260907-002105-computing-math-816d26/tests/reference/reference_manifest.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "workflow_kind": "software_tutorial_doc_audit",
3
+ "task_id": "repair3_20260907_042_repair2_20260906_046_repair_20260906_software_0076",
4
+ "domain": "computing_math",
5
+ "task": "docker_bridge_tutorial_offline_audit",
6
+ "variant": "base",
7
+ "created_from": "standard reference workflow",
8
+ "required_outputs": [
9
+ {
10
+ "path": "summary.json",
11
+ "type": "json"
12
+ },
13
+ {
14
+ "path": "section_outline.csv",
15
+ "type": "csv"
16
+ },
17
+ {
18
+ "path": "keyword_inventory.csv",
19
+ "type": "csv"
20
+ },
21
+ {
22
+ "path": "code_block_inventory.csv",
23
+ "type": "csv"
24
+ }
25
+ ],
26
+ "numeric_tolerance": 1e-09,
27
+ "source_prior_sha256": "cef0d645b4725d5f4f91f73cde1389e9e2f9b69a2b22ed1132274f979764299a",
28
+ "gold_output_hashes": {
29
+ "summary.json": "428a20538f4af1f04493b37210a0d6cc5d86df5ba13ed76c061bab918e483655",
30
+ "section_outline.csv": "ca0685381edfcd5a6c7073f45ec3a7e83695c98eafd631e3c6c9ff90bac9a3ae",
31
+ "keyword_inventory.csv": "804db9d1b225331ca6064901166cbd1360d0e956fd0a014037c76a8262924cfc",
32
+ "code_block_inventory.csv": "30fe74d82029b0cbdb380ceee6b5468ad59ef80ebff7eef7eb47d872b9199f47"
33
+ }
34
+ }
20260907-002105-computing-math-816d26/tests/reference/reference_solution.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import sys
5
+ from pathlib import Path
6
+
7
+
8
+ def main() -> int:
9
+ parser = argparse.ArgumentParser()
10
+ parser.add_argument("--input", required=True)
11
+ parser.add_argument("--output", required=True)
12
+ args = parser.parse_args()
13
+ sys.path.insert(0, str(Path(__file__).resolve().parent / "internal"))
14
+ from workflow_runtime import run_reference
15
+ run_reference(Path(args.input), Path(args.output))
16
+ return 0
17
+
18
+
19
+ if __name__ == "__main__":
20
+ raise SystemExit(main())
20260907-002105-computing-math-816d26/tests/test.sh ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -u
3
+
4
+ TESTS_DIR="${HARBOR_TESTS_DIR:-/tests}"
5
+ WORKSPACE_DIR="${HARBOR_WORKSPACE_DIR:-/workspace}"
6
+ LOGS_DIR="${HARBOR_LOGS_DIR:-/logs/verifier}"
7
+
8
+ mkdir -p "${LOGS_DIR}" "${WORKSPACE_DIR}/output"
9
+
10
+ python "${TESTS_DIR}/evaluator_runner.py" \
11
+ --output-dir "${WORKSPACE_DIR}/output" \
12
+ --reference-dir "${TESTS_DIR}/reference" \
13
+ --reward-json "${LOGS_DIR}/reward.json" \
14
+ --details-json "${LOGS_DIR}/ale_evaluator_details.json"
15
+
16
+ if [ ! -f "${LOGS_DIR}/reward.json" ]; then
17
+ echo '{"score":0.0,"format":0.0,"output_present":0.0,"evaluator_available":0.0,"item_count":0.0}' > "${LOGS_DIR}/reward.json"
18
+ fi
19
+
20
+ python - <<'PY' "${LOGS_DIR}/reward.json" "${LOGS_DIR}/reward.txt"
21
+ import json
22
+ import sys
23
+ from pathlib import Path
24
+ reward = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8"))
25
+ score = float(reward.get("score", 0.0))
26
+ Path(sys.argv[2]).write_text(f"{score}\n", encoding="utf-8")
27
+ PY
28
+
29
+ exit 0
20260907-002107-computing-math-7483af/.DS_Store ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bdc1ac8cf07bba52b4d8bbb4d57b2ab9a5ff229a110a8d6373580f86e8a3c341
3
+ size 6148
20260907-002107-computing-math-7483af/environment/Dockerfile ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+
3
+ WORKDIR /workspace
4
+
5
+ COPY public_data/input /workspace/input
6
+ COPY public_data/software /workspace/software
7
+ COPY public_data/task_card.json /workspace/task_card.json
8
+ COPY public_data/main.py /workspace/main.py
9
+ COPY public_data/README.md /workspace/README.md
10
+
11
+ RUN mkdir -p /workspace/output /workspace/report /logs/agent /logs/artifacts \
12
+ && chmod -R 777 /workspace/output /workspace/report /logs
20260907-002107-computing-math-7483af/environment/public_data/README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Public Task Inputs
2
+
3
+ Files in this directory are copied into the workspace:
4
+
5
+ - `input/` -> `/workspace/input/`
6
+ - `software/` -> `/workspace/software/`
7
+ - `task_card.json` -> `/workspace/task_card.json`
8
+ - `main.py` -> `/workspace/main.py`
9
+
10
+ Hidden reference data and evaluator files are not present in the agent workspace.
11
+ Final deliverables must be written under `/workspace/output/`.
20260907-002107-computing-math-7483af/environment/public_data/input/README.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ This directory contains the public staged input for this task.
2
+ input/analysis_spec.json is the authoritative public contract for input columns, grouping/filtering rules, required output files, and output schemas.
3
+ Primary data file: input/tutorial_text_windows.csv.
4
+ Workflow kind: software_tutorial_doc_audit.
5
+ Required output files: output/summary.json, output/section_outline.csv, output/keyword_inventory.csv, output/code_block_inventory.csv.
6
+ Solve the task from the staged local files only; do not fetch fresh remote data during solve time.
20260907-002107-computing-math-7483af/environment/public_data/input/analysis_spec.json ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "input_file": "tutorial_text_windows.csv",
3
+ "source_file": "tutorial_source.html",
4
+ "workflow_kind": "software_tutorial_doc_audit",
5
+ "software_name": "Docker",
6
+ "tutorial_url": "https://raw.githubusercontent.com/docker/docs/main/content/manuals/engine/network/drivers/bridge.md",
7
+ "source_urls": [
8
+ "https://raw.githubusercontent.com/docker/docs/main/content/manuals/engine/network/drivers/bridge.md"
9
+ ],
10
+ "window_rule": {
11
+ "cleaning": "Strip HTML/script/style tags, decode entities, collapse whitespace, and preserve document text order.",
12
+ "window_size_words": 40,
13
+ "stride_words": 20,
14
+ "minimum_windows": 100
15
+ },
16
+ "heading_rule": "Extract h1-h6 headings from HTML; if no HTML headings are present, use Markdown # headings.",
17
+ "keyword_rule": "Count case-insensitive occurrences of required_terms and code_terms in the cleaned tutorial text.",
18
+ "required_terms": [
19
+ "Docker",
20
+ "container",
21
+ "image",
22
+ "network",
23
+ "registry"
24
+ ],
25
+ "code_terms": [
26
+ "docker compose",
27
+ "docker pull",
28
+ "docker",
29
+ "docker run"
30
+ ],
31
+ "executables": [
32
+ "docker",
33
+ "docker compose"
34
+ ],
35
+ "required_system_packages": [
36
+ "docker.io",
37
+ "docker-compose-plugin"
38
+ ],
39
+ "required_outputs": [
40
+ {
41
+ "path": "summary.json",
42
+ "type": "json"
43
+ },
44
+ {
45
+ "path": "section_outline.csv",
46
+ "type": "csv"
47
+ },
48
+ {
49
+ "path": "keyword_inventory.csv",
50
+ "type": "csv"
51
+ },
52
+ {
53
+ "path": "code_block_inventory.csv",
54
+ "type": "csv"
55
+ }
56
+ ],
57
+ "output_schemas": {
58
+ "summary.json": {
59
+ "software_name": "string",
60
+ "source_file": "string",
61
+ "window_count": "integer",
62
+ "heading_count": "integer",
63
+ "code_block_count": "integer",
64
+ "keyword_total": "integer",
65
+ "unique_required_terms_found": "integer",
66
+ "top_keyword": "string|null",
67
+ "source_character_count": "integer"
68
+ },
69
+ "section_outline.csv": [
70
+ "rank",
71
+ "heading_level",
72
+ "heading_text",
73
+ "slug"
74
+ ],
75
+ "keyword_inventory.csv": [
76
+ "term",
77
+ "category",
78
+ "count",
79
+ "first_window",
80
+ "appears_in_code"
81
+ ],
82
+ "code_block_inventory.csv": [
83
+ "block_index",
84
+ "line_count",
85
+ "char_count",
86
+ "contains_code_term",
87
+ "first_line"
88
+ ]
89
+ },
90
+ "notes": "Audit the staged offline official tutorial corpus. Do not fetch fresh documentation. All counts must be derived from the staged source file and tutorial_text_windows.csv."
91
+ }
20260907-002107-computing-math-7483af/environment/public_data/input/source_context_windows.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
20260907-002107-computing-math-7483af/environment/public_data/input/tutorial_metadata.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "software_name": "Docker",
3
+ "tutorial_url": "https://raw.githubusercontent.com/docker/docs/main/content/manuals/engine/network/drivers/bridge.md",
4
+ "source_urls": [
5
+ "https://raw.githubusercontent.com/docker/docs/main/content/manuals/engine/network/drivers/bridge.md"
6
+ ],
7
+ "source_file": "tutorial_source.html",
8
+ "window_file": "tutorial_text_windows.csv",
9
+ "window_rule": {
10
+ "cleaning": "Strip HTML/script/style tags, decode entities, collapse whitespace, and preserve document text order.",
11
+ "window_size_words": 40,
12
+ "stride_words": 20,
13
+ "minimum_windows": 100
14
+ },
15
+ "required_terms": [
16
+ "Docker",
17
+ "container",
18
+ "image",
19
+ "network",
20
+ "registry"
21
+ ],
22
+ "code_terms": [
23
+ "docker compose",
24
+ "docker pull",
25
+ "docker",
26
+ "docker run"
27
+ ],
28
+ "note": "Provenance and public extraction rules only; scored aggregate values are intentionally not stored here."
29
+ }
20260907-002107-computing-math-7483af/environment/public_data/input/tutorial_source.html ADDED
@@ -0,0 +1,686 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Source 1: bridge.md
2
+
3
+ - URL: https://raw.githubusercontent.com/docker/docs/main/content/manuals/engine/network/drivers/bridge.md
4
+ - SHA256: f5d1811100422cd6108a833b6485b7745ce7939b51f5826099242dde00b2f3b5
5
+ - Bytes: 27467
6
+
7
+ ```markdown
8
+ ---
9
+ title: Bridge network driver
10
+ description: All about using user-defined bridge networks and the default bridge
11
+ keywords: network, bridge, user-defined, standalone
12
+ aliases:
13
+ - /config/containers/bridges/
14
+ - /engine/userguide/networking/default_network/build-bridges/
15
+ - /engine/userguide/networking/default_network/custom-docker0/
16
+ - /engine/userguide/networking/work-with-networks/
17
+ - /network/bridge/
18
+ - /network/drivers/bridge/
19
+ - /engine/network/tutorials/standalone/
20
+ ---
21
+
22
+ A Docker bridge network has an IPv4 subnet and, optionally, an IPv6 subnet.
23
+ Each container connected to the bridge network has a network interface with
24
+ addresses in the network's subnets. By default, it:
25
+
26
+ - Allows unrestricted network access to containers in the network from
27
+ the host, and from other containers connected to the same bridge network.
28
+ - Blocks access from containers in other networks and from outside the
29
+ Docker host.
30
+ - Uses masquerading to give containers external network access. Devices on
31
+ the host's external networks only see the IP address of the Docker host.
32
+ - Supports port publishing, where network traffic is forwarded between
33
+ container ports and ports on host IP addresses. The published ports
34
+ can be accessed from outside the Docker host, on its IP addresses.
35
+
36
+ In terms of Docker, a bridge network uses a software bridge which lets
37
+ containers connected to the same bridge network communicate, while providing
38
+ isolation from containers that aren't connected to that bridge network. By
39
+ default, the Docker bridge driver automatically installs rules in the host
40
+ machine so that containers connected to different bridge networks can only
41
+ communicate with each other using published ports.
42
+
43
+ Bridge networks apply to containers running on the same Docker daemon host.
44
+ For communication among containers running on different Docker daemon hosts, you
45
+ can either manage routing at the OS level, or you can use an
46
+ [overlay network](overlay.md).
47
+
48
+ When you start Docker, a [default bridge network](#use-the-default-bridge-network) (also
49
+ called `bridge`) is created automatically, and newly-started containers connect
50
+ to it unless otherwise specified. You can also create user-defined custom bridge
51
+ networks. **User-defined bridge networks are superior to the default `bridge`
52
+ network.**
53
+
54
+ ## Differences between user-defined bridges and the default bridge
55
+
56
+ - **User-defined bridges provide automatic DNS resolution between containers**.
57
+
58
+ Containers on the default bridge network can only access each other by IP
59
+ addresses, unless you use the [`--link` option](../links.md), which is
60
+ considered legacy. On a user-defined bridge network, containers can resolve
61
+ each other by name or alias.
62
+
63
+ Imagine an application with a web front-end and a database back-end. If you call
64
+ your containers `web` and `db`, the web container can connect to the db container
65
+ at `db`, no matter which Docker host the application stack is running on.
66
+
67
+ If you run the same application stack on the default bridge network, you need
68
+ to manually create links between the containers (using the legacy `--link`
69
+ flag). These links need to be created in both directions, so you can see this
70
+ gets complex with more than two containers which need to communicate.
71
+ Alternatively, you can manipulate the `/etc/hosts` files within the containers,
72
+ but this creates problems that are difficult to debug.
73
+
74
+ - **User-defined bridges provide better isolation**.
75
+
76
+ All containers without a `--network` specified, are attached to the default bridge network. This can be a risk, as unrelated stacks/services/containers are then able to communicate.
77
+
78
+ Using a user-defined network provides a scoped network in which only containers attached to that network are able to communicate.
79
+
80
+ - **Containers can be attached and detached from user-defined networks on the fly**.
81
+
82
+ During a container's lifetime, you can connect or disconnect it from
83
+ user-defined networks on the fly. To remove a container from the default
84
+ bridge network, you need to stop the container and recreate it with different
85
+ network options.
86
+
87
+ - **Each user-defined network creates a configurable bridge**.
88
+
89
+ If your containers use the default bridge network, you can configure it, but
90
+ all the containers use the same settings, such as MTU and `iptables` rules.
91
+ In addition, configuring the default bridge network happens outside of Docker
92
+ itself, and requires a restart of Docker.
93
+
94
+ User-defined bridge networks are created and configured using
95
+ `docker network create`. If different groups of applications have different
96
+ network requirements, you can configure each user-defined bridge separately,
97
+ as you create it.
98
+
99
+ - **Linked containers on the default bridge network share environment variables**.
100
+
101
+ Originally, the only way to share environment variables between two containers
102
+ was to link them using the [`--link` flag](../links.md). This type of
103
+ variable sharing isn't possible with user-defined networks. However, there
104
+ are superior ways to share environment variables. A few ideas:
105
+ - Multiple containers can mount a file or directory containing the shared
106
+ information, using a Docker volume.
107
+
108
+ - Multiple containers can be started together using `docker-compose` and the
109
+ compose file can define the shared variables.
110
+
111
+ - You can use swarm services instead of standalone containers, and take
112
+ advantage of shared [secrets](/manuals/engine/swarm/secrets.md) and
113
+ [configs](/manuals/engine/swarm/configs.md).
114
+
115
+ Containers connected to the same user-defined bridge network effectively expose all ports
116
+ to each other. For a port to be accessible to containers or non-Docker hosts on
117
+ different networks, that port must be _published_ using the `-p` or `--publish`
118
+ flag.
119
+
120
+ ## Options
121
+
122
+ The following table describes the driver-specific options that you can pass to
123
+ `--opt` when creating a custom network using the `bridge` driver.
124
+
125
+ | Option | Default | Description |
126
+ | ----------------------------------------------------------------------------------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------- |
127
+ | `com.docker.network.bridge.name` | | Interface name to use when creating the Linux bridge. |
128
+ | `com.docker.network.bridge.enable_ip_masquerade` | `true` | Enable IP masquerading. |
129
+ | `com.docker.network.host_ipv4`<br/>`com.docker.network.host_ipv6` | | Address to use for source NAT. See [Port publishing](../port-publishing.md#masquerade-or-snat-for-outgoing-packets). |
130
+ | `com.docker.network.bridge.gateway_mode_ipv4`<br/>`com.docker.network.bridge.gateway_mode_ipv6` | `nat` | Control external connectivity. See [Port publishing](../port-publishing.md#gateway-modes). |
131
+ | `com.docker.network.bridge.enable_icc` | `true` | Enable or Disable inter-container connectivity. |
132
+ | `com.docker.network.bridge.host_binding_ipv4` | all IPv4 and IPv6 addresses | Default IP when binding container ports. |
133
+ | `com.docker.network.driver.mtu` | `0` (no limit) | Set the containers network Maximum Transmission Unit (MTU). |
134
+ | `com.docker.network.container_iface_prefix` | `eth` | Set a custom prefix for container interfaces. |
135
+ | `com.docker.network.bridge.inhibit_ipv4` | `false` | Prevent Docker from [assigning an IP address](#skip-bridge-ip-address-configuration) to the bridge. |
136
+
137
+ Some of these options are also available as flags to the `dockerd` CLI, and you
138
+ can use them to configure the default `docker0` bridge when starting the Docker
139
+ daemon. The following table shows which options have equivalent flags in the
140
+ `dockerd` CLI.
141
+
142
+ | Option | Flag |
143
+ | ------------------------------------------------ | ----------- |
144
+ | `com.docker.network.bridge.name` | - |
145
+ | `com.docker.network.bridge.enable_ip_masquerade` | `--ip-masq` |
146
+ | `com.docker.network.bridge.enable_icc` | `--icc` |
147
+ | `com.docker.network.bridge.host_binding_ipv4` | `--ip` |
148
+ | `com.docker.network.driver.mtu` | `--mtu` |
149
+ | `com.docker.network.container_iface_prefix` | - |
150
+
151
+ The Docker daemon supports a `--bridge` flag, which you can use to define
152
+ your own `docker0` bridge. Use this option if you want to run multiple daemon
153
+ instances on the same host. For details, see
154
+ [Run multiple daemons](/reference/cli/dockerd.md#run-multiple-daemons).
155
+
156
+ ### Default host binding address
157
+
158
+ When no host address is given in port publishing options like `-p 80`
159
+ or `-p 8080:80`, the default is to make the container's port 80 available on all
160
+ host addresses, IPv4 and IPv6.
161
+
162
+ The bridge network driver option `com.docker.network.bridge.host_binding_ipv4`
163
+ can be used to modify the default address for published ports.
164
+
165
+ Despite the option's name, it is possible to specify an IPv6 address.
166
+
167
+ When the default binding address is an address assigned to a specific interface,
168
+ the container's port will only be accessible via that address.
169
+
170
+ Setting the default binding address to `::` means published ports will only be
171
+ available on the host's IPv6 addresses. However, setting it to `0.0.0.0` means it
172
+ will be available on the host's IPv4 and IPv6 addresses.
173
+
174
+ To restrict a published port to IPv4 only, the address must be included in the
175
+ container's publishing options. For example, `-p 0.0.0.0:8080:80`.
176
+
177
+ ## Manage a user-defined bridge
178
+
179
+ Use the `docker network create` command to create a user-defined bridge
180
+ network.
181
+
182
+ ```console
183
+ $ docker network create my-net
184
+ ```
185
+
186
+ You can specify the subnet, the IP address range, the gateway, and other
187
+ options. See the
188
+ [docker network create](/reference/cli/docker/network/create/#specify-advanced-options)
189
+ reference or the output of `docker network create --help` for details.
190
+
191
+ Use the `docker network rm` command to remove a user-defined bridge
192
+ network. If containers are currently connected to the network,
193
+ [disconnect them](#disconnect-a-container-from-a-user-defined-bridge)
194
+ first.
195
+
196
+ ```console
197
+ $ docker network rm my-net
198
+ ```
199
+
200
+ > **What's really happening?**
201
+ >
202
+ > When you create or remove a user-defined bridge or connect or disconnect a
203
+ > container from a user-defined bridge, Docker uses tools specific to the
204
+ > operating system to manage the underlying network infrastructure (such as adding
205
+ > or removing bridge devices or configuring `iptables` rules on Linux). These
206
+ > details should be considered implementation details. Let Docker manage your
207
+ > user-defined networks for you.
208
+
209
+ ## Connect a container to a user-defined bridge
210
+
211
+ When you create a new container, you can specify one or more `--network` flags.
212
+ This example connects an Nginx container to the `my-net` network. It also
213
+ publishes port 80 in the container to port 8080 on the Docker host, so external
214
+ clients can access that port. Any other container connected to the `my-net`
215
+ network has access to all ports on the `my-nginx` container, and vice versa.
216
+
217
+ ```console
218
+ $ docker create --name my-nginx \
219
+ --network my-net \
220
+ --publish 8080:80 \
221
+ nginx:latest
222
+ ```
223
+
224
+ To connect a **running** container to an existing user-defined bridge, use the
225
+ `docker network connect` command. The following command connects an already-running
226
+ `my-nginx` container to an already-existing `my-net` network:
227
+
228
+ ```console
229
+ $ docker network connect my-net my-nginx
230
+ ```
231
+
232
+ ## Disconnect a container from a user-defined bridge
233
+
234
+ To disconnect a running container from a user-defined bridge, use the
235
+ `docker network disconnect` command. The following command disconnects
236
+ the `my-nginx` container from the `my-net` network.
237
+
238
+ ```console
239
+ $ docker network disconnect my-net my-nginx
240
+ ```
241
+
242
+ ## Use IPv6 in a user-defined bridge network
243
+
244
+ When you create your network, you can specify the `--ipv6` flag to enable IPv6.
245
+
246
+ ```console
247
+ $ docker network create --ipv6 --subnet 2001:db8:1234::/64 my-net
248
+ ```
249
+
250
+ If you do not provide a `--subnet` option, a Unique Local Address (ULA) prefix
251
+ will be chosen automatically.
252
+
253
+ ## IPv6-only bridge networks
254
+
255
+ To skip IPv4 address configuration on the bridge and in its containers, create
256
+ the network with option `--ipv4=false`, and enable IPv6 using `--ipv6`.
257
+
258
+ ```console
259
+ $ docker network create --ipv6 --ipv4=false v6net
260
+ ```
261
+
262
+ IPv4 address configuration cannot be disabled in the default bridge network.
263
+
264
+ ## Use the default bridge network
265
+
266
+ The default `bridge` network is considered a legacy detail of Docker and is not
267
+ recommended for production use. Configuring it is a manual operation, and it has
268
+ [technical shortcomings](#differences-between-user-defined-bridges-and-the-default-bridge).
269
+
270
+ ### Connect a container to the default bridge network
271
+
272
+ If you do not specify a network using the `--network` flag, and you do specify a
273
+ network driver, your container is connected to the default `bridge` network by
274
+ default. Containers connected to the default `bridge` network can communicate,
275
+ but only by IP address, unless they're linked using the
276
+ [legacy `--link` flag](../links.md).
277
+
278
+ ### Configure the default bridge network
279
+
280
+ To configure the default `bridge` network, you specify options in `daemon.json`.
281
+ Here is an example `daemon.json` with several options specified. Only specify
282
+ the settings you need to customize.
283
+
284
+ ```json
285
+ {
286
+ "bip": "192.168.1.1/24",
287
+ "fixed-cidr": "192.168.1.0/25",
288
+ "mtu": 1500,
289
+ "default-gateway": "192.168.1.254",
290
+ "dns": ["10.20.1.2", "10.20.1.3"]
291
+ }
292
+ ```
293
+
294
+ In this example:
295
+
296
+ - The bridge's address is "192.168.1.1/24" (from `bip`).
297
+ - The bridge network's subnet is "192.168.1.0/24" (from `bip`).
298
+ - Container addresses will be allocated from "192.168.1.0/25" (from `fixed-cidr`).
299
+
300
+ ### Use IPv6 with the default bridge network
301
+
302
+ IPv6 can be enabled for the default bridge using the following options in
303
+ `daemon.json`, or their command line equivalents.
304
+
305
+ These three options only affect the default bridge, they are not used by
306
+ user-defined networks. The addresses in below are examples from the
307
+ IPv6 documentation range.
308
+
309
+ - Option `ipv6` is required.
310
+ - Option `bip6` is optional, it specifies the address of the default bridge, which
311
+ will be used as the default gateway by containers. It also specifies the subnet
312
+ for the bridge network.
313
+ - Option `fixed-cidr-v6` is optional, it specifies the address range Docker may
314
+ automatically allocate to containers.
315
+ - The prefix should normally be `/64` or shorter.
316
+ - For experimentation on a local network, it is better to use a Unique Local
317
+ Address (ULA) prefix (matching `fd00::/8`) than a Link Local prefix (matching
318
+ `fe80::/10`).
319
+ - Option `default-gateway-v6` is optional. If unspecified, the default is the first
320
+ address in the `fixed-cidr-v6` subnet.
321
+
322
+ ```json
323
+ {
324
+ "ipv6": true,
325
+ "bip6": "2001:db8::1111/64",
326
+ "fixed-cidr-v6": "2001:db8::/64",
327
+ "default-gateway-v6": "2001:db8:abcd::89"
328
+ }
329
+ ```
330
+
331
+ If no `bip6` is specified, `fixed-cidr-v6` defines the subnet for the bridge
332
+ network. If no `bip6` or `fixed-cidr-v6` is specified, a ULA prefix will be
333
+ chosen.
334
+
335
+ Restart Docker for changes to take effect.
336
+
337
+ ## Connection limit for bridge networks
338
+
339
+ Due to limitations set by the Linux kernel, bridge networks become unstable and
340
+ inter-container communications may break when 1000 containers or more connect
341
+ to a single network.
342
+
343
+ For more information about this limitation, see
344
+ [moby/moby#44973](https://github.com/moby/moby/issues/44973#issuecomment-1543747718).
345
+
346
+ ## Skip Bridge IP address configuration
347
+
348
+ The bridge is normally assigned the network's `--gateway` address, which is
349
+ used as the default route from the bridge network to other networks.
350
+
351
+ The `com.docker.network.bridge.inhibit_ipv4` option lets you create a network
352
+ without the IPv4 gateway address being assigned to the bridge. This is useful
353
+ if you want to configure the gateway IP address for the bridge manually. For
354
+ instance if you add a physical interface to your bridge, and need it to have
355
+ the gateway address.
356
+
357
+ With this configuration, north-south traffic (to and from the bridge network)
358
+ won't work unless you've manually configured the gateway address on the bridge,
359
+ or a device attached to it.
360
+
361
+ This option can only be used with user-defined bridge networks.
362
+
363
+ ## Usage examples
364
+
365
+ This section provides hands-on examples for working with bridge networks.
366
+
367
+ ### Use the default bridge network
368
+
369
+ This example shows how the default `bridge` network works. You start two
370
+ `alpine` containers on the default bridge and test how they communicate.
371
+
372
+ > [!NOTE]
373
+ > The default `bridge` network is not recommended for production. Use
374
+ > user-defined bridge networks instead.
375
+
376
+ 1. List current networks:
377
+
378
+ ```console
379
+ $ docker network ls
380
+
381
+ NETWORK ID NAME DRIVER SCOPE
382
+ 17e324f45964 bridge bridge local
383
+ 6ed54d316334 host host local
384
+ 7092879f2cc8 none null local
385
+ ```
386
+
387
+ The default `bridge` network is listed, along with `host` and `none`.
388
+
389
+ 2. Start two `alpine` containers running `ash`. The `-dit` flags mean detached,
390
+ interactive, and with a TTY. Since you haven't specified a `--network` flag,
391
+ the containers connect to the default `bridge` network.
392
+
393
+ ```console
394
+ $ docker run -dit --name alpine1 alpine ash
395
+ $ docker run -dit --name alpine2 alpine ash
396
+ ```
397
+
398
+ Verify both containers are running:
399
+
400
+ ```console
401
+ $ docker container ls
402
+
403
+ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
404
+ 602dbf1edc81 alpine "ash" 4 seconds ago Up 3 seconds alpine2
405
+ da33b7aa74b0 alpine "ash" 17 seconds ago Up 16 seconds alpine1
406
+ ```
407
+
408
+ 3. Inspect the `bridge` network to see connected containers:
409
+
410
+ ```console
411
+ $ docker network inspect bridge
412
+ ```
413
+
414
+ The output shows both containers connected, with their assigned IP addresses
415
+ (`172.17.0.2` for `alpine1` and `172.17.0.3` for `alpine2`).
416
+
417
+ 4. Connect to `alpine1`:
418
+
419
+ ```console
420
+ $ docker attach alpine1
421
+
422
+ / #
423
+ ```
424
+
425
+ Show the network interfaces for `alpine1` from within the container:
426
+
427
+ ```console
428
+ # ip addr show
429
+
430
+ 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
431
+ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
432
+ inet 127.0.0.1/8 scope host lo
433
+ valid_lft forever preferred_lft forever
434
+ inet6 ::1/128 scope host
435
+ valid_lft forever preferred_lft forever
436
+ 27: eth0@if28: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
437
+ link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
438
+ inet 172.17.0.2/16 scope global eth0
439
+ valid_lft forever preferred_lft forever
440
+ ```
441
+
442
+ In this example, the `eth0` interface has the IP address `172.17.0.2`.
443
+
444
+ 5. From within `alpine1`, verify you can connect to the internet:
445
+
446
+ ```console
447
+ # ping -c 2 google.com
448
+
449
+ PING google.com (172.217.3.174): 56 data bytes
450
+ 64 bytes from 172.217.3.174: seq=0 ttl=41 time=9.841 ms
451
+ 64 bytes from 172.217.3.174: seq=1 ttl=41 time=9.897 ms
452
+
453
+ --- google.com ping statistics ---
454
+ 2 packets transmitted, 2 packets received, 0% packet loss
455
+ round-trip min/avg/max = 9.841/9.869/9.897 ms
456
+ ```
457
+
458
+ 6. Ping the second container by its IP address:
459
+
460
+ ```console
461
+ # ping -c 2 172.17.0.3
462
+
463
+ PING 172.17.0.3 (172.17.0.3): 56 data bytes
464
+ 64 bytes from 172.17.0.3: seq=0 ttl=64 time=0.086 ms
465
+ 64 bytes from 172.17.0.3: seq=1 ttl=64 time=0.094 ms
466
+
467
+ --- 172.17.0.3 ping statistics ---
468
+ 2 packets transmitted, 2 packets received, 0% packet loss
469
+ round-trip min/avg/max = 0.086/0.090/0.094 ms
470
+ ```
471
+
472
+ This succeeds. Now try pinging by container name:
473
+
474
+ ```console
475
+ # ping -c 2 alpine2
476
+
477
+ ping: bad address 'alpine2'
478
+ ```
479
+
480
+ On the default bridge network, containers can't resolve each other by name.
481
+
482
+ 7. Detach from `alpine1` without stopping it using `CTRL+p CTRL+q`.
483
+
484
+ 8. Clean up: stop the containers and remove them.
485
+
486
+ ```console
487
+ $ docker container stop alpine1 alpine2
488
+ $ docker container rm alpine1 alpine2
489
+ ```
490
+
491
+ Stopped containers lose their IP addresses.
492
+
493
+ ### Use user-defined bridge networks
494
+
495
+ This example shows how user-defined bridge networks provide better isolation
496
+ and automatic DNS resolution between containers.
497
+
498
+ 1. Create the `alpine-net` network:
499
+
500
+ ```console
501
+ $ docker network create --driver bridge alpine-net
502
+ ```
503
+
504
+ 2. List Docker's networks:
505
+
506
+ ```console
507
+ $ docker network ls
508
+
509
+ NETWORK ID NAME DRIVER SCOPE
510
+ e9261a8c9a19 alpine-net bridge local
511
+ 17e324f45964 bridge bridge local
512
+ 6ed54d316334 host host local
513
+ 7092879f2cc8 none null local
514
+ ```
515
+
516
+ Inspect the `alpine-net` network:
517
+
518
+ ```console
519
+ $ docker network inspect alpine-net
520
+ ```
521
+
522
+ This shows the network's gateway (for example, `172.18.0.1`) and that no
523
+ containers are connected yet.
524
+
525
+ 3. Create four containers. Three connect to `alpine-net`, and one connects to
526
+ the default `bridge`. Then connect one container to both networks:
527
+
528
+ ```console
529
+ $ docker run -dit --name alpine1 --network alpine-net alpine ash
530
+ $ docker run -dit --name alpine2 --network alpine-net alpine ash
531
+ $ docker run -dit --name alpine3 alpine ash
532
+ $ docker run -dit --name alpine4 --network alpine-net alpine ash
533
+ $ docker network connect bridge alpine4
534
+ ```
535
+
536
+ Verify all containers are running:
537
+
538
+ ```console
539
+ $ docker container ls
540
+
541
+ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
542
+ 156849ccd902 alpine "ash" 41 seconds ago Up 41 seconds alpine4
543
+ fa1340b8d83e alpine "ash" 51 seconds ago Up 51 seconds alpine3
544
+ a535d969081e alpine "ash" About a minute ago Up About a minute alpine2
545
+ 0a02c449a6e9 alpine "ash" About a minute ago Up About a minute alpine1
546
+ ```
547
+
548
+ 4. Inspect both networks again to see which containers are connected:
549
+
550
+ ```console
551
+ $ docker network inspect bridge
552
+ ```
553
+
554
+ Containers `alpine3` and `alpine4` are connected to the `bridge` network.
555
+
556
+ ```console
557
+ $ docker network inspect alpine-net
558
+ ```
559
+
560
+ Containers `alpine1`, `alpine2`, and `alpine4` are connected to
561
+ `alpine-net`.
562
+
563
+ 5. On user-defined networks, containers can resolve each other by name. Connect
564
+ to `alpine1` and test:
565
+
566
+ > [!NOTE]
567
+ > Automatic service discovery only resolves custom container names, not
568
+ > default automatically generated names.
569
+
570
+ ```console
571
+ $ docker container attach alpine1
572
+
573
+ # ping -c 2 alpine2
574
+
575
+ PING alpine2 (172.18.0.3): 56 data bytes
576
+ 64 bytes from 172.18.0.3: seq=0 ttl=64 time=0.085 ms
577
+ 64 bytes from 172.18.0.3: seq=1 ttl=64 time=0.090 ms
578
+
579
+ --- alpine2 ping statistics ---
580
+ 2 packets transmitted, 2 packets received, 0% packet loss
581
+ round-trip min/avg/max = 0.085/0.087/0.090 ms
582
+
583
+ # ping -c 2 alpine4
584
+
585
+ PING alpine4 (172.18.0.4): 56 data bytes
586
+ 64 bytes from 172.18.0.4: seq=0 ttl=64 time=0.076 ms
587
+ 64 bytes from 172.18.0.4: seq=1 ttl=64 time=0.091 ms
588
+
589
+ --- alpine4 ping statistics ---
590
+ 2 packets transmitted, 2 packets received, 0% packet loss
591
+ round-trip min/avg/max = 0.076/0.083/0.091 ms
592
+ ```
593
+
594
+ 6. From `alpine1`, you can't connect to `alpine3` because it's on a different
595
+ network:
596
+
597
+ ```console
598
+ # ping -c 2 alpine3
599
+
600
+ ping: bad address 'alpine3'
601
+ ```
602
+
603
+ You also can't connect by IP address. If `alpine3`'s IP is `172.17.0.2`:
604
+
605
+ ```console
606
+ # ping -c 2 172.17.0.2
607
+
608
+ PING 172.17.0.2 (172.17.0.2): 56 data bytes
609
+
610
+ --- 172.17.0.2 ping statistics ---
611
+ 2 packets transmitted, 0 packets received, 100% packet loss
612
+ ```
613
+
614
+ Detach from `alpine1` using `CTRL+p CTRL+q`.
615
+
616
+ 7. Since `alpine4` is connected to both networks, it can reach all containers.
617
+ However, you need to use `alpine3`'s IP address:
618
+
619
+ ```console
620
+ $ docker container attach alpine4
621
+
622
+ # ping -c 2 alpine1
623
+
624
+ PING alpine1 (172.18.0.2): 56 data bytes
625
+ 64 bytes from 172.18.0.2: seq=0 ttl=64 time=0.074 ms
626
+ 64 bytes from 172.18.0.2: seq=1 ttl=64 time=0.082 ms
627
+
628
+ --- alpine1 ping statistics ---
629
+ 2 packets transmitted, 2 packets received, 0% packet loss
630
+ round-trip min/avg/max = 0.074/0.078/0.082 ms
631
+
632
+ # ping -c 2 alpine2
633
+
634
+ PING alpine2 (172.18.0.3): 56 data bytes
635
+ 64 bytes from 172.18.0.3: seq=0 ttl=64 time=0.075 ms
636
+ 64 bytes from 172.18.0.3: seq=1 ttl=64 time=0.080 ms
637
+
638
+ --- alpine2 ping statistics ---
639
+ 2 packets transmitted, 2 packets received, 0% packet loss
640
+ round-trip min/avg/max = 0.075/0.077/0.080 ms
641
+
642
+ # ping -c 2 alpine3
643
+ ping: bad address 'alpine3'
644
+
645
+ # ping -c 2 172.17.0.2
646
+
647
+ PING 172.17.0.2 (172.17.0.2): 56 data bytes
648
+ 64 bytes from 172.17.0.2: seq=0 ttl=64 time=0.089 ms
649
+ 64 bytes from 172.17.0.2: seq=1 ttl=64 time=0.075 ms
650
+
651
+ --- 172.17.0.2 ping statistics ---
652
+ 2 packets transmitted, 2 packets received, 0% packet loss
653
+ round-trip min/avg/max = 0.075/0.082/0.089 ms
654
+ ```
655
+
656
+ 8. Verify all containers can connect to the internet:
657
+
658
+ ```console
659
+ # ping -c 2 google.com
660
+
661
+ PING google.com (172.217.3.174): 56 data bytes
662
+ 64 bytes from 172.217.3.174: seq=0 ttl=41 time=9.778 ms
663
+ 64 bytes from 172.217.3.174: seq=1 ttl=41 time=9.634 ms
664
+
665
+ --- google.com ping statistics ---
666
+ 2 packets transmitted, 2 packets received, 0% packet loss
667
+ round-trip min/avg/max = 9.634/9.706/9.778 ms
668
+ ```
669
+
670
+ Detach with `CTRL+p CTRL+q` and repeat for `alpine3` and `alpine1` if
671
+ desired.
672
+
673
+ 9. Clean up:
674
+
675
+ ```console
676
+ $ docker container stop alpine1 alpine2 alpine3 alpine4
677
+ $ docker container rm alpine1 alpine2 alpine3 alpine4
678
+ $ docker network rm alpine-net
679
+ ```
680
+
681
+ ## Next steps
682
+
683
+ - Learn about [networking from the container's point of view](../_index.md)
684
+ - Learn about [overlay networks](./overlay.md)
685
+ - Learn about [Macvlan networks](./macvlan.md)
686
+ ```
20260907-002107-computing-math-7483af/environment/public_data/input/tutorial_text_windows.csv ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ window_id,start_word,end_word,text,contains_code_term,matched_required_terms
2
+ 1,0,40,"# Source 1: bridge.md - URL: https://raw.githubusercontent.com/docker/docs/main/content/manuals/engine/network/drivers/bridge.md - SHA256: f5d1811100422cd6108a833b6485b7745ce7939b51f5826099242dde00b2f3b5 - Bytes: 27467 ```markdown --- title: Bridge network driver description: All about using user-defined bridge networks and the default bridge keywords: network, bridge, user-defined, standalone aliases: - /config/containers/bridges/ - /engine/userguide/networking/default_network/build-bridges/",true,Docker|container|network
3
+ 2,20,60,"All about using user-defined bridge networks and the default bridge keywords: network, bridge, user-defined, standalone aliases: - /config/containers/bridges/ - /engine/userguide/networking/default_network/build-bridges/ - /engine/userguide/networking/default_network/custom-docker0/ - /engine/userguide/networking/work-with-networks/ - /network/bridge/ - /network/drivers/bridge/ - /engine/network/tutorials/standalone/ --- A Docker bridge network has an IPv4 subnet and,",true,Docker|container|network
4
+ 3,40,80,"- /engine/userguide/networking/default_network/custom-docker0/ - /engine/userguide/networking/work-with-networks/ - /network/bridge/ - /network/drivers/bridge/ - /engine/network/tutorials/standalone/ --- A Docker bridge network has an IPv4 subnet and, optionally, an IPv6 subnet. Each container connected to the bridge network has a network interface with addresses in the network's",true,Docker|container|network
5
+ 4,60,100,"optionally, an IPv6 subnet. Each container connected to the bridge network has a network interface with addresses in the network's subnets. By default, it: - Allows unrestricted network access to containers in the network from the host, and from other",false,container|network
6
+ 5,80,120,"subnets. By default, it: - Allows unrestricted network access to containers in the network from the host, and from other containers connected to the same bridge network. - Blocks access from containers in other networks and from outside the Docker",true,Docker|container|network
7
+ 6,100,140,containers connected to the same bridge network. - Blocks access from containers in other networks and from outside the Docker host. - Uses masquerading to give containers external network access. Devices on the host's external networks only see the IP,true,Docker|container|network
8
+ 7,120,160,"host. - Uses masquerading to give containers external network access. Devices on the host's external networks only see the IP address of the Docker host. - Supports port publishing, where network traffic is forwarded between container ports and ports on",true,Docker|container|network
9
+ 8,140,180,"address of the Docker host. - Supports port publishing, where network traffic is forwarded between container ports and ports on host IP addresses. The published ports can be accessed from outside the Docker host, on its IP addresses. In terms",true,Docker|container|network
10
+ 9,160,200,"host IP addresses. The published ports can be accessed from outside the Docker host, on its IP addresses. In terms of Docker, a bridge network uses a software bridge which lets containers connected to the same bridge network communicate, while",true,Docker|container|network
11
+ 10,180,220,"of Docker, a bridge network uses a software bridge which lets containers connected to the same bridge network communicate, while providing isolation from containers that aren't connected to that bridge network. By default, the Docker bridge driver automatically installs rules",true,Docker|container|network
12
+ 11,200,240,"providing isolation from containers that aren't connected to that bridge network. By default, the Docker bridge driver automatically installs rules in the host machine so that containers connected to different bridge networks can only communicate with each other using published",true,Docker|container|network
13
+ 12,220,260,in the host machine so that containers connected to different bridge networks can only communicate with each other using published ports. Bridge networks apply to containers running on the same Docker daemon host. For communication among containers running on different,true,Docker|container|network
14
+ 13,240,280,"ports. Bridge networks apply to containers running on the same Docker daemon host. For communication among containers running on different Docker daemon hosts, you can either manage routing at the OS level, or you can use an [overlay network](overlay.md). When",true,Docker|container|network
15
+ 14,260,300,"Docker daemon hosts, you can either manage routing at the OS level, or you can use an [overlay network](overlay.md). When you start Docker, a [default bridge network](#use-the-default-bridge-network) (also called `bridge`) is created automatically, and newly-started containers connect to it unless",true,Docker|container|network
16
+ 15,280,320,"you start Docker, a [default bridge network](#use-the-default-bridge-network) (also called `bridge`) is created automatically, and newly-started containers connect to it unless otherwise specified. You can also create user-defined custom bridge networks. **User-defined bridge networks are superior to the default `bridge` network.**",true,Docker|container|network
17
+ 16,300,340,otherwise specified. You can also create user-defined custom bridge networks. **User-defined bridge networks are superior to the default `bridge` network.** ## Differences between user-defined bridges and the default bridge - **User-defined bridges provide automatic DNS resolution between containers**. Containers on,false,container|network
18
+ 17,320,360,"## Differences between user-defined bridges and the default bridge - **User-defined bridges provide automatic DNS resolution between containers**. Containers on the default bridge network can only access each other by IP addresses, unless you use the [`--link` option](../links.md), which is",false,container|network
19
+ 18,340,380,"the default bridge network can only access each other by IP addresses, unless you use the [`--link` option](../links.md), which is considered legacy. On a user-defined bridge network, containers can resolve each other by name or alias. Imagine an application with",false,container|network
20
+ 19,360,400,"considered legacy. On a user-defined bridge network, containers can resolve each other by name or alias. Imagine an application with a web front-end and a database back-end. If you call your containers `web` and `db`, the web container can connect",false,container|network
21
+ 20,380,420,"a web front-end and a database back-end. If you call your containers `web` and `db`, the web container can connect to the db container at `db`, no matter which Docker host the application stack is running on. If you run",true,Docker|container
22
+ 21,400,440,"to the db container at `db`, no matter which Docker host the application stack is running on. If you run the same application stack on the default bridge network, you need to manually create links between the containers (using the",true,Docker|container|network
23
+ 22,420,460,"the same application stack on the default bridge network, you need to manually create links between the containers (using the legacy `--link` flag). These links need to be created in both directions, so you can see this gets complex with",false,container|network
24
+ 23,440,480,"legacy `--link` flag). These links need to be created in both directions, so you can see this gets complex with more than two containers which need to communicate. Alternatively, you can manipulate the `/etc/hosts` files within the containers, but this",false,container
25
+ 24,460,500,"more than two containers which need to communicate. Alternatively, you can manipulate the `/etc/hosts` files within the containers, but this creates problems that are difficult to debug. - **User-defined bridges provide better isolation**. All containers without a `--network` specified, are",false,container|network
26
+ 25,480,520,"creates problems that are difficult to debug. - **User-defined bridges provide better isolation**. All containers without a `--network` specified, are attached to the default bridge network. This can be a risk, as unrelated stacks/services/containers are then able to communicate. Using",false,container|network
27
+ 26,500,540,"attached to the default bridge network. This can be a risk, as unrelated stacks/services/containers are then able to communicate. Using a user-defined network provides a scoped network in which only containers attached to that network are able to communicate. -",false,container|network
28
+ 27,520,560,"a user-defined network provides a scoped network in which only containers attached to that network are able to communicate. - **Containers can be attached and detached from user-defined networks on the fly**. During a container's lifetime, you can connect or",false,container|network
29
+ 28,540,580,"**Containers can be attached and detached from user-defined networks on the fly**. During a container's lifetime, you can connect or disconnect it from user-defined networks on the fly. To remove a container from the default bridge network, you need to",false,container|network
30
+ 29,560,600,"disconnect it from user-defined networks on the fly. To remove a container from the default bridge network, you need to stop the container and recreate it with different network options. - **Each user-defined network creates a configurable bridge**. If your",false,container|network
31
+ 30,580,620,"stop the container and recreate it with different network options. - **Each user-defined network creates a configurable bridge**. If your containers use the default bridge network, you can configure it, but all the containers use the same settings, such as",false,container|network
32
+ 31,600,640,"containers use the default bridge network, you can configure it, but all the containers use the same settings, such as MTU and `iptables` rules. In addition, configuring the default bridge network happens outside of Docker itself, and requires a restart",true,Docker|container|network
33
+ 32,620,660,"MTU and `iptables` rules. In addition, configuring the default bridge network happens outside of Docker itself, and requires a restart of Docker. User-defined bridge networks are created and configured using `docker network create`. If different groups of applications have different",true,Docker|network
34
+ 33,640,680,"of Docker. User-defined bridge networks are created and configured using `docker network create`. If different groups of applications have different network requirements, you can configure each user-defined bridge separately, as you create it. - **Linked containers on the default bridge",true,Docker|container|network
35
+ 34,660,700,"network requirements, you can configure each user-defined bridge separately, as you create it. - **Linked containers on the default bridge network share environment variables**. Originally, the only way to share environment variables between two containers was to link them using",false,container|network
36
+ 35,680,720,"network share environment variables**. Originally, the only way to share environment variables between two containers was to link them using the [`--link` flag](../links.md). This type of variable sharing isn't possible with user-defined networks. However, there are superior ways to share",false,container|network
37
+ 36,700,740,"the [`--link` flag](../links.md). This type of variable sharing isn't possible with user-defined networks. However, there are superior ways to share environment variables. A few ideas: - Multiple containers can mount a file or directory containing the shared information, using a",false,container|network
38
+ 37,720,760,"environment variables. A few ideas: - Multiple containers can mount a file or directory containing the shared information, using a Docker volume. - Multiple containers can be started together using `docker-compose` and the compose file can define the shared variables.",true,Docker|container
39
+ 38,740,780,"Docker volume. - Multiple containers can be started together using `docker-compose` and the compose file can define the shared variables. - You can use swarm services instead of standalone containers, and take advantage of shared [secrets](/manuals/engine/swarm/secrets.md) and [configs](/manuals/engine/swarm/configs.md). Containers connected",true,Docker|container
40
+ 39,760,800,"- You can use swarm services instead of standalone containers, and take advantage of shared [secrets](/manuals/engine/swarm/secrets.md) and [configs](/manuals/engine/swarm/configs.md). Containers connected to the same user-defined bridge network effectively expose all ports to each other. For a port to be accessible to",false,container|network
41
+ 40,780,820,"to the same user-defined bridge network effectively expose all ports to each other. For a port to be accessible to containers or non-Docker hosts on different networks, that port must be _published_ using the `-p` or `--publish` flag. ## Options",true,Docker|container|network
42
+ 41,800,840,"containers or non-Docker hosts on different networks, that port must be _published_ using the `-p` or `--publish` flag. ## Options The following table describes the driver-specific options that you can pass to `--opt` when creating a custom network using the",true,Docker|container|network
43
+ 42,820,860,The following table describes the driver-specific options that you can pass to `--opt` when creating a custom network using the `bridge` driver. | Option | Default | Description | | ----------------------------------------------------------------------------------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------- | | `com.docker.network.bridge.name` | |,true,Docker|network
44
+ 43,840,880,`bridge` driver. | Option | Default | Description | | ----------------------------------------------------------------------------------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------- | | `com.docker.network.bridge.name` | | Interface name to use when creating the Linux bridge. | | `com.docker.network.bridge.enable_ip_masquerade` | `true` | Enable IP masquerading. | |,true,Docker|network
45
+ 44,860,900,Interface name to use when creating the Linux bridge. | | `com.docker.network.bridge.enable_ip_masquerade` | `true` | Enable IP masquerading. | | `com.docker.network.host_ipv4` `com.docker.network.host_ipv6` | | Address to use for source NAT. See [Port publishing](../port-publishing.md#masquerade-or-snat-for-outgoing-packets). | | `com.docker.network.bridge.gateway_mode_ipv4` `com.docker.network.bridge.gateway_mode_ipv6` | `nat` |,true,Docker|network
46
+ 45,880,920,`com.docker.network.host_ipv4` `com.docker.network.host_ipv6` | | Address to use for source NAT. See [Port publishing](../port-publishing.md#masquerade-or-snat-for-outgoing-packets). | | `com.docker.network.bridge.gateway_mode_ipv4` `com.docker.network.bridge.gateway_mode_ipv6` | `nat` | Control external connectivity. See [Port publishing](../port-publishing.md#gateway-modes). | | `com.docker.network.bridge.enable_icc` | `true` | Enable or Disable inter-container connectivity. | | `com.docker.network.bridge.host_binding_ipv4`,true,Docker|container|network
47
+ 46,900,940,Control external connectivity. See [Port publishing](../port-publishing.md#gateway-modes). | | `com.docker.network.bridge.enable_icc` | `true` | Enable or Disable inter-container connectivity. | | `com.docker.network.bridge.host_binding_ipv4` | all IPv4 and IPv6 addresses | Default IP when binding container ports. | | `com.docker.network.driver.mtu` | `0` (no limit),true,Docker|container|network
48
+ 47,920,960,| all IPv4 and IPv6 addresses | Default IP when binding container ports. | | `com.docker.network.driver.mtu` | `0` (no limit) | Set the containers network Maximum Transmission Unit (MTU). | | `com.docker.network.container_iface_prefix` | `eth` | Set a custom prefix for,true,Docker|container|network
49
+ 48,940,980,| Set the containers network Maximum Transmission Unit (MTU). | | `com.docker.network.container_iface_prefix` | `eth` | Set a custom prefix for container interfaces. | | `com.docker.network.bridge.inhibit_ipv4` | `false` | Prevent Docker from [assigning an IP address](#skip-bridge-ip-address-configuration) to the bridge. | Some,true,Docker|container|network
50
+ 49,960,1000,"container interfaces. | | `com.docker.network.bridge.inhibit_ipv4` | `false` | Prevent Docker from [assigning an IP address](#skip-bridge-ip-address-configuration) to the bridge. | Some of these options are also available as flags to the `dockerd` CLI, and you can use them to configure the",true,Docker|container|network
51
+ 50,980,1020,"of these options are also available as flags to the `dockerd` CLI, and you can use them to configure the default `docker0` bridge when starting the Docker daemon. The following table shows which options have equivalent flags in the `dockerd`",true,Docker
52
+ 51,1000,1040,default `docker0` bridge when starting the Docker daemon. The following table shows which options have equivalent flags in the `dockerd` CLI. | Option | Flag | | ------------------------------------------------ | ----------- | | `com.docker.network.bridge.name` | - | | `com.docker.network.bridge.enable_ip_masquerade` | `--ip-masq`,true,Docker|network
53
+ 52,1020,1060,CLI. | Option | Flag | | ------------------------------------------------ | ----------- | | `com.docker.network.bridge.name` | - | | `com.docker.network.bridge.enable_ip_masquerade` | `--ip-masq` | | `com.docker.network.bridge.enable_icc` | `--icc` | | `com.docker.network.bridge.host_binding_ipv4` | `--ip` | | `com.docker.network.driver.mtu` | `--mtu` | | `com.docker.network.container_iface_prefix` | -,true,Docker|container|network
54
+ 53,1040,1080,"| | `com.docker.network.bridge.enable_icc` | `--icc` | | `com.docker.network.bridge.host_binding_ipv4` | `--ip` | | `com.docker.network.driver.mtu` | `--mtu` | | `com.docker.network.container_iface_prefix` | - | The Docker daemon supports a `--bridge` flag, which you can use to define your own `docker0` bridge. Use this",true,Docker|container|network
55
+ 54,1060,1100,"| The Docker daemon supports a `--bridge` flag, which you can use to define your own `docker0` bridge. Use this option if you want to run multiple daemon instances on the same host. For details, see [Run multiple daemons](/reference/cli/dockerd.md#run-multiple-daemons). ###",true,Docker
56
+ 55,1080,1120,"option if you want to run multiple daemon instances on the same host. For details, see [Run multiple daemons](/reference/cli/dockerd.md#run-multiple-daemons). ### Default host binding address When no host address is given in port publishing options like `-p 80` or `-p 8080:80`,",true,Docker
57
+ 56,1100,1140,"Default host binding address When no host address is given in port publishing options like `-p 80` or `-p 8080:80`, the default is to make the container's port 80 available on all host addresses, IPv4 and IPv6. The bridge network",false,container|network
58
+ 57,1120,1160,"the default is to make the container's port 80 available on all host addresses, IPv4 and IPv6. The bridge network driver option `com.docker.network.bridge.host_binding_ipv4` can be used to modify the default address for published ports. Despite the option's name, it is",true,Docker|container|network
59
+ 58,1140,1180,"driver option `com.docker.network.bridge.host_binding_ipv4` can be used to modify the default address for published ports. Despite the option's name, it is possible to specify an IPv6 address. When the default binding address is an address assigned to a specific interface, the",true,Docker|network
60
+ 59,1160,1200,"possible to specify an IPv6 address. When the default binding address is an address assigned to a specific interface, the container's port will only be accessible via that address. Setting the default binding address to `::` means published ports will",false,container
61
+ 60,1180,1220,"container's port will only be accessible via that address. Setting the default binding address to `::` means published ports will only be available on the host's IPv6 addresses. However, setting it to `0.0.0.0` means it will be available on the",false,container
62
+ 61,1200,1240,"only be available on the host's IPv6 addresses. However, setting it to `0.0.0.0` means it will be available on the host's IPv4 and IPv6 addresses. To restrict a published port to IPv4 only, the address must be included in the",false,
63
+ 62,1220,1260,"host's IPv4 and IPv6 addresses. To restrict a published port to IPv4 only, the address must be included in the container's publishing options. For example, `-p 0.0.0.0:8080:80`. ## Manage a user-defined bridge Use the `docker network create` command to create",true,Docker|container|network
64
+ 63,1240,1280,"container's publishing options. For example, `-p 0.0.0.0:8080:80`. ## Manage a user-defined bridge Use the `docker network create` command to create a user-defined bridge network. ```console $ docker network create my-net ``` You can specify the subnet, the IP address range,",true,Docker|container|network
65
+ 64,1260,1300,"a user-defined bridge network. ```console $ docker network create my-net ``` You can specify the subnet, the IP address range, the gateway, and other options. See the [docker network create](/reference/cli/docker/network/create/#specify-advanced-options) reference or the output of `docker network create --help` for",true,Docker|network
66
+ 65,1280,1320,"the gateway, and other options. See the [docker network create](/reference/cli/docker/network/create/#specify-advanced-options) reference or the output of `docker network create --help` for details. Use the `docker network rm` command to remove a user-defined bridge network. If containers are currently connected to the",true,Docker|container|network
67
+ 66,1300,1340,"details. Use the `docker network rm` command to remove a user-defined bridge network. If containers are currently connected to the network, [disconnect them](#disconnect-a-container-from-a-user-defined-bridge) first. ```console $ docker network rm my-net ``` > **What's really happening?** > > When you create",true,Docker|container|network
68
+ 67,1320,1360,"network, [disconnect them](#disconnect-a-container-from-a-user-defined-bridge) first. ```console $ docker network rm my-net ``` > **What's really happening?** > > When you create or remove a user-defined bridge or connect or disconnect a > container from a user-defined bridge, Docker uses tools specific",true,Docker|container|network
69
+ 68,1340,1380,"or remove a user-defined bridge or connect or disconnect a > container from a user-defined bridge, Docker uses tools specific to the > operating system to manage the underlying network infrastructure (such as adding > or removing bridge devices or",true,Docker|container|network
70
+ 69,1360,1400,to the > operating system to manage the underlying network infrastructure (such as adding > or removing bridge devices or configuring `iptables` rules on Linux). These > details should be considered implementation details. Let Docker manage your > user-defined networks,true,Docker|network
71
+ 70,1380,1420,"configuring `iptables` rules on Linux). These > details should be considered implementation details. Let Docker manage your > user-defined networks for you. ## Connect a container to a user-defined bridge When you create a new container, you can specify one",true,Docker|container|network
72
+ 71,1400,1440,"for you. ## Connect a container to a user-defined bridge When you create a new container, you can specify one or more `--network` flags. This example connects an Nginx container to the `my-net` network. It also publishes port 80 in",false,container|network
73
+ 72,1420,1460,"or more `--network` flags. This example connects an Nginx container to the `my-net` network. It also publishes port 80 in the container to port 8080 on the Docker host, so external clients can access that port. Any other container connected",true,Docker|container|network
74
+ 73,1440,1480,"the container to port 8080 on the Docker host, so external clients can access that port. Any other container connected to the `my-net` network has access to all ports on the `my-nginx` container, and vice versa. ```console $ docker create",true,Docker|container|network
75
+ 74,1460,1500,"to the `my-net` network has access to all ports on the `my-nginx` container, and vice versa. ```console $ docker create --name my-nginx \ --network my-net \ --publish 8080:80 \ nginx:latest ``` To connect a **running** container to an existing user-defined",true,Docker|container|network
76
+ 75,1480,1520,"--name my-nginx \ --network my-net \ --publish 8080:80 \ nginx:latest ``` To connect a **running** container to an existing user-defined bridge, use the `docker network connect` command. The following command connects an already-running `my-nginx` container to an already-existing `my-net` network:",true,Docker|container|network
77
+ 76,1500,1540,"bridge, use the `docker network connect` command. The following command connects an already-running `my-nginx` container to an already-existing `my-net` network: ```console $ docker network connect my-net my-nginx ``` ## Disconnect a container from a user-defined bridge To disconnect a running",true,Docker|container|network
78
+ 77,1520,1560,"```console $ docker network connect my-net my-nginx ``` ## Disconnect a container from a user-defined bridge To disconnect a running container from a user-defined bridge, use the `docker network disconnect` command. The following command disconnects the `my-nginx` container from the",true,Docker|container|network
79
+ 78,1540,1580,"container from a user-defined bridge, use the `docker network disconnect` command. The following command disconnects the `my-nginx` container from the `my-net` network. ```console $ docker network disconnect my-net my-nginx ``` ## Use IPv6 in a user-defined bridge network When you",true,Docker|container|network
80
+ 79,1560,1600,"`my-net` network. ```console $ docker network disconnect my-net my-nginx ``` ## Use IPv6 in a user-defined bridge network When you create your network, you can specify the `--ipv6` flag to enable IPv6. ```console $ docker network create --ipv6 --subnet 2001:db8:1234::/64",true,Docker|network
81
+ 80,1580,1620,"create your network, you can specify the `--ipv6` flag to enable IPv6. ```console $ docker network create --ipv6 --subnet 2001:db8:1234::/64 my-net ``` If you do not provide a `--subnet` option, a Unique Local Address (ULA) prefix will be chosen automatically.",true,Docker|network
82
+ 81,1600,1640,"my-net ``` If you do not provide a `--subnet` option, a Unique Local Address (ULA) prefix will be chosen automatically. ## IPv6-only bridge networks To skip IPv4 address configuration on the bridge and in its containers, create the network with",false,container|network
83
+ 82,1620,1660,"## IPv6-only bridge networks To skip IPv4 address configuration on the bridge and in its containers, create the network with option `--ipv4=false`, and enable IPv6 using `--ipv6`. ```console $ docker network create --ipv6 --ipv4=false v6net ``` IPv4 address configuration cannot",true,Docker|container|network
84
+ 83,1640,1680,"option `--ipv4=false`, and enable IPv6 using `--ipv6`. ```console $ docker network create --ipv6 --ipv4=false v6net ``` IPv4 address configuration cannot be disabled in the default bridge network. ## Use the default bridge network The default `bridge` network is considered a",true,Docker|network
85
+ 84,1660,1700,"be disabled in the default bridge network. ## Use the default bridge network The default `bridge` network is considered a legacy detail of Docker and is not recommended for production use. Configuring it is a manual operation, and it has",true,Docker|network
86
+ 85,1680,1720,"legacy detail of Docker and is not recommended for production use. Configuring it is a manual operation, and it has [technical shortcomings](#differences-between-user-defined-bridges-and-the-default-bridge). ### Connect a container to the default bridge network If you do not specify a network using the",true,Docker|container|network
87
+ 86,1700,1740,"[technical shortcomings](#differences-between-user-defined-bridges-and-the-default-bridge). ### Connect a container to the default bridge network If you do not specify a network using the `--network` flag, and you do specify a network driver, your container is connected to the default `bridge` network by default.",false,container|network
88
+ 87,1720,1760,"`--network` flag, and you do specify a network driver, your container is connected to the default `bridge` network by default. Containers connected to the default `bridge` network can communicate, but only by IP address, unless they're linked using the [legacy",false,container|network
89
+ 88,1740,1780,"Containers connected to the default `bridge` network can communicate, but only by IP address, unless they're linked using the [legacy `--link` flag](../links.md). ### Configure the default bridge network To configure the default `bridge` network, you specify options in `daemon.json`. Here",false,container|network
90
+ 89,1760,1800,"`--link` flag](../links.md). ### Configure the default bridge network To configure the default `bridge` network, you specify options in `daemon.json`. Here is an example `daemon.json` with several options specified. Only specify the settings you need to customize. ```json { ""bip"": ""192.168.1.1/24"",",false,network
91
+ 90,1780,1820,"is an example `daemon.json` with several options specified. Only specify the settings you need to customize. ```json { ""bip"": ""192.168.1.1/24"", ""fixed-cidr"": ""192.168.1.0/25"", ""mtu"": 1500, ""default-gateway"": ""192.168.1.254"", ""dns"": [""10.20.1.2"", ""10.20.1.3""] } ``` In this example: - The bridge's address is ""192.168.1.1/24""",false,
92
+ 91,1800,1840,"""fixed-cidr"": ""192.168.1.0/25"", ""mtu"": 1500, ""default-gateway"": ""192.168.1.254"", ""dns"": [""10.20.1.2"", ""10.20.1.3""] } ``` In this example: - The bridge's address is ""192.168.1.1/24"" (from `bip`). - The bridge network's subnet is ""192.168.1.0/24"" (from `bip`). - Container addresses will be allocated from ""192.168.1.0/25"" (from",false,container|network
93
+ 92,1820,1860,"(from `bip`). - The bridge network's subnet is ""192.168.1.0/24"" (from `bip`). - Container addresses will be allocated from ""192.168.1.0/25"" (from `fixed-cidr`). ### Use IPv6 with the default bridge network IPv6 can be enabled for the default bridge using the following",false,container|network
94
+ 93,1840,1880,"`fixed-cidr`). ### Use IPv6 with the default bridge network IPv6 can be enabled for the default bridge using the following options in `daemon.json`, or their command line equivalents. These three options only affect the default bridge, they are not used",false,network
95
+ 94,1860,1900,"options in `daemon.json`, or their command line equivalents. These three options only affect the default bridge, they are not used by user-defined networks. The addresses in below are examples from the IPv6 documentation range. - Option `ipv6` is required. -",false,network
96
+ 95,1880,1920,"by user-defined networks. The addresses in below are examples from the IPv6 documentation range. - Option `ipv6` is required. - Option `bip6` is optional, it specifies the address of the default bridge, which will be used as the default gateway",false,network
97
+ 96,1900,1940,"Option `bip6` is optional, it specifies the address of the default bridge, which will be used as the default gateway by containers. It also specifies the subnet for the bridge network. - Option `fixed-cidr-v6` is optional, it specifies the address",false,container|network
98
+ 97,1920,1960,"by containers. It also specifies the subnet for the bridge network. - Option `fixed-cidr-v6` is optional, it specifies the address range Docker may automatically allocate to containers. - The prefix should normally be `/64` or shorter. - For experimentation on",true,Docker|container|network
99
+ 98,1940,1980,"range Docker may automatically allocate to containers. - The prefix should normally be `/64` or shorter. - For experimentation on a local network, it is better to use a Unique Local Address (ULA) prefix (matching `fd00::/8`) than a Link Local",true,Docker|container|network
100
+ 99,1960,2000,"a local network, it is better to use a Unique Local Address (ULA) prefix (matching `fd00::/8`) than a Link Local prefix (matching `fe80::/10`). - Option `default-gateway-v6` is optional. If unspecified, the default is the first address in the `fixed-cidr-v6` subnet.",false,network
101
+ 100,1980,2020,"prefix (matching `fe80::/10`). - Option `default-gateway-v6` is optional. If unspecified, the default is the first address in the `fixed-cidr-v6` subnet. ```json { ""ipv6"": true, ""bip6"": ""2001:db8::1111/64"", ""fixed-cidr-v6"": ""2001:db8::/64"", ""default-gateway-v6"": ""2001:db8:abcd::89"" } ``` If no `bip6` is specified, `fixed-cidr-v6` defines the",false,
102
+ 101,2000,2040,"```json { ""ipv6"": true, ""bip6"": ""2001:db8::1111/64"", ""fixed-cidr-v6"": ""2001:db8::/64"", ""default-gateway-v6"": ""2001:db8:abcd::89"" } ``` If no `bip6` is specified, `fixed-cidr-v6` defines the subnet for the bridge network. If no `bip6` or `fixed-cidr-v6` is specified, a ULA prefix will be chosen. Restart Docker",true,Docker|network
103
+ 102,2020,2060,"subnet for the bridge network. If no `bip6` or `fixed-cidr-v6` is specified, a ULA prefix will be chosen. Restart Docker for changes to take effect. ## Connection limit for bridge networks Due to limitations set by the Linux kernel, bridge",true,Docker|network
104
+ 103,2040,2080,"for changes to take effect. ## Connection limit for bridge networks Due to limitations set by the Linux kernel, bridge networks become unstable and inter-container communications may break when 1000 containers or more connect to a single network. For more",false,container|network
105
+ 104,2060,2100,"networks become unstable and inter-container communications may break when 1000 containers or more connect to a single network. For more information about this limitation, see [moby/moby#44973](https://github.com/moby/moby/issues/44973#issuecomment-1543747718). ## Skip Bridge IP address configuration The bridge is normally assigned the network's `--gateway`",false,container|network
106
+ 105,2080,2120,"information about this limitation, see [moby/moby#44973](https://github.com/moby/moby/issues/44973#issuecomment-1543747718). ## Skip Bridge IP address configuration The bridge is normally assigned the network's `--gateway` address, which is used as the default route from the bridge network to other networks. The `com.docker.network.bridge.inhibit_ipv4` option lets you",true,Docker|network
107
+ 106,2100,2140,"address, which is used as the default route from the bridge network to other networks. The `com.docker.network.bridge.inhibit_ipv4` option lets you create a network without the IPv4 gateway address being assigned to the bridge. This is useful if you want to",true,Docker|network
108
+ 107,2120,2160,"create a network without the IPv4 gateway address being assigned to the bridge. This is useful if you want to configure the gateway IP address for the bridge manually. For instance if you add a physical interface to your bridge,",false,network
109
+ 108,2140,2180,"configure the gateway IP address for the bridge manually. For instance if you add a physical interface to your bridge, and need it to have the gateway address. With this configuration, north-south traffic (to and from the bridge network) won't",false,network
110
+ 109,2160,2200,"and need it to have the gateway address. With this configuration, north-south traffic (to and from the bridge network) won't work unless you've manually configured the gateway address on the bridge, or a device attached to it. This option can",false,network
111
+ 110,2180,2220,"work unless you've manually configured the gateway address on the bridge, or a device attached to it. This option can only be used with user-defined bridge networks. ## Usage examples This section provides hands-on examples for working with bridge networks.",false,network
112
+ 111,2200,2240,only be used with user-defined bridge networks. ## Usage examples This section provides hands-on examples for working with bridge networks. ### Use the default bridge network This example shows how the default `bridge` network works. You start two `alpine` containers,false,container|network
113
+ 112,2220,2260,### Use the default bridge network This example shows how the default `bridge` network works. You start two `alpine` containers on the default bridge and test how they communicate. > [!NOTE] > The default `bridge` network is not recommended for,false,container|network
114
+ 113,2240,2280,on the default bridge and test how they communicate. > [!NOTE] > The default `bridge` network is not recommended for production. Use > user-defined bridge networks instead. 1. List current networks: ```console $ docker network ls NETWORK ID NAME DRIVER,true,Docker|network
115
+ 114,2260,2300,"production. Use > user-defined bridge networks instead. 1. List current networks: ```console $ docker network ls NETWORK ID NAME DRIVER SCOPE 17e324f45964 bridge bridge local 6ed54d316334 host host local 7092879f2cc8 none null local ``` The default `bridge` network is listed,",true,Docker|network
116
+ 115,2280,2320,"SCOPE 17e324f45964 bridge bridge local 6ed54d316334 host host local 7092879f2cc8 none null local ``` The default `bridge` network is listed, along with `host` and `none`. 2. Start two `alpine` containers running `ash`. The `-dit` flags mean detached, interactive, and with",false,container|network
117
+ 116,2300,2340,"along with `host` and `none`. 2. Start two `alpine` containers running `ash`. The `-dit` flags mean detached, interactive, and with a TTY. Since you haven't specified a `--network` flag, the containers connect to the default `bridge` network. ```console $ docker",true,Docker|container|network
118
+ 117,2320,2360,"a TTY. Since you haven't specified a `--network` flag, the containers connect to the default `bridge` network. ```console $ docker run -dit --name alpine1 alpine ash $ docker run -dit --name alpine2 alpine ash ``` Verify both containers are running:",true,Docker|container|network
119
+ 118,2340,2380,"run -dit --name alpine1 alpine ash $ docker run -dit --name alpine2 alpine ash ``` Verify both containers are running: ```console $ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 602dbf1edc81 alpine ""ash"" 4 seconds ago Up",true,Docker|container|image
120
+ 119,2360,2400,"```console $ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 602dbf1edc81 alpine ""ash"" 4 seconds ago Up 3 seconds alpine2 da33b7aa74b0 alpine ""ash"" 17 seconds ago Up 16 seconds alpine1 ``` 3. Inspect the `bridge` network to",true,Docker|container|image|network
121
+ 120,2380,2420,"3 seconds alpine2 da33b7aa74b0 alpine ""ash"" 17 seconds ago Up 16 seconds alpine1 ``` 3. Inspect the `bridge` network to see connected containers: ```console $ docker network inspect bridge ``` The output shows both containers connected, with their assigned IP",true,Docker|container|network
122
+ 121,2400,2440,"see connected containers: ```console $ docker network inspect bridge ``` The output shows both containers connected, with their assigned IP addresses (`172.17.0.2` for `alpine1` and `172.17.0.3` for `alpine2`). 4. Connect to `alpine1`: ```console $ docker attach alpine1 / # ```",true,Docker|container|network
123
+ 122,2420,2460,addresses (`172.17.0.2` for `alpine1` and `172.17.0.3` for `alpine2`). 4. Connect to `alpine1`: ```console $ docker attach alpine1 / # ``` Show the network interfaces for `alpine1` from within the container: ```console # ip addr show 1: lo: mtu 65536 qdisc,true,Docker|container|network
124
+ 123,2440,2480,Show the network interfaces for `alpine1` from within the container: ```console # ip addr show 1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128,false,container|network
125
+ 124,2460,2500,noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 27: eth0@if28: mtu 1500 qdisc noqueue state UP link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff inet 172.17.0.2/16,false,
126
+ 125,2480,2520,"scope host valid_lft forever preferred_lft forever 27: eth0@if28: mtu 1500 qdisc noqueue state UP link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff inet 172.17.0.2/16 scope global eth0 valid_lft forever preferred_lft forever ``` In this example, the `eth0` interface has the IP address `172.17.0.2`. 5.",false,
127
+ 126,2500,2540,"scope global eth0 valid_lft forever preferred_lft forever ``` In this example, the `eth0` interface has the IP address `172.17.0.2`. 5. From within `alpine1`, verify you can connect to the internet: ```console # ping -c 2 google.com PING google.com (172.217.3.174): 56",false,
128
+ 127,2520,2560,"From within `alpine1`, verify you can connect to the internet: ```console # ping -c 2 google.com PING google.com (172.217.3.174): 56 data bytes 64 bytes from 172.217.3.174: seq=0 ttl=41 time=9.841 ms 64 bytes from 172.217.3.174: seq=1 ttl=41 time=9.897 ms --- google.com",false,
129
+ 128,2540,2580,"data bytes 64 bytes from 172.217.3.174: seq=0 ttl=41 time=9.841 ms 64 bytes from 172.217.3.174: seq=1 ttl=41 time=9.897 ms --- google.com ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 9.841/9.869/9.897 ms ``` 6. Ping",false,
130
+ 129,2560,2600,"ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 9.841/9.869/9.897 ms ``` 6. Ping the second container by its IP address: ```console # ping -c 2 172.17.0.3 PING 172.17.0.3 (172.17.0.3): 56 data bytes 64",false,container
131
+ 130,2580,2620,the second container by its IP address: ```console # ping -c 2 172.17.0.3 PING 172.17.0.3 (172.17.0.3): 56 data bytes 64 bytes from 172.17.0.3: seq=0 ttl=64 time=0.086 ms 64 bytes from 172.17.0.3: seq=1 ttl=64 time=0.094 ms --- 172.17.0.3 ping statistics ---,false,container
132
+ 131,2600,2640,"bytes from 172.17.0.3: seq=0 ttl=64 time=0.086 ms 64 bytes from 172.17.0.3: seq=1 ttl=64 time=0.094 ms --- 172.17.0.3 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 0.086/0.090/0.094 ms ``` This succeeds. Now try pinging",false,
133
+ 132,2620,2660,"2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 0.086/0.090/0.094 ms ``` This succeeds. Now try pinging by container name: ```console # ping -c 2 alpine2 ping: bad address 'alpine2' ``` On the default bridge network, containers",false,container|network
134
+ 133,2640,2680,"by container name: ```console # ping -c 2 alpine2 ping: bad address 'alpine2' ``` On the default bridge network, containers can't resolve each other by name. 7. Detach from `alpine1` without stopping it using `CTRL+p CTRL+q`. 8. Clean up: stop",false,container|network
135
+ 134,2660,2700,can't resolve each other by name. 7. Detach from `alpine1` without stopping it using `CTRL+p CTRL+q`. 8. Clean up: stop the containers and remove them. ```console $ docker container stop alpine1 alpine2 $ docker container rm alpine1 alpine2 ``` Stopped,true,Docker|container
136
+ 135,2680,2720,the containers and remove them. ```console $ docker container stop alpine1 alpine2 $ docker container rm alpine1 alpine2 ``` Stopped containers lose their IP addresses. ### Use user-defined bridge networks This example shows how user-defined bridge networks provide better isolation,true,Docker|container|network
137
+ 136,2700,2740,containers lose their IP addresses. ### Use user-defined bridge networks This example shows how user-defined bridge networks provide better isolation and automatic DNS resolution between containers. 1. Create the `alpine-net` network: ```console $ docker network create --driver bridge alpine-net ```,true,Docker|container|network
138
+ 137,2720,2760,and automatic DNS resolution between containers. 1. Create the `alpine-net` network: ```console $ docker network create --driver bridge alpine-net ``` 2. List Docker's networks: ```console $ docker network ls NETWORK ID NAME DRIVER SCOPE e9261a8c9a19 alpine-net bridge local 17e324f45964 bridge,true,Docker|container|network
139
+ 138,2740,2780,2. List Docker's networks: ```console $ docker network ls NETWORK ID NAME DRIVER SCOPE e9261a8c9a19 alpine-net bridge local 17e324f45964 bridge bridge local 6ed54d316334 host host local 7092879f2cc8 none null local ``` Inspect the `alpine-net` network: ```console $ docker network inspect,true,Docker|network
140
+ 139,2760,2800,"bridge local 6ed54d316334 host host local 7092879f2cc8 none null local ``` Inspect the `alpine-net` network: ```console $ docker network inspect alpine-net ``` This shows the network's gateway (for example, `172.18.0.1`) and that no containers are connected yet. 3. Create four",true,Docker|container|network
141
+ 140,2780,2820,"alpine-net ``` This shows the network's gateway (for example, `172.18.0.1`) and that no containers are connected yet. 3. Create four containers. Three connect to `alpine-net`, and one connects to the default `bridge`. Then connect one container to both networks: ```console",false,container|network
142
+ 141,2800,2840,"containers. Three connect to `alpine-net`, and one connects to the default `bridge`. Then connect one container to both networks: ```console $ docker run -dit --name alpine1 --network alpine-net alpine ash $ docker run -dit --name alpine2 --network alpine-net alpine ash",true,Docker|container|network
143
+ 142,2820,2860,$ docker run -dit --name alpine1 --network alpine-net alpine ash $ docker run -dit --name alpine2 --network alpine-net alpine ash $ docker run -dit --name alpine3 alpine ash $ docker run -dit --name alpine4 --network alpine-net alpine ash $ docker,true,Docker|network
144
+ 143,2840,2880,$ docker run -dit --name alpine3 alpine ash $ docker run -dit --name alpine4 --network alpine-net alpine ash $ docker network connect bridge alpine4 ``` Verify all containers are running: ```console $ docker container ls CONTAINER ID IMAGE COMMAND CREATED,true,Docker|container|image|network
145
+ 144,2860,2900,"network connect bridge alpine4 ``` Verify all containers are running: ```console $ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 156849ccd902 alpine ""ash"" 41 seconds ago Up 41 seconds alpine4 fa1340b8d83e alpine ""ash"" 51 seconds ago Up",true,Docker|container|image|network
146
+ 145,2880,2920,"STATUS PORTS NAMES 156849ccd902 alpine ""ash"" 41 seconds ago Up 41 seconds alpine4 fa1340b8d83e alpine ""ash"" 51 seconds ago Up 51 seconds alpine3 a535d969081e alpine ""ash"" About a minute ago Up About a minute alpine2 0a02c449a6e9 alpine ""ash"" About a",false,
147
+ 146,2900,2940,"51 seconds alpine3 a535d969081e alpine ""ash"" About a minute ago Up About a minute alpine2 0a02c449a6e9 alpine ""ash"" About a minute ago Up About a minute alpine1 ``` 4. Inspect both networks again to see which containers are connected: ```console",false,container|network
148
+ 147,2920,2960,minute ago Up About a minute alpine1 ``` 4. Inspect both networks again to see which containers are connected: ```console $ docker network inspect bridge ``` Containers `alpine3` and `alpine4` are connected to the `bridge` network. ```console $ docker network,true,Docker|container|network
149
+ 148,2940,2980,"$ docker network inspect bridge ``` Containers `alpine3` and `alpine4` are connected to the `bridge` network. ```console $ docker network inspect alpine-net ``` Containers `alpine1`, `alpine2`, and `alpine4` are connected to `alpine-net`. 5. On user-defined networks, containers can resolve each",true,Docker|container|network
150
+ 149,2960,3000,"inspect alpine-net ``` Containers `alpine1`, `alpine2`, and `alpine4` are connected to `alpine-net`. 5. On user-defined networks, containers can resolve each other by name. Connect to `alpine1` and test: > [!NOTE] > Automatic service discovery only resolves custom container names, not",false,container|network
151
+ 150,2980,3020,"other by name. Connect to `alpine1` and test: > [!NOTE] > Automatic service discovery only resolves custom container names, not > default automatically generated names. ```console $ docker container attach alpine1 # ping -c 2 alpine2 PING alpine2 (172.18.0.3): 56",true,Docker|container
152
+ 151,3000,3040,> default automatically generated names. ```console $ docker container attach alpine1 # ping -c 2 alpine2 PING alpine2 (172.18.0.3): 56 data bytes 64 bytes from 172.18.0.3: seq=0 ttl=64 time=0.085 ms 64 bytes from 172.18.0.3: seq=1 ttl=64 time=0.090 ms --- alpine2,true,Docker|container
153
+ 152,3020,3060,"data bytes 64 bytes from 172.18.0.3: seq=0 ttl=64 time=0.085 ms 64 bytes from 172.18.0.3: seq=1 ttl=64 time=0.090 ms --- alpine2 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 0.085/0.087/0.090 ms # ping -c",false,
154
+ 153,3040,3080,"ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 0.085/0.087/0.090 ms # ping -c 2 alpine4 PING alpine4 (172.18.0.4): 56 data bytes 64 bytes from 172.18.0.4: seq=0 ttl=64 time=0.076 ms 64 bytes from 172.18.0.4:",false,
155
+ 154,3060,3100,"2 alpine4 PING alpine4 (172.18.0.4): 56 data bytes 64 bytes from 172.18.0.4: seq=0 ttl=64 time=0.076 ms 64 bytes from 172.18.0.4: seq=1 ttl=64 time=0.091 ms --- alpine4 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max",false,
156
+ 155,3080,3120,"seq=1 ttl=64 time=0.091 ms --- alpine4 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 0.076/0.083/0.091 ms ``` 6. From `alpine1`, you can't connect to `alpine3` because it's on a different network: ```console #",false,network
157
+ 156,3100,3140,"= 0.076/0.083/0.091 ms ``` 6. From `alpine1`, you can't connect to `alpine3` because it's on a different network: ```console # ping -c 2 alpine3 ping: bad address 'alpine3' ``` You also can't connect by IP address. If `alpine3`'s IP is",false,network
158
+ 157,3120,3160,ping -c 2 alpine3 ping: bad address 'alpine3' ``` You also can't connect by IP address. If `alpine3`'s IP is `172.17.0.2`: ```console # ping -c 2 172.17.0.2 PING 172.17.0.2 (172.17.0.2): 56 data bytes --- 172.17.0.2 ping statistics --- 2 packets,false,
159
+ 158,3140,3180,"`172.17.0.2`: ```console # ping -c 2 172.17.0.2 PING 172.17.0.2 (172.17.0.2): 56 data bytes --- 172.17.0.2 ping statistics --- 2 packets transmitted, 0 packets received, 100% packet loss ``` Detach from `alpine1` using `CTRL+p CTRL+q`. 7. Since `alpine4` is connected to",false,
160
+ 159,3160,3200,"transmitted, 0 packets received, 100% packet loss ``` Detach from `alpine1` using `CTRL+p CTRL+q`. 7. Since `alpine4` is connected to both networks, it can reach all containers. However, you need to use `alpine3`'s IP address: ```console $ docker container attach",true,Docker|container|network
161
+ 160,3180,3220,"both networks, it can reach all containers. However, you need to use `alpine3`'s IP address: ```console $ docker container attach alpine4 # ping -c 2 alpine1 PING alpine1 (172.18.0.2): 56 data bytes 64 bytes from 172.18.0.2: seq=0 ttl=64 time=0.074 ms",true,Docker|container|network
162
+ 161,3200,3240,"alpine4 # ping -c 2 alpine1 PING alpine1 (172.18.0.2): 56 data bytes 64 bytes from 172.18.0.2: seq=0 ttl=64 time=0.074 ms 64 bytes from 172.18.0.2: seq=1 ttl=64 time=0.082 ms --- alpine1 ping statistics --- 2 packets transmitted, 2 packets received, 0%",false,
163
+ 162,3220,3260,"64 bytes from 172.18.0.2: seq=1 ttl=64 time=0.082 ms --- alpine1 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 0.074/0.078/0.082 ms # ping -c 2 alpine2 PING alpine2 (172.18.0.3): 56 data bytes 64 bytes",false,
164
+ 163,3240,3280,packet loss round-trip min/avg/max = 0.074/0.078/0.082 ms # ping -c 2 alpine2 PING alpine2 (172.18.0.3): 56 data bytes 64 bytes from 172.18.0.3: seq=0 ttl=64 time=0.075 ms 64 bytes from 172.18.0.3: seq=1 ttl=64 time=0.080 ms --- alpine2 ping statistics --- 2,false,
165
+ 164,3260,3300,"from 172.18.0.3: seq=0 ttl=64 time=0.075 ms 64 bytes from 172.18.0.3: seq=1 ttl=64 time=0.080 ms --- alpine2 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 0.075/0.077/0.080 ms # ping -c 2 alpine3 ping: bad",false,
166
+ 165,3280,3320,"packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 0.075/0.077/0.080 ms # ping -c 2 alpine3 ping: bad address 'alpine3' # ping -c 2 172.17.0.2 PING 172.17.0.2 (172.17.0.2): 56 data bytes 64 bytes from 172.17.0.2: seq=0 ttl=64 time=0.089",false,
167
+ 166,3300,3340,"address 'alpine3' # ping -c 2 172.17.0.2 PING 172.17.0.2 (172.17.0.2): 56 data bytes 64 bytes from 172.17.0.2: seq=0 ttl=64 time=0.089 ms 64 bytes from 172.17.0.2: seq=1 ttl=64 time=0.075 ms --- 172.17.0.2 ping statistics --- 2 packets transmitted, 2 packets received,",false,
168
+ 167,3320,3360,"ms 64 bytes from 172.17.0.2: seq=1 ttl=64 time=0.075 ms --- 172.17.0.2 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 0.075/0.082/0.089 ms ``` 8. Verify all containers can connect to the internet: ```console #",false,container
169
+ 168,3340,3380,0% packet loss round-trip min/avg/max = 0.075/0.082/0.089 ms ``` 8. Verify all containers can connect to the internet: ```console # ping -c 2 google.com PING google.com (172.217.3.174): 56 data bytes 64 bytes from 172.217.3.174: seq=0 ttl=41 time=9.778 ms 64 bytes,false,container
170
+ 169,3360,3400,"ping -c 2 google.com PING google.com (172.217.3.174): 56 data bytes 64 bytes from 172.217.3.174: seq=0 ttl=41 time=9.778 ms 64 bytes from 172.217.3.174: seq=1 ttl=41 time=9.634 ms --- google.com ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss",false,
171
+ 170,3380,3420,"from 172.217.3.174: seq=1 ttl=41 time=9.634 ms --- google.com ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 9.634/9.706/9.778 ms ``` Detach with `CTRL+p CTRL+q` and repeat for `alpine3` and `alpine1` if desired. 9. Clean",false,
172
+ 171,3400,3440,round-trip min/avg/max = 9.634/9.706/9.778 ms ``` Detach with `CTRL+p CTRL+q` and repeat for `alpine3` and `alpine1` if desired. 9. Clean up: ```console $ docker container stop alpine1 alpine2 alpine3 alpine4 $ docker container rm alpine1 alpine2 alpine3 alpine4 $ docker,true,Docker|container
173
+ 172,3420,3460,up: ```console $ docker container stop alpine1 alpine2 alpine3 alpine4 $ docker container rm alpine1 alpine2 alpine3 alpine4 $ docker network rm alpine-net ``` ## Next steps - Learn about [networking from the container's point of view](../_index.md) - Learn about,true,Docker|container|network
174
+ 173,3440,3468,network rm alpine-net ``` ## Next steps - Learn about [networking from the container's point of view](../_index.md) - Learn about [overlay networks](./overlay.md) - Learn about [Macvlan networks](./macvlan.md) ```,false,container|network
20260907-002107-computing-math-7483af/environment/public_data/main.py ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import importlib.util
4
+ import json
5
+ import os
6
+ import shlex
7
+ import shutil
8
+ from pathlib import Path
9
+ from typing import Any
10
+
11
+
12
+ class Task:
13
+ def __init__(self, task_id: str, description: str, metadata: dict[str, Any]):
14
+ self.task_id = task_id
15
+ self.description = description
16
+ self.prompt = description
17
+ self.metadata = metadata
18
+ self.computer = {"setup_config": {"os_type": "linux"}}
19
+
20
+
21
+ def _task_dir() -> Path:
22
+ return Path(__file__).resolve().parent
23
+
24
+
25
+ def _load_card() -> dict[str, Any]:
26
+ path = _task_dir() / "task_card.json"
27
+ if not path.is_file():
28
+ return {
29
+ "taskId": os.environ.get("ALE_TASK_ID", "computing_math/docker_bridge_tutorial_offline_audit"),
30
+ "taskPrompt": "Task card has not been rendered yet; this fallback exists for stage-03 hook smoke only.",
31
+ "metadata": {
32
+ "domain": "computing_math",
33
+ "task": "docker_bridge_tutorial_offline_audit",
34
+ "variant": "base",
35
+ "domain_name": "computing_math",
36
+ "task_name": "docker_bridge_tutorial_offline_audit",
37
+ "variant_name": "base",
38
+ "requires_task_data": True,
39
+ "task_dir": "/media/user/data/agenthle/computing_math/docker_bridge_tutorial_offline_audit/base",
40
+ "input_dir": "/media/user/data/agenthle/computing_math/docker_bridge_tutorial_offline_audit/base/input",
41
+ "software_dir": "/media/user/data/agenthle/computing_math/docker_bridge_tutorial_offline_audit/base/software",
42
+ "remote_output_dir": "/media/user/data/agenthle/computing_math/docker_bridge_tutorial_offline_audit/base/output",
43
+ "reference_dir": "/media/user/data/agenthle/computing_math/docker_bridge_tutorial_offline_audit/base/reference",
44
+ },
45
+ }
46
+ with path.open("r", encoding="utf-8") as handle:
47
+ return json.load(handle)
48
+
49
+
50
+ def load() -> list[Task]:
51
+ card = _load_card()
52
+ metadata = dict(card.get("metadata") or {})
53
+ if not metadata:
54
+ domain, _, task = str(card["taskId"]).partition("/")
55
+ variant = "base"
56
+ task_dir = f"/media/user/data/agenthle/{domain}/{task}/{variant}"
57
+ metadata.update({
58
+ "domain": domain,
59
+ "task": task,
60
+ "variant": variant,
61
+ "domain_name": domain,
62
+ "task_name": task,
63
+ "variant_name": variant,
64
+ "requires_task_data": True,
65
+ "task_dir": task_dir,
66
+ "input_dir": f"{task_dir}/input",
67
+ "software_dir": f"{task_dir}/software",
68
+ "remote_output_dir": f"{task_dir}/output",
69
+ "reference_dir": f"{task_dir}/reference",
70
+ })
71
+ return [Task(task_id=card["taskId"], description=card["taskPrompt"], metadata=metadata)]
72
+
73
+
74
+ def _metadata(cfg: Any = None) -> dict[str, Any]:
75
+ if cfg is None:
76
+ return {}
77
+ value = getattr(cfg, "metadata", None)
78
+ return value if isinstance(value, dict) else {}
79
+
80
+
81
+ def _remote_path(metadata: dict[str, Any], key: str, fallback: str) -> str:
82
+ value = str(metadata.get(key) or "").strip()
83
+ return value or fallback
84
+
85
+
86
+ async def _remote_run(session: Any, command: str, *, check: bool = False) -> Any:
87
+ try:
88
+ return await session.run_command(command, check=check)
89
+ except TypeError:
90
+ return await session.run_command(command)
91
+
92
+
93
+ async def _remote_start(cfg: Any, session: Any) -> dict[str, Any]:
94
+ metadata = _metadata(cfg)
95
+ output_dir = _remote_path(metadata, "remote_output_dir", "output")
96
+ input_dir = _remote_path(metadata, "input_dir", "input")
97
+ software_dir = _remote_path(metadata, "software_dir", "software")
98
+ command = (
99
+ "set -eu\n"
100
+ f"mkdir -p {shlex.quote(output_dir)}\n"
101
+ f"find {shlex.quote(output_dir)} -mindepth 1 -maxdepth 1 -exec rm -rf -- {{}} +\n"
102
+ )
103
+ await _remote_run(session, command, check=True)
104
+ return {"ok": True, "input_dir": input_dir, "software_dir": software_dir, "output_dir": output_dir}
105
+
106
+
107
+ def start(cfg: Any = None, session: Any = None) -> dict[str, Any]:
108
+ if session is not None:
109
+ return _remote_start(cfg, session)
110
+ del cfg
111
+ output_dir = Path(os.environ.get("ALE_OUTPUT_DIR", "output"))
112
+ output_dir.mkdir(parents=True, exist_ok=True)
113
+ for child in output_dir.iterdir():
114
+ if child.is_dir():
115
+ shutil.rmtree(child)
116
+ else:
117
+ child.unlink()
118
+ input_dir = Path(os.environ.get("ALE_INPUT_DIR", "input"))
119
+ software_dir = Path(os.environ.get("ALE_SOFTWARE_DIR", "software"))
120
+ return {
121
+ "ok": True,
122
+ "input_dir": str(input_dir),
123
+ "software_dir": str(software_dir),
124
+ "output_dir": str(output_dir),
125
+ }
126
+
127
+
128
+ async def _remote_evaluate(cfg: Any, session: Any) -> list[float]:
129
+ metadata = _metadata(cfg)
130
+ output_dir = _remote_path(metadata, "remote_output_dir", "output")
131
+ reference_dir = _remote_path(metadata, "reference_dir", "reference")
132
+ script = f"""
133
+ import importlib.util
134
+ import json
135
+ import pathlib
136
+
137
+ output_dir = pathlib.Path({output_dir!r})
138
+ reference_dir = pathlib.Path({reference_dir!r})
139
+ evaluator_path = reference_dir / "evaluator.py"
140
+ if not evaluator_path.is_file():
141
+ raise FileNotFoundError(f"hidden evaluator is missing: {{evaluator_path}}")
142
+ spec = importlib.util.spec_from_file_location("hidden_ale_evaluator", evaluator_path)
143
+ if spec is None or spec.loader is None:
144
+ raise RuntimeError(f"cannot import hidden evaluator: {{evaluator_path}}")
145
+ module = importlib.util.module_from_spec(spec)
146
+ spec.loader.exec_module(module)
147
+ result = module.evaluate(output_dir, reference_dir)
148
+ print(json.dumps(result))
149
+ """
150
+ command = "python3 - <<'PY'\n" + script + "\nPY"
151
+ result = await _remote_run(session, command, check=True)
152
+ stdout = getattr(result, "stdout", "") or ""
153
+ for line in reversed([item.strip() for item in stdout.splitlines() if item.strip()]):
154
+ try:
155
+ payload = json.loads(line)
156
+ if isinstance(payload, list):
157
+ return [float(max(0.0, min(1.0, value))) for value in payload]
158
+ except Exception:
159
+ continue
160
+ raise RuntimeError("hidden evaluator did not emit a JSON score list")
161
+
162
+
163
+ def evaluate(cfg: Any = None, session: Any = None) -> list[float]:
164
+ if session is not None:
165
+ return _remote_evaluate(cfg, session)
166
+ del cfg
167
+ output_dir = Path(os.environ.get("ALE_OUTPUT_DIR", "output"))
168
+ reference_dir = Path(os.environ.get("ALE_REFERENCE_DIR", "reference"))
169
+ evaluator_path = reference_dir / "evaluator.py"
170
+ if not evaluator_path.is_file():
171
+ raise FileNotFoundError(f"hidden evaluator is missing: {evaluator_path}")
172
+ spec = importlib.util.spec_from_file_location("hidden_ale_evaluator", evaluator_path)
173
+ if spec is None or spec.loader is None:
174
+ raise RuntimeError(f"cannot import hidden evaluator: {evaluator_path}")
175
+ module = importlib.util.module_from_spec(spec)
176
+ spec.loader.exec_module(module)
177
+ result = module.evaluate(output_dir, reference_dir)
178
+ if not isinstance(result, list):
179
+ raise TypeError("hidden evaluator must return list[float]")
180
+ return [float(max(0.0, min(1.0, value))) for value in result]
20260907-002107-computing-math-7483af/environment/public_data/software/command_examples.csv ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ term,kind,software_name
2
+ docker compose,code_term,Docker
3
+ docker pull,code_term,Docker
4
+ docker,code_term,Docker
5
+ docker run,code_term,Docker
6
+ docker,executable,Docker
7
+ docker compose,executable,Docker
20260907-002107-computing-math-7483af/environment/public_data/software/software_manifest.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "software_name": "Docker",
3
+ "executables": [
4
+ "docker",
5
+ "docker compose"
6
+ ],
7
+ "required_system_packages": [
8
+ "docker.io",
9
+ "docker-compose-plugin"
10
+ ],
11
+ "official_sources": [
12
+ "https://raw.githubusercontent.com/docker/docs/main/content/manuals/engine/network/drivers/bridge.md"
13
+ ],
14
+ "solve_time_network": "disabled",
15
+ "python_wrapper_only": false,
16
+ "note": "This task audits real official software documentation/source staged offline; Python helpers only validate outputs."
17
+ }
20260907-002107-computing-math-7483af/environment/public_data/software/validate_outputs.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ from __future__ import annotations
3
+
4
+ import json
5
+ import os
6
+ import sys
7
+ from pathlib import Path
8
+
9
+
10
+ def required_outputs(input_dir: Path) -> list[str]:
11
+ spec_path = input_dir / "analysis_spec.json"
12
+ if spec_path.is_file():
13
+ payload = json.loads(spec_path.read_text(encoding="utf-8"))
14
+ required = payload.get("required_outputs") if isinstance(payload, dict) else None
15
+ if isinstance(required, list):
16
+ rows = [str(item.get("path") or "") for item in required if isinstance(item, dict)]
17
+ rows = [item for item in rows if item]
18
+ if rows:
19
+ return rows
20
+ return [
21
+ "summary.json",
22
+ "magnitude_depth_bins.csv",
23
+ "region_daily_counts.csv",
24
+ "filtered_events.geojson",
25
+ ]
26
+
27
+
28
+ def main() -> int:
29
+ output_dir = Path(sys.argv[1]) if len(sys.argv) > 1 else Path("output")
30
+ input_dir = Path(sys.argv[2]) if len(sys.argv) > 2 else Path(os.environ.get("ALE_INPUT_DIR", "input"))
31
+ required = required_outputs(input_dir)
32
+ missing = [name for name in required if not (output_dir / name).is_file()]
33
+ if missing:
34
+ print(json.dumps({"ok": False, "missing": missing}, indent=2))
35
+ return 1
36
+ print(json.dumps({"ok": True, "required": required}, indent=2))
37
+ return 0
38
+
39
+
40
+ if __name__ == "__main__":
41
+ raise SystemExit(main())
20260907-002107-computing-math-7483af/environment/public_data/task_card.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "taskId": "computing_math/docker_bridge_tutorial_offline_audit__20260907-002107_computing_math_7483af",
3
+ "title": "Repair3 20260907 043 Repair2 20260906 047 Repair 20260906 Software 0078",
4
+ "summary": "Audit a staged offline Docker official tutorial corpus and produce reproducible section, keyword, and command inventories from local files (keyword-subset experiment 13: 5 terms) (ALE-100 software diversity variant 15) (independent source snapshot 15). (repair batch 20260906; independent official source) (targeted repair round 2). (targeted repair round 3).",
5
+ "category": "computing_math",
6
+ "taxonomy": {
7
+ "domain_id": "9",
8
+ "domain_code": "computing_math",
9
+ "subdomain_id": "9.6",
10
+ "subdomain_code": "infra_cloud",
11
+ "subdomain_name": "Infrastructure Engineering & Cloud Operations",
12
+ "classifier": {
13
+ "source": "public software metadata mapping",
14
+ "rationale": "Subdomain selected from public task metadata."
15
+ }
16
+ },
17
+ "taskPrompt": "Use a Linux command-line workflow to audit the staged offline official tutorial corpus for Docker. The source document is input/tutorial_source.html, and input/tutorial_text_windows.csv contains deterministic text windows derived from it. Your job is to reconstruct the section outline, keyword inventory, code-block inventory, and summary statistics from the local files. Read only the staged files in input/ and software/, write final deliverables under output/, and do not use network access, credentials, GUI tools, browser automation, Windows-only tooling, or mobile apps. The authoritative public contract is input/analysis_spec.json; if any wording elsewhere is less specific, follow analysis_spec.json for file names, columns, filters, grouping rules, rounding rules, and output schemas. The workflow kind is software_tutorial_doc_audit. The primary staged data file is input/tutorial_text_windows.csv. Produce exactly these required deliverables: output/summary.json, output/section_outline.csv, output/keyword_inventory.csv, output/code_block_inventory.csv. The output schemas are:\n- output/summary.json: JSON keys and nested shape {\"code_block_count\": \"integer\", \"heading_count\": \"integer\", \"keyword_total\": \"integer\", \"software_name\": \"string\", \"source_character_count\": \"integer\", \"source_file\": \"string\", \"top_keyword\": \"string|null\", \"unique_required_terms_found\": \"integer\", \"window_count\": \"integer\"}\n- output/section_outline.csv: CSV header exactly rank, heading_level, heading_text, slug\n- output/keyword_inventory.csv: CSV header exactly term, category, count, first_window, appears_in_code\n- output/code_block_inventory.csv: CSV header exactly block_index, line_count, char_count, contains_code_term, first_line\nCompute all requested values from the staged data rather than hard-coding constants. Use deterministic ordering, UTF-8 text, explicit CSV headers, valid JSON/GeoJSON where applicable, and stable numeric formatting. You may run software/validate_outputs.py as a public sanity check after writing outputs, but the deliverables in output/ are what will be evaluated.",
18
+ "agentMustDo": [
19
+ "Read input/analysis_spec.json first and treat it as the authoritative public specification.",
20
+ "Read input/tutorial_text_windows.csv and compute results from the staged local data.",
21
+ "Create output/summary.json as json exactly as specified by analysis_spec.json.",
22
+ "Create output/section_outline.csv as csv exactly as specified by analysis_spec.json.",
23
+ "Create output/keyword_inventory.csv as csv exactly as specified by analysis_spec.json.",
24
+ "Create output/code_block_inventory.csv as csv exactly as specified by analysis_spec.json.",
25
+ "Place every final deliverable directly under output/ with the exact required filename.",
26
+ "Use only local staged files and installed Linux CLI tooling; do not download fresh data."
27
+ ],
28
+ "inputFiles": [
29
+ {
30
+ "name": "README.md",
31
+ "format": "Markdown",
32
+ "path": "input/README.md",
33
+ "description": "Agent-visible staged input file for this task."
34
+ },
35
+ {
36
+ "name": "analysis_spec.json",
37
+ "format": "JSON",
38
+ "path": "input/analysis_spec.json",
39
+ "description": "Agent-visible staged input file for this task."
40
+ },
41
+ {
42
+ "name": "source_context_windows.jsonl",
43
+ "format": "JSONL",
44
+ "path": "input/source_context_windows.jsonl",
45
+ "description": "Agent-visible staged input file for this task."
46
+ },
47
+ {
48
+ "name": "tutorial_metadata.json",
49
+ "format": "JSON",
50
+ "path": "input/tutorial_metadata.json",
51
+ "description": "Agent-visible staged input file for this task."
52
+ },
53
+ {
54
+ "name": "tutorial_source.html",
55
+ "format": "HTML",
56
+ "path": "input/tutorial_source.html",
57
+ "description": "Agent-visible staged input file for this task."
58
+ },
59
+ {
60
+ "name": "tutorial_text_windows.csv",
61
+ "format": "CSV",
62
+ "path": "input/tutorial_text_windows.csv",
63
+ "description": "Agent-visible staged input file for this task."
64
+ }
65
+ ],
66
+ "referenceFiles": [
67
+ {
68
+ "name": "summary.json",
69
+ "format": "JSON",
70
+ "path": "output/summary.json",
71
+ "description": "Required agent output file evaluated against hidden reference data."
72
+ },
73
+ {
74
+ "name": "section_outline.csv",
75
+ "format": "CSV",
76
+ "path": "output/section_outline.csv",
77
+ "description": "Required agent output file evaluated against hidden reference data."
78
+ },
79
+ {
80
+ "name": "keyword_inventory.csv",
81
+ "format": "CSV",
82
+ "path": "output/keyword_inventory.csv",
83
+ "description": "Required agent output file evaluated against hidden reference data."
84
+ },
85
+ {
86
+ "name": "code_block_inventory.csv",
87
+ "format": "CSV",
88
+ "path": "output/code_block_inventory.csv",
89
+ "description": "Required agent output file evaluated against hidden reference data."
90
+ }
91
+ ],
92
+ "software": [
93
+ "Docker",
94
+ "docker",
95
+ "docker compose",
96
+ "Python 3.11",
97
+ "standard Unix shell",
98
+ "software/command_examples.csv",
99
+ "software/software_manifest.json",
100
+ "software/validate_outputs.py"
101
+ ],
102
+ "requiredSystemPackages": [
103
+ "docker.io",
104
+ "docker-compose-plugin"
105
+ ],
106
+ "evaluation": "Final required files under output/ are compared against standard-reference outputs generated by the deterministic workflow for this task.",
107
+ "vm": {
108
+ "machineType": "c4-standard-4",
109
+ "snapshot": "cpu-free-ubuntu",
110
+ "timeout": 7200
111
+ }
112
+ }
20260907-002107-computing-math-7483af/instruction.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Repair3 20260907 043 Repair2 20260906 047 Repair 20260906 Software 0078
2
+
3
+ Audit a staged offline Docker official tutorial corpus and produce reproducible section, keyword, and command inventories from local files (keyword-subset experiment 13: 5 terms) (ALE-100 software diversity variant 15) (independent source snapshot 15). (repair batch 20260906; independent official source) (targeted repair round 2). (targeted repair round 3).
4
+
5
+ ## Task
6
+
7
+ Use a Linux command-line workflow to audit the staged offline official tutorial corpus for Docker. The source document is input/tutorial_source.html, and input/tutorial_text_windows.csv contains deterministic text windows derived from it. Your job is to reconstruct the section outline, keyword inventory, code-block inventory, and summary statistics from the local files. Read only the staged files in input/ and software/, write final deliverables under output/, and do not use network access, credentials, GUI tools, browser automation, Windows-only tooling, or mobile apps. The authoritative public contract is input/analysis_spec.json; if any wording elsewhere is less specific, follow analysis_spec.json for file names, columns, filters, grouping rules, rounding rules, and output schemas. The workflow kind is software_tutorial_doc_audit. The primary staged data file is input/tutorial_text_windows.csv. Produce exactly these required deliverables: output/summary.json, output/section_outline.csv, output/keyword_inventory.csv, output/code_block_inventory.csv. The output schemas are:
8
+ - output/summary.json: JSON keys and nested shape {"code_block_count": "integer", "heading_count": "integer", "keyword_total": "integer", "software_name": "string", "source_character_count": "integer", "source_file": "string", "top_keyword": "string|null", "unique_required_terms_found": "integer", "window_count": "integer"}
9
+ - output/section_outline.csv: CSV header exactly rank, heading_level, heading_text, slug
10
+ - output/keyword_inventory.csv: CSV header exactly term, category, count, first_window, appears_in_code
11
+ - output/code_block_inventory.csv: CSV header exactly block_index, line_count, char_count, contains_code_term, first_line
12
+ Compute all requested values from the staged data rather than hard-coding constants. Use deterministic ordering, UTF-8 text, explicit CSV headers, valid JSON/GeoJSON where applicable, and stable numeric formatting. You may run software/validate_outputs.py as a public sanity check after writing outputs, but the deliverables in output/ are what will be evaluated.
13
+
14
+ ## Workspace
15
+
16
+ You are working in `/workspace`.
17
+
18
+ - Public input files are under `/workspace/input/`.
19
+ - Public helper software and validation scripts are under `/workspace/software/`.
20
+ - The public task card is available at `/workspace/task_card.json`.
21
+ - The public task driver is available at `/workspace/main.py` for reference only.
22
+ - Do not use hidden reference data, network downloads, credentials, GUI tools, or browser automation.
23
+
24
+ ## Required Outputs
25
+
26
+ Create every final deliverable exactly at these paths:
27
+
28
+ - `/workspace/output/summary.json` (json)
29
+ - `/workspace/output/section_outline.csv` (csv)
30
+ - `/workspace/output/keyword_inventory.csv` (csv)
31
+ - `/workspace/output/code_block_inventory.csv` (csv)
32
+
33
+ Follow `/workspace/input/analysis_spec.json` whenever it is more specific than prose. You may run public validation helpers, but the files under `/workspace/output/` are what will be evaluated.
20260907-002107-computing-math-7483af/solution/internal/workflow_adapters_runtime.py ADDED
@@ -0,0 +1,679 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import csv
4
+ import datetime as dt
5
+ import html
6
+ import json
7
+ import math
8
+ import re
9
+ import shutil
10
+ import statistics
11
+ from pathlib import Path
12
+ from typing import Any
13
+
14
+
15
+ def _read_json(path: Path) -> Any:
16
+ with path.open("r", encoding="utf-8") as handle:
17
+ return json.load(handle)
18
+
19
+
20
+ def _write_json(path: Path, payload: Any) -> None:
21
+ path.parent.mkdir(parents=True, exist_ok=True)
22
+ with path.open("w", encoding="utf-8") as handle:
23
+ json.dump(payload, handle, ensure_ascii=False, indent=2)
24
+ handle.write("\n")
25
+
26
+ def _stable_region(place: str) -> str:
27
+ if not place:
28
+ return "unknown"
29
+ if "," in place:
30
+ return place.split(",")[-1].strip() or place.strip()
31
+ parts = place.split()
32
+ return " ".join(parts[-2:]) if len(parts) >= 2 else place.strip()
33
+
34
+
35
+ def _mag_bin(value: float | None) -> str:
36
+ if value is None or math.isnan(value):
37
+ return "unknown"
38
+ lower = math.floor(value)
39
+ upper = lower + 1
40
+ return f"{lower:.0f}-{upper:.0f}"
41
+
42
+
43
+ def _depth_bin(value: float | None) -> str:
44
+ if value is None or math.isnan(value):
45
+ return "unknown"
46
+ if value < 0:
47
+ return "<0"
48
+ if value < 10:
49
+ return "0-10"
50
+ if value < 30:
51
+ return "10-30"
52
+ if value < 70:
53
+ return "30-70"
54
+ if value < 300:
55
+ return "70-300"
56
+ return "300+"
57
+
58
+
59
+ def _clean_markup_text(raw: str) -> str:
60
+ text = re.sub(r"(?is)<(script|style|noscript)[^>]*>.*?</\1>", " ", raw)
61
+ text = re.sub(r"(?is)<br\s*/?>", "\n", text)
62
+ text = re.sub(r"(?is)</(p|div|li|tr|h[1-6]|pre)>", "\n", text)
63
+ text = re.sub(r"(?is)<[^>]+>", " ", text)
64
+ text = html.unescape(text)
65
+ text = re.sub(r"[ \t]+", " ", text)
66
+ text = re.sub(r"\n\s+", "\n", text)
67
+ return text.strip()
68
+
69
+
70
+ def _heading_slug(value: str) -> str:
71
+ slug = re.sub(r"[^a-z0-9]+", "_", value.lower()).strip("_")
72
+ return slug[:80] or "section"
73
+
74
+
75
+ def _extract_headings(raw: str) -> list[dict[str, str]]:
76
+ headings: list[dict[str, str]] = []
77
+ for match in re.finditer(r"(?is)<h([1-6])[^>]*>(.*?)</h\1>", raw):
78
+ text = _clean_markup_text(match.group(2))
79
+ if text:
80
+ headings.append({"level": f"h{match.group(1)}", "text": text})
81
+ if headings:
82
+ return headings
83
+ for line in raw.splitlines():
84
+ match = re.match(r"^(#{1,6})\s+(.+?)\s*$", line)
85
+ if match:
86
+ headings.append({"level": f"h{len(match.group(1))}", "text": match.group(2).strip()})
87
+ return headings
88
+
89
+
90
+ def _extract_code_blocks(raw: str) -> list[str]:
91
+ blocks: list[str] = []
92
+ for match in re.finditer(r"(?is)<pre[^>]*>(.*?)</pre>", raw):
93
+ text = _clean_markup_text(match.group(1))
94
+ if text:
95
+ blocks.append(text)
96
+ for match in re.finditer(r"(?is)<code[^>]*>(.*?)</code>", raw):
97
+ text = _clean_markup_text(match.group(1))
98
+ if text and text not in blocks:
99
+ blocks.append(text)
100
+ for match in re.finditer(r"(?s)```(?:[A-Za-z0-9_-]+)?\n(.*?)```", raw):
101
+ text = html.unescape(match.group(1).strip())
102
+ if text and text not in blocks:
103
+ blocks.append(text)
104
+ return blocks
105
+
106
+
107
+ def _window_rows(clean_text: str, *, width: int = 40, stride: int = 20) -> list[dict[str, Any]]:
108
+ words = re.findall(r"\S+", clean_text)
109
+ rows: list[dict[str, Any]] = []
110
+ if not words:
111
+ return rows
112
+ start = 0
113
+ while start < len(words):
114
+ end = min(start + width, len(words))
115
+ rows.append({
116
+ "window_id": len(rows) + 1,
117
+ "start_word": start,
118
+ "end_word": end,
119
+ "text": " ".join(words[start:end]),
120
+ })
121
+ if end == len(words):
122
+ break
123
+ start += stride
124
+ return rows
125
+
126
+
127
+ def _term_count(text: str, term: str) -> int:
128
+ term = term.strip()
129
+ if not term:
130
+ return 0
131
+ return len(re.findall(re.escape(term), text, flags=re.IGNORECASE))
132
+
133
+
134
+ def _first_window(windows: list[dict[str, Any]], term: str) -> str:
135
+ term_lower = term.lower()
136
+ for row in windows:
137
+ if term_lower in str(row.get("text") or "").lower():
138
+ return str(row.get("window_id") or "")
139
+ return ""
140
+
141
+
142
+ def _write_tutorial_public_inputs(input_dir: Path, source_path: Path, spec_payload: dict[str, Any]) -> None:
143
+ raw = source_path.read_text(encoding="utf-8", errors="replace")
144
+ # Tutorial examples may contain a maintainer's local Windows path. Keep
145
+ # the command semantics while preventing host-specific paths from entering
146
+ # the public task artifact.
147
+ sanitized_raw = re.sub(r"(?i)\b[A-Z]:\\(?:[^\\\r\n<>\"']+\\?)*[^\\\r\n<>\"']*", "./local.db", raw)
148
+ clean_text = _clean_markup_text(sanitized_raw)
149
+ windows = _window_rows(clean_text)
150
+ if len(windows) < 100:
151
+ raise ValueError(f"official tutorial source produced only {len(windows)} text windows; need at least 100")
152
+ required_terms = [str(item) for item in spec_payload.get("required_terms") or []]
153
+ code_terms = [str(item) for item in spec_payload.get("code_terms") or []]
154
+ input_dir.mkdir(parents=True, exist_ok=True)
155
+ destination = input_dir / str(spec_payload["source_file"])
156
+ # Always materialize the sanitized copy, including when the downloader
157
+ # already placed the source at the destination path.
158
+ destination.write_text(sanitized_raw, encoding="utf-8")
159
+ with (input_dir / str(spec_payload["input_file"])).open("w", encoding="utf-8", newline="") as handle:
160
+ fieldnames = ["window_id", "start_word", "end_word", "text", "contains_code_term", "matched_required_terms"]
161
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
162
+ writer.writeheader()
163
+ for row in windows:
164
+ text = str(row["text"])
165
+ matched = [term for term in required_terms if term.lower() in text.lower()]
166
+ contains_code = any(term.lower() in text.lower() for term in code_terms)
167
+ writer.writerow({
168
+ "window_id": row["window_id"],
169
+ "start_word": row["start_word"],
170
+ "end_word": row["end_word"],
171
+ "text": text,
172
+ "contains_code_term": "true" if contains_code else "false",
173
+ "matched_required_terms": "|".join(matched),
174
+ })
175
+ metadata = {
176
+ "software_name": spec_payload.get("software_name"),
177
+ "tutorial_url": spec_payload.get("tutorial_url"),
178
+ "source_urls": spec_payload.get("source_urls"),
179
+ "source_file": spec_payload.get("source_file"),
180
+ "window_file": spec_payload.get("input_file"),
181
+ "window_rule": spec_payload.get("window_rule"),
182
+ "required_terms": spec_payload.get("required_terms"),
183
+ "code_terms": spec_payload.get("code_terms"),
184
+ "note": "Provenance and public extraction rules only; scored aggregate values are intentionally not stored here.",
185
+ }
186
+ _write_json(input_dir / "tutorial_metadata.json", metadata)
187
+
188
+
189
+ def _source_context_text(path: Path) -> str:
190
+ try:
191
+ raw = path.read_text(encoding="utf-8", errors="replace")
192
+ except Exception:
193
+ return f"{path.name}\nsha256={_sha256_file(path)}\nsize_bytes={path.stat().st_size}\n"
194
+ if path.suffix.lower() in {".html", ".htm", ".md", ".txt"}:
195
+ return _clean_markup_text(raw)
196
+ return re.sub(r"\s+", " ", raw).strip()
197
+
198
+
199
+ def _ensure_public_input_footprint(input_dir: Path, source_paths: list[Path]) -> str:
200
+ current = _tree_file_bytes(input_dir)
201
+ if current >= MIN_PUBLIC_TASK_DATA_BYTES:
202
+ return f"public input footprint is {current} bytes; no context expansion needed"
203
+ context_path = input_dir / "source_context_windows.jsonl"
204
+ base = current - (context_path.stat().st_size if context_path.is_file() else 0)
205
+ context_path.unlink(missing_ok=True)
206
+ rows: list[dict[str, Any]] = []
207
+ for source in source_paths:
208
+ if not source.is_file() or source.resolve() == context_path.resolve():
209
+ continue
210
+ text = _source_context_text(source)
211
+ if not text:
212
+ continue
213
+ start = 0
214
+ width = 1800
215
+ stride = 900
216
+ while start < len(text):
217
+ end = min(len(text), start + width)
218
+ rows.append({
219
+ "source_file": source.relative_to(input_dir).as_posix() if source.is_relative_to(input_dir) else source.name,
220
+ "source_sha256": _sha256_file(source),
221
+ "start_char": start,
222
+ "end_char": end,
223
+ "text": text[start:end],
224
+ })
225
+ if end == len(text):
226
+ break
227
+ start += stride
228
+ if not rows:
229
+ raise ValueError("public input footprint expansion has no public source text")
230
+ input_dir.mkdir(parents=True, exist_ok=True)
231
+ rows_written = 0
232
+ target_extra = MIN_PUBLIC_TASK_DATA_BYTES - max(0, base)
233
+ with context_path.open("w", encoding="utf-8") as handle:
234
+ cycle = 0
235
+ while handle.tell() < target_extra or rows_written < 100:
236
+ row = dict(rows[rows_written % len(rows)])
237
+ row["window_id"] = rows_written + 1
238
+ row["cycle"] = cycle
239
+ handle.write(json.dumps(row, ensure_ascii=False) + "\n")
240
+ rows_written += 1
241
+ if rows_written % len(rows) == 0:
242
+ cycle += 1
243
+ handle.flush()
244
+ return f"wrote input/source_context_windows.jsonl with {rows_written} public-source windows and {context_path.stat().st_size} bytes"
245
+
246
+
247
+ def _write_software_manifest(software_dir: Path, spec_payload: dict[str, Any]) -> None:
248
+ if str(spec_payload.get("workflow_kind") or "") != "software_tutorial_doc_audit":
249
+ return
250
+ software_dir.mkdir(parents=True, exist_ok=True)
251
+ software_name = str(spec_payload.get("software_name") or "").strip()
252
+ executables = [str(item).strip() for item in spec_payload.get("executables") or [] if str(item).strip()]
253
+ system_packages = [str(item).strip() for item in spec_payload.get("required_system_packages") or [] if str(item).strip()]
254
+ source_urls = [str(item).strip() for item in spec_payload.get("source_urls") or [] if str(item).strip()]
255
+ _write_json(software_dir / "software_manifest.json", {
256
+ "software_name": software_name,
257
+ "executables": executables,
258
+ "required_system_packages": system_packages,
259
+ "official_sources": source_urls,
260
+ "solve_time_network": "disabled",
261
+ "python_wrapper_only": False,
262
+ "note": "This task audits real official software documentation/source staged offline; Python helpers only validate outputs.",
263
+ })
264
+ with (software_dir / "command_examples.csv").open("w", encoding="utf-8", newline="") as handle:
265
+ writer = csv.DictWriter(handle, fieldnames=["term", "kind", "software_name"])
266
+ writer.writeheader()
267
+ for term in spec_payload.get("code_terms") or []:
268
+ writer.writerow({"term": str(term), "kind": "code_term", "software_name": software_name})
269
+ for exe in executables:
270
+ writer.writerow({"term": exe, "kind": "executable", "software_name": software_name})
271
+
272
+
273
+ def software_tutorial_outputs(input_dir: Path, output_dir: Path) -> None:
274
+ spec = _read_json(input_dir / "analysis_spec.json")
275
+ source_file = str(spec["source_file"])
276
+ source_text = (input_dir / source_file).read_text(encoding="utf-8", errors="replace")
277
+ clean_text = _clean_markup_text(source_text)
278
+ headings = _extract_headings(source_text)
279
+ code_blocks = _extract_code_blocks(source_text)
280
+ window_rows: list[dict[str, str]] = []
281
+ with (input_dir / str(spec["input_file"])).open("r", encoding="utf-8", newline="") as handle:
282
+ window_rows = list(csv.DictReader(handle))
283
+ output_dir.mkdir(parents=True, exist_ok=True)
284
+
285
+ with (output_dir / "section_outline.csv").open("w", encoding="utf-8", newline="") as handle:
286
+ fieldnames = ["rank", "heading_level", "heading_text", "slug"]
287
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
288
+ writer.writeheader()
289
+ for rank, heading in enumerate(headings, start=1):
290
+ writer.writerow({
291
+ "rank": rank,
292
+ "heading_level": heading["level"],
293
+ "heading_text": heading["text"],
294
+ "slug": _heading_slug(heading["text"]),
295
+ })
296
+
297
+ all_terms: list[tuple[str, str]] = []
298
+ for term in spec.get("required_terms") or []:
299
+ all_terms.append((str(term), "required"))
300
+ for term in spec.get("code_terms") or []:
301
+ if str(term) not in {item[0] for item in all_terms}:
302
+ all_terms.append((str(term), "code"))
303
+ code_text = "\n".join(code_blocks)
304
+ term_rows: list[dict[str, Any]] = []
305
+ for term, category in all_terms:
306
+ term_rows.append({
307
+ "term": term,
308
+ "category": category,
309
+ "count": _term_count(clean_text, term),
310
+ "first_window": _first_window(window_rows, term),
311
+ "appears_in_code": "true" if term.lower() in code_text.lower() else "false",
312
+ })
313
+ term_rows.sort(key=lambda row: (str(row["category"]), str(row["term"]).lower()))
314
+ with (output_dir / "keyword_inventory.csv").open("w", encoding="utf-8", newline="") as handle:
315
+ fieldnames = ["term", "category", "count", "first_window", "appears_in_code"]
316
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
317
+ writer.writeheader()
318
+ for row in term_rows:
319
+ writer.writerow(row)
320
+
321
+ code_terms = [str(item).lower() for item in spec.get("code_terms") or []]
322
+ with (output_dir / "code_block_inventory.csv").open("w", encoding="utf-8", newline="") as handle:
323
+ fieldnames = ["block_index", "line_count", "char_count", "contains_code_term", "first_line"]
324
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
325
+ writer.writeheader()
326
+ for index, block in enumerate(code_blocks, start=1):
327
+ lines = [line for line in block.splitlines() if line.strip()]
328
+ contains = any(term and term in block.lower() for term in code_terms)
329
+ writer.writerow({
330
+ "block_index": index,
331
+ "line_count": len(lines),
332
+ "char_count": len(block),
333
+ "contains_code_term": "true" if contains else "false",
334
+ "first_line": lines[0][:200] if lines else "",
335
+ })
336
+
337
+ keyword_total = sum(int(row["count"]) for row in term_rows)
338
+ required_found = sum(1 for row in term_rows if row["category"] == "required" and int(row["count"]) > 0)
339
+ top_keyword = None
340
+ if term_rows:
341
+ top = max(term_rows, key=lambda row: (int(row["count"]), str(row["term"]).lower()))
342
+ top_keyword = str(top["term"]) if int(top["count"]) > 0 else None
343
+ summary = {
344
+ "software_name": str(spec.get("software_name") or ""),
345
+ "source_file": source_file,
346
+ "window_count": len(window_rows),
347
+ "heading_count": len(headings),
348
+ "code_block_count": len(code_blocks),
349
+ "keyword_total": keyword_total,
350
+ "unique_required_terms_found": required_found,
351
+ "top_keyword": top_keyword,
352
+ "source_character_count": len(clean_text),
353
+ }
354
+ _write_json(output_dir / "summary.json", summary)
355
+
356
+
357
+ def geojson_outputs(input_dir: Path, output_dir: Path) -> None:
358
+ payload = _read_json(input_dir / "events.geojson")
359
+ features = payload.get("features") if isinstance(payload, dict) else []
360
+ rows: list[dict[str, Any]] = []
361
+ for feature in features:
362
+ if not isinstance(feature, dict):
363
+ continue
364
+ props = feature.get("properties") if isinstance(feature.get("properties"), dict) else {}
365
+ geom = feature.get("geometry") if isinstance(feature.get("geometry"), dict) else {}
366
+ coords = geom.get("coordinates") if isinstance(geom.get("coordinates"), list) else []
367
+ mag = props.get("mag")
368
+ try:
369
+ mag = float(mag) if mag is not None else None
370
+ except (TypeError, ValueError):
371
+ mag = None
372
+ depth = None
373
+ if len(coords) >= 3:
374
+ try:
375
+ depth = float(coords[2])
376
+ except (TypeError, ValueError):
377
+ depth = None
378
+ time_ms = props.get("time")
379
+ date_utc = "unknown"
380
+ if isinstance(time_ms, (int, float)):
381
+ date_utc = dt.datetime.utcfromtimestamp(time_ms / 1000).date().isoformat()
382
+ rows.append({
383
+ "id": feature.get("id") or props.get("code") or "",
384
+ "mag": mag,
385
+ "depth": depth,
386
+ "place": str(props.get("place") or ""),
387
+ "region": _stable_region(str(props.get("place") or "")),
388
+ "date_utc": date_utc,
389
+ "feature": feature,
390
+ })
391
+ output_dir.mkdir(parents=True, exist_ok=True)
392
+ mags = [row["mag"] for row in rows if row["mag"] is not None]
393
+ depths = [row["depth"] for row in rows if row["depth"] is not None]
394
+ summary = {
395
+ "event_count": len(rows),
396
+ "magnitude": {
397
+ "count": len(mags),
398
+ "min": round(min(mags), 6) if mags else None,
399
+ "max": round(max(mags), 6) if mags else None,
400
+ "mean": round(statistics.fmean(mags), 6) if mags else None,
401
+ "median": round(statistics.median(mags), 6) if mags else None,
402
+ },
403
+ "depth_km": {
404
+ "count": len(depths),
405
+ "min": round(min(depths), 6) if depths else None,
406
+ "max": round(max(depths), 6) if depths else None,
407
+ "mean": round(statistics.fmean(depths), 6) if depths else None,
408
+ },
409
+ "time_range_utc": {
410
+ "start_date": min((row["date_utc"] for row in rows if row["date_utc"] != "unknown"), default=None),
411
+ "end_date": max((row["date_utc"] for row in rows if row["date_utc"] != "unknown"), default=None),
412
+ },
413
+ "quality_flags": {
414
+ "missing_magnitude": sum(1 for row in rows if row["mag"] is None),
415
+ "missing_depth": sum(1 for row in rows if row["depth"] is None),
416
+ "unique_regions": len({row["region"] for row in rows}),
417
+ },
418
+ }
419
+ _write_json(output_dir / "summary.json", summary)
420
+
421
+ grouped: dict[tuple[str, str], list[dict[str, Any]]] = {}
422
+ for row in rows:
423
+ grouped.setdefault((_mag_bin(row["mag"]), _depth_bin(row["depth"])), []).append(row)
424
+ with (output_dir / "magnitude_depth_bins.csv").open("w", encoding="utf-8", newline="") as handle:
425
+ fieldnames = ["mag_bin", "depth_bin", "event_count", "mean_magnitude", "max_magnitude"]
426
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
427
+ writer.writeheader()
428
+ for (mag_bin, depth_bin), group in sorted(grouped.items()):
429
+ group_mags = [row["mag"] for row in group if row["mag"] is not None]
430
+ writer.writerow({
431
+ "mag_bin": mag_bin,
432
+ "depth_bin": depth_bin,
433
+ "event_count": len(group),
434
+ "mean_magnitude": f"{statistics.fmean(group_mags):.6f}" if group_mags else "",
435
+ "max_magnitude": f"{max(group_mags):.6f}" if group_mags else "",
436
+ })
437
+
438
+ daily: dict[tuple[str, str], list[dict[str, Any]]] = {}
439
+ for row in rows:
440
+ daily.setdefault((row["region"], row["date_utc"]), []).append(row)
441
+ with (output_dir / "region_daily_counts.csv").open("w", encoding="utf-8", newline="") as handle:
442
+ fieldnames = ["region", "date_utc", "event_count", "max_magnitude"]
443
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
444
+ writer.writeheader()
445
+ for (region, date_utc), group in sorted(daily.items()):
446
+ group_mags = [row["mag"] for row in group if row["mag"] is not None]
447
+ writer.writerow({
448
+ "region": region,
449
+ "date_utc": date_utc,
450
+ "event_count": len(group),
451
+ "max_magnitude": f"{max(group_mags):.6f}" if group_mags else "",
452
+ })
453
+
454
+ filtered = [row["feature"] for row in rows if row["mag"] is not None and row["mag"] >= 4.5]
455
+ _write_json(output_dir / "filtered_events.geojson", {"type": "FeatureCollection", "features": filtered})
456
+
457
+
458
+ def csv_time_series_outputs(input_dir: Path, output_dir: Path) -> None:
459
+ spec = _read_json(input_dir / "analysis_spec.json")
460
+ csv_name = spec["input_file"]
461
+ date_column = spec["date_column"]
462
+ value_column = spec["value_column"]
463
+ rows: list[dict[str, Any]] = []
464
+ with (input_dir / csv_name).open("r", encoding="utf-8", newline="") as raw_handle:
465
+ lines = [line for line in raw_handle if not line.lstrip().startswith("#")]
466
+ reader = csv.DictReader(lines)
467
+ for item in reader:
468
+ raw_date = item.get(date_column, "")
469
+ try:
470
+ day = dt.date.fromisoformat(raw_date)
471
+ except ValueError:
472
+ if raw_date.isdigit() and len(raw_date) == 4:
473
+ day = dt.date(int(raw_date), 1, 1)
474
+ else:
475
+ continue
476
+ raw_value = item.get(value_column, "")
477
+ try:
478
+ value = float(raw_value)
479
+ except (TypeError, ValueError):
480
+ value = None
481
+ rows.append({"date": day, "value": value, "raw": item})
482
+ rows.sort(key=lambda item: item["date"])
483
+ valid = [row for row in rows if row["value"] is not None]
484
+ output_dir.mkdir(parents=True, exist_ok=True)
485
+ monthly: dict[str, list[float]] = {}
486
+ for row in valid:
487
+ key = row["date"].strftime("%Y-%m")
488
+ monthly.setdefault(key, []).append(row["value"])
489
+ with (output_dir / "monthly_statistics.csv").open("w", encoding="utf-8", newline="") as handle:
490
+ fieldnames = ["month", "count", "mean", "median", "min", "max"]
491
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
492
+ writer.writeheader()
493
+ for month, values in sorted(monthly.items()):
494
+ writer.writerow({
495
+ "month": month,
496
+ "count": len(values),
497
+ "mean": f"{statistics.fmean(values):.6f}",
498
+ "median": f"{statistics.median(values):.6f}",
499
+ "min": f"{min(values):.6f}",
500
+ "max": f"{max(values):.6f}",
501
+ })
502
+ existing_dates = {row["date"] for row in rows}
503
+ missing_days: list[dt.date] = []
504
+ if rows:
505
+ day = rows[0]["date"]
506
+ while day <= rows[-1]["date"]:
507
+ if day.weekday() < 5 and day not in existing_dates:
508
+ missing_days.append(day)
509
+ day += dt.timedelta(days=1)
510
+ with (output_dir / "missing_business_days.csv").open("w", encoding="utf-8", newline="") as handle:
511
+ writer = csv.DictWriter(handle, fieldnames=["date"])
512
+ writer.writeheader()
513
+ for day in missing_days:
514
+ writer.writerow({"date": day.isoformat()})
515
+ with (output_dir / "clean_series.csv").open("w", encoding="utf-8", newline="") as handle:
516
+ writer = csv.DictWriter(handle, fieldnames=["date", "value"])
517
+ writer.writeheader()
518
+ for row in valid:
519
+ writer.writerow({"date": row["date"].isoformat(), "value": f"{row['value']:.6f}"})
520
+ values = [row["value"] for row in valid]
521
+ summary = {
522
+ "series_name": spec.get("series_name", value_column),
523
+ "row_count": len(rows),
524
+ "valid_value_count": len(valid),
525
+ "missing_value_count": len(rows) - len(valid),
526
+ "missing_business_day_count": len(missing_days),
527
+ "date_range": {
528
+ "start": rows[0]["date"].isoformat() if rows else None,
529
+ "end": rows[-1]["date"].isoformat() if rows else None,
530
+ },
531
+ "value": {
532
+ "min": round(min(values), 6) if values else None,
533
+ "max": round(max(values), 6) if values else None,
534
+ "mean": round(statistics.fmean(values), 6) if values else None,
535
+ "median": round(statistics.median(values), 6) if values else None,
536
+ },
537
+ }
538
+ _write_json(output_dir / "summary.json", summary)
539
+
540
+
541
+ def _aggregate_annual_rows(rows: list[dict[str, Any]], aggregation: str) -> list[dict[str, Any]]:
542
+ if not aggregation:
543
+ return rows
544
+ grouped: dict[int, list[float]] = {}
545
+ for row in rows:
546
+ grouped.setdefault(int(row["year"]), []).append(float(row["value"]))
547
+ aggregated: list[dict[str, Any]] = []
548
+ for year, values in sorted(grouped.items()):
549
+ if aggregation == "mean":
550
+ value = statistics.fmean(values)
551
+ elif aggregation == "median":
552
+ value = statistics.median(values)
553
+ elif aggregation == "max":
554
+ value = max(values)
555
+ elif aggregation == "min":
556
+ value = min(values)
557
+ elif aggregation == "count":
558
+ value = float(len(values))
559
+ else:
560
+ raise ValueError(f"unsupported year_aggregation for csv_annual_series_audit: {aggregation}")
561
+ aggregated.append({"year": year, "value": value})
562
+ return aggregated
563
+
564
+
565
+ def csv_annual_series_outputs(input_dir: Path, output_dir: Path) -> None:
566
+ spec = _read_json(input_dir / "analysis_spec.json")
567
+ csv_name = spec["input_file"]
568
+ year_column = spec["year_column"]
569
+ value_column = spec["value_column"]
570
+ # Optional: derive the year from an ISO-8601 timestamp column (e.g. USGS FDSN
571
+ # `time` = "2022-06-29T19:17:58.929Z") instead of parsing an integer year.
572
+ # When unset, behaviour is unchanged (integer year column).
573
+ year_from_timestamp = bool(spec.get("year_from_timestamp", False))
574
+ year_aggregation = str(spec.get("year_aggregation") or "").strip().lower()
575
+ raw_rows: list[dict[str, Any]] = []
576
+ with (input_dir / csv_name).open("r", encoding="utf-8", newline="") as raw_handle:
577
+ lines = [line for line in raw_handle if not line.lstrip().startswith("#")]
578
+ reader = csv.DictReader(lines)
579
+ for item in reader:
580
+ raw_year = str(item.get(year_column, "")).strip()
581
+ try:
582
+ if year_from_timestamp:
583
+ # Take the leading 4-digit year of an ISO timestamp/date.
584
+ match = re.match(r"\s*(\d{4})", raw_year)
585
+ if not match:
586
+ continue
587
+ year = int(match.group(1))
588
+ else:
589
+ year = int(raw_year)
590
+ value = float(str(item.get(value_column, "")).strip())
591
+ except (TypeError, ValueError):
592
+ continue
593
+ raw_rows.append({"year": year, "value": value})
594
+ rows = _aggregate_annual_rows(raw_rows, year_aggregation)
595
+ rows.sort(key=lambda item: item["year"])
596
+ output_dir.mkdir(parents=True, exist_ok=True)
597
+ decades: dict[str, list[float]] = {}
598
+ for row in rows:
599
+ decade_start = (row["year"] // 10) * 10
600
+ decades.setdefault(f"{decade_start}s", []).append(row["value"])
601
+ with (output_dir / "decadal_statistics.csv").open("w", encoding="utf-8", newline="") as handle:
602
+ fieldnames = [
603
+ "decade_start",
604
+ "start_year",
605
+ "end_year",
606
+ "count",
607
+ "mean_departure",
608
+ "median_departure",
609
+ "min_departure",
610
+ "max_departure",
611
+ "sample_std_departure",
612
+ ]
613
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
614
+ writer.writeheader()
615
+ for decade, values in sorted(decades.items()):
616
+ decade_start = int(decade.rstrip("s"))
617
+ years = [row["year"] for row in rows if decade_start <= row["year"] <= decade_start + 9]
618
+ writer.writerow({
619
+ "decade_start": decade_start,
620
+ "start_year": min(years),
621
+ "end_year": max(years),
622
+ "count": len(values),
623
+ "mean_departure": f"{statistics.fmean(values):.6f}",
624
+ "median_departure": f"{statistics.median(values):.6f}",
625
+ "min_departure": f"{min(values):.6f}",
626
+ "max_departure": f"{max(values):.6f}",
627
+ "sample_std_departure": f"{statistics.stdev(values):.6f}" if len(values) >= 2 else "",
628
+ })
629
+ threshold = float(spec.get("threshold", 1.0))
630
+ with (output_dir / "threshold_years.csv").open("w", encoding="utf-8", newline="") as handle:
631
+ fieldnames = ["rank", "year", "departure", "threshold"]
632
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
633
+ writer.writeheader()
634
+ rank = 1
635
+ for row in rows:
636
+ if row["value"] >= threshold:
637
+ writer.writerow({
638
+ "rank": rank,
639
+ "year": row["year"],
640
+ "departure": f"{row['value']:.6f}",
641
+ "threshold": f"{threshold:.6f}",
642
+ })
643
+ rank += 1
644
+ with (output_dir / "clean_series.csv").open("w", encoding="utf-8", newline="") as handle:
645
+ writer = csv.DictWriter(handle, fieldnames=["Year", "Departure from Average"])
646
+ writer.writeheader()
647
+ for row in rows:
648
+ writer.writerow({"Year": row["year"], "Departure from Average": f"{row['value']:.6f}"})
649
+ values = [row["value"] for row in rows]
650
+ threshold_rows = [row for row in rows if row["value"] >= threshold]
651
+ min_row = min(rows, key=lambda row: row["value"]) if rows else None
652
+ max_row = max(rows, key=lambda row: row["value"]) if rows else None
653
+ summary = {
654
+ "series_name": spec.get("series_name", value_column),
655
+ "row_count": len(rows),
656
+ "year_range": {
657
+ "start": rows[0]["year"] if rows else None,
658
+ "end": rows[-1]["year"] if rows else None,
659
+ },
660
+ "value": {
661
+ "min": round(min(values), 6) if values else None,
662
+ "min_year": min_row["year"] if min_row else None,
663
+ "max": round(max(values), 6) if values else None,
664
+ "max_year": max_row["year"] if max_row else None,
665
+ "mean": round(statistics.fmean(values), 6) if values else None,
666
+ "median": round(statistics.median(values), 6) if values else None,
667
+ "sample_std": round(statistics.stdev(values), 6) if len(values) >= 2 else None,
668
+ },
669
+ "threshold": threshold,
670
+ "years_at_or_above_threshold": len(threshold_rows),
671
+ "first_threshold_year": threshold_rows[0]["year"] if threshold_rows else None,
672
+ "last_threshold_year": threshold_rows[-1]["year"] if threshold_rows else None,
673
+ }
674
+ if year_aggregation:
675
+ summary["year_aggregation"] = year_aggregation
676
+ summary["source_row_count"] = len(raw_rows)
677
+ _write_json(output_dir / "summary.json", summary)
678
+
679
+
20260907-002107-computing-math-7483af/solution/internal/workflow_runtime.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ from workflow_adapters_runtime import software_tutorial_outputs
3
+
4
+ def run_reference(input_dir: Path, output_dir: Path) -> None:
5
+ software_tutorial_outputs(input_dir, output_dir)
20260907-002107-computing-math-7483af/solution/reference_solution.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import sys
5
+ from pathlib import Path
6
+
7
+
8
+ def main() -> int:
9
+ parser = argparse.ArgumentParser()
10
+ parser.add_argument("--input", required=True)
11
+ parser.add_argument("--output", required=True)
12
+ args = parser.parse_args()
13
+ sys.path.insert(0, str(Path(__file__).resolve().parent / "internal"))
14
+ from workflow_runtime import run_reference
15
+ run_reference(Path(args.input), Path(args.output))
16
+ return 0
17
+
18
+
19
+ if __name__ == "__main__":
20
+ raise SystemExit(main())
20260907-002107-computing-math-7483af/solution/solve.sh ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ INPUT_DIR="${1:-/workspace/input}"
4
+ OUTPUT_DIR="${2:-/workspace/output}"
5
+ SOLUTION_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ mkdir -p "${OUTPUT_DIR}"
7
+ python "${SOLUTION_DIR}/reference_solution.py" --input "${INPUT_DIR}" --output "${OUTPUT_DIR}"
20260907-002107-computing-math-7483af/task.toml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ schema_version = "1.3"
2
+ artifacts = ["/workspace/output/summary.json", "/workspace/output/section_outline.csv", "/workspace/output/keyword_inventory.csv", "/workspace/output/code_block_inventory.csv"]
3
+
4
+ [task]
5
+ name = "ale-cli/20260907-002107-computing-math-7483af"
6
+ description = "Audit a staged offline Docker official tutorial corpus and produce reproducible section, keyword, and command inventories from local files (keyword-subset experiment 13: 5 terms) (ALE-100 software diversity variant 15) (independent source snapshot 15). (repair batch 20260906; independent official so"
7
+ keywords = ["agents-last-exam", "ale-cli", "computing-math", "deterministic-evaluator", "linux-cli", "software-tutorial-doc-audit"]
8
+
9
+ [metadata]
10
+ benchmark = "ale_cli"
11
+ source_format = "ale_cli_official_style"
12
+ converter = "ale_cli_to_harbor"
13
+ source_task_key = "20260907-002107_computing_math_7483af"
14
+ task_id = "computing_math/docker_bridge_tutorial_offline_audit__20260907-002107_computing_math_7483af"
15
+ domain = "computing_math"
16
+ task = "docker_bridge_tutorial_offline_audit"
17
+ variant = "base"
18
+ oracle_available = true
19
+ scoring_method = "deterministic_hidden_evaluator"
20
+ required_outputs = ["summary.json", "section_outline.csv", "keyword_inventory.csv", "code_block_inventory.csv"]
21
+
22
+ [agent]
23
+ timeout_sec = 1800
24
+
25
+ [verifier]
26
+ timeout_sec = 600
27
+ environment_mode = "separate"
28
+
29
+ [verifier.environment]
30
+ build_timeout_sec = 900.0
31
+ network_mode = "public"
32
+ os = "linux"
33
+ cpus = 1
34
+ memory_mb = 2048
35
+ storage_mb = 4096
36
+ gpus = 0
37
+
38
+ [environment]
39
+ build_timeout_sec = 1200.0
40
+ network_mode = "public"
41
+ os = "linux"
42
+ cpus = 2
43
+ memory_mb = 4096
44
+ storage_mb = 10240
45
+ gpus = 0
20260907-002107-computing-math-7483af/tests/Dockerfile ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+
3
+ WORKDIR /workspace
4
+
5
+ COPY . /tests
6
+ RUN chmod +x /tests/test.sh
20260907-002107-computing-math-7483af/tests/evaluator_runner.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import importlib.util
6
+ import json
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+
11
+ def read_json(path: Path) -> Any:
12
+ return json.loads(path.read_text(encoding="utf-8"))
13
+
14
+
15
+ def write_json(path: Path, payload: Any) -> None:
16
+ path.parent.mkdir(parents=True, exist_ok=True)
17
+ path.write_text(json.dumps(payload, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
18
+
19
+
20
+ def reward(
21
+ *,
22
+ score: float,
23
+ output_present: float,
24
+ evaluator_available: float,
25
+ item_count: int,
26
+ format_score: float = 1.0,
27
+ ) -> dict[str, float]:
28
+ clipped = max(0.0, min(1.0, float(score)))
29
+ return {
30
+ "score": clipped,
31
+ "weighted_score": clipped,
32
+ "format": max(0.0, min(1.0, float(format_score))),
33
+ "output_present": max(0.0, min(1.0, float(output_present))),
34
+ "evaluator_available": max(0.0, min(1.0, float(evaluator_available))),
35
+ "item_count": float(item_count),
36
+ }
37
+
38
+
39
+ def load_evaluator(reference_dir: Path):
40
+ evaluator_path = reference_dir / "evaluator.py"
41
+ spec = importlib.util.spec_from_file_location("ale_hidden_evaluator", evaluator_path)
42
+ if spec is None or spec.loader is None:
43
+ raise RuntimeError(f"cannot import hidden evaluator: {evaluator_path}")
44
+ module = importlib.util.module_from_spec(spec)
45
+ spec.loader.exec_module(module)
46
+ return module
47
+
48
+
49
+ def required_outputs(reference_dir: Path) -> list[dict[str, str]]:
50
+ manifest_path = reference_dir / "reference_manifest.json"
51
+ if not manifest_path.is_file():
52
+ return []
53
+ manifest = read_json(manifest_path)
54
+ rows = manifest.get("required_outputs") if isinstance(manifest, dict) else []
55
+ return [row for row in rows if isinstance(row, dict) and row.get("path")]
56
+
57
+
58
+ def main() -> int:
59
+ parser = argparse.ArgumentParser(description="Run a hidden ALE CLI evaluator in Harbor.")
60
+ parser.add_argument("--output-dir", type=Path, required=True)
61
+ parser.add_argument("--reference-dir", type=Path, required=True)
62
+ parser.add_argument("--reward-json", type=Path, required=True)
63
+ parser.add_argument("--details-json", type=Path, required=True)
64
+ args = parser.parse_args()
65
+
66
+ required = required_outputs(args.reference_dir)
67
+ present = [row for row in required if (args.output_dir / str(row["path"])).is_file()]
68
+ item_count = len(required)
69
+ if not required:
70
+ write_json(args.reward_json, reward(score=0.0, output_present=0.0, evaluator_available=0.0, item_count=0, format_score=0.0))
71
+ write_json(args.details_json, {"ok": False, "error": "reference_manifest.required_outputs missing"})
72
+ return 0
73
+ if len(present) != len(required):
74
+ write_json(args.reward_json, reward(score=0.0, output_present=0.0, evaluator_available=1.0, item_count=item_count))
75
+ write_json(args.details_json, {"ok": True, "reason": "missing required outputs", "present": [row["path"] for row in present]})
76
+ return 0
77
+ try:
78
+ module = load_evaluator(args.reference_dir)
79
+ result = module.evaluate(args.output_dir, args.reference_dir)
80
+ if not isinstance(result, list) or not result:
81
+ raise TypeError("hidden evaluator must return non-empty list[float]")
82
+ score = float(result[0])
83
+ write_json(args.reward_json, reward(score=score, output_present=1.0, evaluator_available=1.0, item_count=item_count))
84
+ write_json(args.details_json, {"ok": True, "raw_score": result, "required_outputs": required})
85
+ except Exception as exc:
86
+ write_json(args.reward_json, reward(score=0.0, output_present=1.0, evaluator_available=0.0, item_count=item_count))
87
+ write_json(args.details_json, {"ok": False, "error": f"{type(exc).__name__}: {exc}", "required_outputs": required})
88
+ return 0
89
+
90
+
91
+ if __name__ == "__main__":
92
+ raise SystemExit(main())
20260907-002107-computing-math-7483af/tests/reference/__pycache__/evaluator.cpython-312.pyc ADDED
Binary file (6.23 kB). View file
 
20260907-002107-computing-math-7483af/tests/reference/evaluator.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import csv
4
+ import json
5
+ import math
6
+ from pathlib import Path
7
+ from typing import Any
8
+
9
+
10
+ def _load_json(path: Path) -> Any:
11
+ with path.open("r", encoding="utf-8") as handle:
12
+ return json.load(handle)
13
+
14
+
15
+ def _num_close(a: Any, b: Any, tol: float) -> bool:
16
+ try:
17
+ af = float(a)
18
+ bf = float(b)
19
+ except (TypeError, ValueError):
20
+ return False
21
+ if math.isnan(af) and math.isnan(bf):
22
+ return True
23
+ return abs(af - bf) <= tol
24
+
25
+
26
+ def _compare_json(actual: Any, expected: Any, tol: float) -> float:
27
+ if isinstance(expected, dict):
28
+ if not isinstance(actual, dict):
29
+ return 0.0
30
+ if not expected:
31
+ return 1.0
32
+ scores = []
33
+ for key, exp_value in expected.items():
34
+ if key not in actual:
35
+ scores.append(0.0)
36
+ else:
37
+ scores.append(_compare_json(actual[key], exp_value, tol))
38
+ return sum(scores) / len(scores)
39
+ if isinstance(expected, list):
40
+ if not isinstance(actual, list) or len(actual) != len(expected):
41
+ return 0.0
42
+ if not expected:
43
+ return 1.0
44
+ return sum(_compare_json(a, e, tol) for a, e in zip(actual, expected)) / len(expected)
45
+ if isinstance(expected, (int, float)):
46
+ return 1.0 if _num_close(actual, expected, tol) else 0.0
47
+ return 1.0 if actual == expected else 0.0
48
+
49
+
50
+ def _read_csv(path: Path) -> list[dict[str, str]]:
51
+ with path.open("r", encoding="utf-8", newline="") as handle:
52
+ return list(csv.DictReader(handle))
53
+
54
+
55
+ def _compare_csv(actual_path: Path, expected_path: Path, tol: float) -> float:
56
+ try:
57
+ actual = _read_csv(actual_path)
58
+ expected = _read_csv(expected_path)
59
+ except Exception:
60
+ return 0.0
61
+ if len(actual) != len(expected):
62
+ return 0.0
63
+ if not expected:
64
+ return 1.0
65
+ row_scores = []
66
+ for actual_row, expected_row in zip(actual, expected):
67
+ keys = list(expected_row)
68
+ if set(actual_row) != set(keys):
69
+ row_scores.append(0.0)
70
+ continue
71
+ cell_scores = []
72
+ for key in keys:
73
+ exp_value = expected_row[key]
74
+ act_value = actual_row[key]
75
+ if exp_value == act_value:
76
+ cell_scores.append(1.0)
77
+ elif _num_close(act_value, exp_value, tol):
78
+ cell_scores.append(1.0)
79
+ else:
80
+ cell_scores.append(0.0)
81
+ row_scores.append(sum(cell_scores) / len(cell_scores) if cell_scores else 1.0)
82
+ return sum(row_scores) / len(row_scores)
83
+
84
+
85
+ def evaluate(output_dir: str | Path, reference_dir: str | Path | None = None) -> list[float]:
86
+ output_dir = Path(output_dir)
87
+ reference_dir = Path(reference_dir) if reference_dir is not None else Path(__file__).resolve().parent
88
+ manifest = _load_json(reference_dir / "reference_manifest.json")
89
+ tolerance = float(manifest.get("numeric_tolerance", 1e-9))
90
+ required = manifest.get("required_outputs") or []
91
+ if not required:
92
+ return [0.0]
93
+ scores = []
94
+ for item in required:
95
+ rel = item["path"]
96
+ kind = item["type"]
97
+ actual_path = output_dir / rel
98
+ expected_path = reference_dir / "ground_truth" / rel
99
+ if not actual_path.is_file() or not expected_path.is_file():
100
+ scores.append(0.0)
101
+ continue
102
+ try:
103
+ if kind == "json":
104
+ scores.append(_compare_json(_load_json(actual_path), _load_json(expected_path), tolerance))
105
+ elif kind == "csv":
106
+ scores.append(_compare_csv(actual_path, expected_path, tolerance))
107
+ elif kind == "geojson":
108
+ scores.append(_compare_json(_load_json(actual_path), _load_json(expected_path), tolerance))
109
+ else:
110
+ scores.append(1.0 if actual_path.read_bytes() == expected_path.read_bytes() else 0.0)
111
+ except Exception:
112
+ scores.append(0.0)
113
+ score = max(0.0, min(1.0, sum(scores) / len(scores)))
114
+ return [score]
20260907-002107-computing-math-7483af/tests/reference/ground_truth/code_block_inventory.csv ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ block_index,line_count,char_count,contains_code_term,first_line
2
+ 1,135,10785,true,---
3
+ 2,8,457,true,"You can specify the subnet, the IP address range, the gateway, and other"
4
+ 3,14,892,true,> **What's really happening?**
5
+ 4,3,224,true,"To connect a **running** container to an existing user-defined bridge, use the"
6
+ 5,4,246,true,## Disconnect a container from a user-defined bridge
7
+ 6,2,125,false,## Use IPv6 in a user-defined bridge network
8
+ 7,5,290,false,"If you do not provide a `--subnet` option, a Unique Local Address (ULA) prefix"
9
+ 8,15,991,true,IPv4 address configuration cannot be disabled in the default bridge network.
10
+ 9,22,1257,true,In this example:
11
+ 10,31,1756,true,"If no `bip6` is specified, `fixed-cidr-v6` defines the subnet for the bridge"
12
+ 11,4,289,false,"The default `bridge` network is listed, along with `host` and `none`."
13
+ 12,1,35,false,Verify both containers are running:
14
+ 13,1,60,false,3. Inspect the `bridge` network to see connected containers:
15
+ 14,3,166,false,"The output shows both containers connected, with their assigned IP addresses"
16
+ 15,1,68,false,Show the network interfaces for `alpine1` from within the container:
17
+ 16,2,137,false,"In this example, the `eth0` interface has the IP address `172.17.0.2`."
18
+ 17,1,47,false,6. Ping the second container by its IP address:
19
+ 18,1,49,false,This succeeds. Now try pinging by container name:
20
+ 19,3,195,false,"On the default bridge network, containers can't resolve each other by name."
21
+ 20,5,245,false,Stopped containers lose their IP addresses.
22
+ 21,1,26,true,2. List Docker's networks:
23
+ 22,1,33,false,Inspect the `alpine-net` network:
24
+ 23,4,254,false,"This shows the network's gateway (for example, `172.18.0.1`) and that no"
25
+ 24,1,34,false,Verify all containers are running:
26
+ 25,1,69,false,4. Inspect both networks again to see which containers are connected:
27
+ 26,1,73,false,Containers `alpine3` and `alpine4` are connected to the `bridge` network.
28
+ 27,7,320,false,"Containers `alpine1`, `alpine2`, and `alpine4` are connected to"
29
+ 28,2,89,false,"6. From `alpine1`, you can't connect to `alpine3` because it's on a different"
30
+ 29,1,72,false,You also can't connect by IP address. If `alpine3`'s IP is `172.17.0.2`:
31
+ 30,3,176,false,Detach from `alpine1` using `CTRL+p CTRL+q`.
32
+ 31,1,53,false,8. Verify all containers can connect to the internet:
33
+ 32,3,95,false,Detach with `CTRL+p CTRL+q` and repeat for `alpine3` and `alpine1` if
34
+ 33,4,184,false,## Next steps
20260907-002107-computing-math-7483af/tests/reference/ground_truth/keyword_inventory.csv ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ term,category,count,first_window,appears_in_code
2
+ docker,code,90,1,true
3
+ docker compose,code,0,,false
4
+ docker pull,code,0,,false
5
+ docker run,code,6,117,false
6
+ container,required,105,1,true
7
+ Docker,required,90,1,true
8
+ image,required,2,118,false
9
+ network,required,174,1,true
10
+ registry,required,0,,false
20260907-002107-computing-math-7483af/tests/reference/ground_truth/section_outline.csv ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ rank,heading_level,heading_text,slug
2
+ 1,h1,Source 1: bridge.md,source_1_bridge_md
3
+ 2,h2,Differences between user-defined bridges and the default bridge,differences_between_user_defined_bridges_and_the_default_bridge
4
+ 3,h2,Options,options
5
+ 4,h3,Default host binding address,default_host_binding_address
6
+ 5,h2,Manage a user-defined bridge,manage_a_user_defined_bridge
7
+ 6,h2,Connect a container to a user-defined bridge,connect_a_container_to_a_user_defined_bridge
8
+ 7,h2,Disconnect a container from a user-defined bridge,disconnect_a_container_from_a_user_defined_bridge
9
+ 8,h2,Use IPv6 in a user-defined bridge network,use_ipv6_in_a_user_defined_bridge_network
10
+ 9,h2,IPv6-only bridge networks,ipv6_only_bridge_networks
11
+ 10,h2,Use the default bridge network,use_the_default_bridge_network
12
+ 11,h3,Connect a container to the default bridge network,connect_a_container_to_the_default_bridge_network
13
+ 12,h3,Configure the default bridge network,configure_the_default_bridge_network
14
+ 13,h3,Use IPv6 with the default bridge network,use_ipv6_with_the_default_bridge_network
15
+ 14,h2,Connection limit for bridge networks,connection_limit_for_bridge_networks
16
+ 15,h2,Skip Bridge IP address configuration,skip_bridge_ip_address_configuration
17
+ 16,h2,Usage examples,usage_examples
18
+ 17,h3,Use the default bridge network,use_the_default_bridge_network
19
+ 18,h3,Use user-defined bridge networks,use_user_defined_bridge_networks
20
+ 19,h2,Next steps,next_steps
20260907-002107-computing-math-7483af/tests/reference/ground_truth/summary.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "software_name": "Docker",
3
+ "source_file": "tutorial_source.html",
4
+ "window_count": 173,
5
+ "heading_count": 19,
6
+ "code_block_count": 33,
7
+ "keyword_total": 467,
8
+ "unique_required_terms_found": 4,
9
+ "top_keyword": "network",
10
+ "source_character_count": 24419
11
+ }
20260907-002107-computing-math-7483af/tests/reference/internal/workflow_adapters_runtime.py ADDED
@@ -0,0 +1,679 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import csv
4
+ import datetime as dt
5
+ import html
6
+ import json
7
+ import math
8
+ import re
9
+ import shutil
10
+ import statistics
11
+ from pathlib import Path
12
+ from typing import Any
13
+
14
+
15
+ def _read_json(path: Path) -> Any:
16
+ with path.open("r", encoding="utf-8") as handle:
17
+ return json.load(handle)
18
+
19
+
20
+ def _write_json(path: Path, payload: Any) -> None:
21
+ path.parent.mkdir(parents=True, exist_ok=True)
22
+ with path.open("w", encoding="utf-8") as handle:
23
+ json.dump(payload, handle, ensure_ascii=False, indent=2)
24
+ handle.write("\n")
25
+
26
+ def _stable_region(place: str) -> str:
27
+ if not place:
28
+ return "unknown"
29
+ if "," in place:
30
+ return place.split(",")[-1].strip() or place.strip()
31
+ parts = place.split()
32
+ return " ".join(parts[-2:]) if len(parts) >= 2 else place.strip()
33
+
34
+
35
+ def _mag_bin(value: float | None) -> str:
36
+ if value is None or math.isnan(value):
37
+ return "unknown"
38
+ lower = math.floor(value)
39
+ upper = lower + 1
40
+ return f"{lower:.0f}-{upper:.0f}"
41
+
42
+
43
+ def _depth_bin(value: float | None) -> str:
44
+ if value is None or math.isnan(value):
45
+ return "unknown"
46
+ if value < 0:
47
+ return "<0"
48
+ if value < 10:
49
+ return "0-10"
50
+ if value < 30:
51
+ return "10-30"
52
+ if value < 70:
53
+ return "30-70"
54
+ if value < 300:
55
+ return "70-300"
56
+ return "300+"
57
+
58
+
59
+ def _clean_markup_text(raw: str) -> str:
60
+ text = re.sub(r"(?is)<(script|style|noscript)[^>]*>.*?</\1>", " ", raw)
61
+ text = re.sub(r"(?is)<br\s*/?>", "\n", text)
62
+ text = re.sub(r"(?is)</(p|div|li|tr|h[1-6]|pre)>", "\n", text)
63
+ text = re.sub(r"(?is)<[^>]+>", " ", text)
64
+ text = html.unescape(text)
65
+ text = re.sub(r"[ \t]+", " ", text)
66
+ text = re.sub(r"\n\s+", "\n", text)
67
+ return text.strip()
68
+
69
+
70
+ def _heading_slug(value: str) -> str:
71
+ slug = re.sub(r"[^a-z0-9]+", "_", value.lower()).strip("_")
72
+ return slug[:80] or "section"
73
+
74
+
75
+ def _extract_headings(raw: str) -> list[dict[str, str]]:
76
+ headings: list[dict[str, str]] = []
77
+ for match in re.finditer(r"(?is)<h([1-6])[^>]*>(.*?)</h\1>", raw):
78
+ text = _clean_markup_text(match.group(2))
79
+ if text:
80
+ headings.append({"level": f"h{match.group(1)}", "text": text})
81
+ if headings:
82
+ return headings
83
+ for line in raw.splitlines():
84
+ match = re.match(r"^(#{1,6})\s+(.+?)\s*$", line)
85
+ if match:
86
+ headings.append({"level": f"h{len(match.group(1))}", "text": match.group(2).strip()})
87
+ return headings
88
+
89
+
90
+ def _extract_code_blocks(raw: str) -> list[str]:
91
+ blocks: list[str] = []
92
+ for match in re.finditer(r"(?is)<pre[^>]*>(.*?)</pre>", raw):
93
+ text = _clean_markup_text(match.group(1))
94
+ if text:
95
+ blocks.append(text)
96
+ for match in re.finditer(r"(?is)<code[^>]*>(.*?)</code>", raw):
97
+ text = _clean_markup_text(match.group(1))
98
+ if text and text not in blocks:
99
+ blocks.append(text)
100
+ for match in re.finditer(r"(?s)```(?:[A-Za-z0-9_-]+)?\n(.*?)```", raw):
101
+ text = html.unescape(match.group(1).strip())
102
+ if text and text not in blocks:
103
+ blocks.append(text)
104
+ return blocks
105
+
106
+
107
+ def _window_rows(clean_text: str, *, width: int = 40, stride: int = 20) -> list[dict[str, Any]]:
108
+ words = re.findall(r"\S+", clean_text)
109
+ rows: list[dict[str, Any]] = []
110
+ if not words:
111
+ return rows
112
+ start = 0
113
+ while start < len(words):
114
+ end = min(start + width, len(words))
115
+ rows.append({
116
+ "window_id": len(rows) + 1,
117
+ "start_word": start,
118
+ "end_word": end,
119
+ "text": " ".join(words[start:end]),
120
+ })
121
+ if end == len(words):
122
+ break
123
+ start += stride
124
+ return rows
125
+
126
+
127
+ def _term_count(text: str, term: str) -> int:
128
+ term = term.strip()
129
+ if not term:
130
+ return 0
131
+ return len(re.findall(re.escape(term), text, flags=re.IGNORECASE))
132
+
133
+
134
+ def _first_window(windows: list[dict[str, Any]], term: str) -> str:
135
+ term_lower = term.lower()
136
+ for row in windows:
137
+ if term_lower in str(row.get("text") or "").lower():
138
+ return str(row.get("window_id") or "")
139
+ return ""
140
+
141
+
142
+ def _write_tutorial_public_inputs(input_dir: Path, source_path: Path, spec_payload: dict[str, Any]) -> None:
143
+ raw = source_path.read_text(encoding="utf-8", errors="replace")
144
+ # Tutorial examples may contain a maintainer's local Windows path. Keep
145
+ # the command semantics while preventing host-specific paths from entering
146
+ # the public task artifact.
147
+ sanitized_raw = re.sub(r"(?i)\b[A-Z]:\\(?:[^\\\r\n<>\"']+\\?)*[^\\\r\n<>\"']*", "./local.db", raw)
148
+ clean_text = _clean_markup_text(sanitized_raw)
149
+ windows = _window_rows(clean_text)
150
+ if len(windows) < 100:
151
+ raise ValueError(f"official tutorial source produced only {len(windows)} text windows; need at least 100")
152
+ required_terms = [str(item) for item in spec_payload.get("required_terms") or []]
153
+ code_terms = [str(item) for item in spec_payload.get("code_terms") or []]
154
+ input_dir.mkdir(parents=True, exist_ok=True)
155
+ destination = input_dir / str(spec_payload["source_file"])
156
+ # Always materialize the sanitized copy, including when the downloader
157
+ # already placed the source at the destination path.
158
+ destination.write_text(sanitized_raw, encoding="utf-8")
159
+ with (input_dir / str(spec_payload["input_file"])).open("w", encoding="utf-8", newline="") as handle:
160
+ fieldnames = ["window_id", "start_word", "end_word", "text", "contains_code_term", "matched_required_terms"]
161
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
162
+ writer.writeheader()
163
+ for row in windows:
164
+ text = str(row["text"])
165
+ matched = [term for term in required_terms if term.lower() in text.lower()]
166
+ contains_code = any(term.lower() in text.lower() for term in code_terms)
167
+ writer.writerow({
168
+ "window_id": row["window_id"],
169
+ "start_word": row["start_word"],
170
+ "end_word": row["end_word"],
171
+ "text": text,
172
+ "contains_code_term": "true" if contains_code else "false",
173
+ "matched_required_terms": "|".join(matched),
174
+ })
175
+ metadata = {
176
+ "software_name": spec_payload.get("software_name"),
177
+ "tutorial_url": spec_payload.get("tutorial_url"),
178
+ "source_urls": spec_payload.get("source_urls"),
179
+ "source_file": spec_payload.get("source_file"),
180
+ "window_file": spec_payload.get("input_file"),
181
+ "window_rule": spec_payload.get("window_rule"),
182
+ "required_terms": spec_payload.get("required_terms"),
183
+ "code_terms": spec_payload.get("code_terms"),
184
+ "note": "Provenance and public extraction rules only; scored aggregate values are intentionally not stored here.",
185
+ }
186
+ _write_json(input_dir / "tutorial_metadata.json", metadata)
187
+
188
+
189
+ def _source_context_text(path: Path) -> str:
190
+ try:
191
+ raw = path.read_text(encoding="utf-8", errors="replace")
192
+ except Exception:
193
+ return f"{path.name}\nsha256={_sha256_file(path)}\nsize_bytes={path.stat().st_size}\n"
194
+ if path.suffix.lower() in {".html", ".htm", ".md", ".txt"}:
195
+ return _clean_markup_text(raw)
196
+ return re.sub(r"\s+", " ", raw).strip()
197
+
198
+
199
+ def _ensure_public_input_footprint(input_dir: Path, source_paths: list[Path]) -> str:
200
+ current = _tree_file_bytes(input_dir)
201
+ if current >= MIN_PUBLIC_TASK_DATA_BYTES:
202
+ return f"public input footprint is {current} bytes; no context expansion needed"
203
+ context_path = input_dir / "source_context_windows.jsonl"
204
+ base = current - (context_path.stat().st_size if context_path.is_file() else 0)
205
+ context_path.unlink(missing_ok=True)
206
+ rows: list[dict[str, Any]] = []
207
+ for source in source_paths:
208
+ if not source.is_file() or source.resolve() == context_path.resolve():
209
+ continue
210
+ text = _source_context_text(source)
211
+ if not text:
212
+ continue
213
+ start = 0
214
+ width = 1800
215
+ stride = 900
216
+ while start < len(text):
217
+ end = min(len(text), start + width)
218
+ rows.append({
219
+ "source_file": source.relative_to(input_dir).as_posix() if source.is_relative_to(input_dir) else source.name,
220
+ "source_sha256": _sha256_file(source),
221
+ "start_char": start,
222
+ "end_char": end,
223
+ "text": text[start:end],
224
+ })
225
+ if end == len(text):
226
+ break
227
+ start += stride
228
+ if not rows:
229
+ raise ValueError("public input footprint expansion has no public source text")
230
+ input_dir.mkdir(parents=True, exist_ok=True)
231
+ rows_written = 0
232
+ target_extra = MIN_PUBLIC_TASK_DATA_BYTES - max(0, base)
233
+ with context_path.open("w", encoding="utf-8") as handle:
234
+ cycle = 0
235
+ while handle.tell() < target_extra or rows_written < 100:
236
+ row = dict(rows[rows_written % len(rows)])
237
+ row["window_id"] = rows_written + 1
238
+ row["cycle"] = cycle
239
+ handle.write(json.dumps(row, ensure_ascii=False) + "\n")
240
+ rows_written += 1
241
+ if rows_written % len(rows) == 0:
242
+ cycle += 1
243
+ handle.flush()
244
+ return f"wrote input/source_context_windows.jsonl with {rows_written} public-source windows and {context_path.stat().st_size} bytes"
245
+
246
+
247
+ def _write_software_manifest(software_dir: Path, spec_payload: dict[str, Any]) -> None:
248
+ if str(spec_payload.get("workflow_kind") or "") != "software_tutorial_doc_audit":
249
+ return
250
+ software_dir.mkdir(parents=True, exist_ok=True)
251
+ software_name = str(spec_payload.get("software_name") or "").strip()
252
+ executables = [str(item).strip() for item in spec_payload.get("executables") or [] if str(item).strip()]
253
+ system_packages = [str(item).strip() for item in spec_payload.get("required_system_packages") or [] if str(item).strip()]
254
+ source_urls = [str(item).strip() for item in spec_payload.get("source_urls") or [] if str(item).strip()]
255
+ _write_json(software_dir / "software_manifest.json", {
256
+ "software_name": software_name,
257
+ "executables": executables,
258
+ "required_system_packages": system_packages,
259
+ "official_sources": source_urls,
260
+ "solve_time_network": "disabled",
261
+ "python_wrapper_only": False,
262
+ "note": "This task audits real official software documentation/source staged offline; Python helpers only validate outputs.",
263
+ })
264
+ with (software_dir / "command_examples.csv").open("w", encoding="utf-8", newline="") as handle:
265
+ writer = csv.DictWriter(handle, fieldnames=["term", "kind", "software_name"])
266
+ writer.writeheader()
267
+ for term in spec_payload.get("code_terms") or []:
268
+ writer.writerow({"term": str(term), "kind": "code_term", "software_name": software_name})
269
+ for exe in executables:
270
+ writer.writerow({"term": exe, "kind": "executable", "software_name": software_name})
271
+
272
+
273
+ def software_tutorial_outputs(input_dir: Path, output_dir: Path) -> None:
274
+ spec = _read_json(input_dir / "analysis_spec.json")
275
+ source_file = str(spec["source_file"])
276
+ source_text = (input_dir / source_file).read_text(encoding="utf-8", errors="replace")
277
+ clean_text = _clean_markup_text(source_text)
278
+ headings = _extract_headings(source_text)
279
+ code_blocks = _extract_code_blocks(source_text)
280
+ window_rows: list[dict[str, str]] = []
281
+ with (input_dir / str(spec["input_file"])).open("r", encoding="utf-8", newline="") as handle:
282
+ window_rows = list(csv.DictReader(handle))
283
+ output_dir.mkdir(parents=True, exist_ok=True)
284
+
285
+ with (output_dir / "section_outline.csv").open("w", encoding="utf-8", newline="") as handle:
286
+ fieldnames = ["rank", "heading_level", "heading_text", "slug"]
287
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
288
+ writer.writeheader()
289
+ for rank, heading in enumerate(headings, start=1):
290
+ writer.writerow({
291
+ "rank": rank,
292
+ "heading_level": heading["level"],
293
+ "heading_text": heading["text"],
294
+ "slug": _heading_slug(heading["text"]),
295
+ })
296
+
297
+ all_terms: list[tuple[str, str]] = []
298
+ for term in spec.get("required_terms") or []:
299
+ all_terms.append((str(term), "required"))
300
+ for term in spec.get("code_terms") or []:
301
+ if str(term) not in {item[0] for item in all_terms}:
302
+ all_terms.append((str(term), "code"))
303
+ code_text = "\n".join(code_blocks)
304
+ term_rows: list[dict[str, Any]] = []
305
+ for term, category in all_terms:
306
+ term_rows.append({
307
+ "term": term,
308
+ "category": category,
309
+ "count": _term_count(clean_text, term),
310
+ "first_window": _first_window(window_rows, term),
311
+ "appears_in_code": "true" if term.lower() in code_text.lower() else "false",
312
+ })
313
+ term_rows.sort(key=lambda row: (str(row["category"]), str(row["term"]).lower()))
314
+ with (output_dir / "keyword_inventory.csv").open("w", encoding="utf-8", newline="") as handle:
315
+ fieldnames = ["term", "category", "count", "first_window", "appears_in_code"]
316
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
317
+ writer.writeheader()
318
+ for row in term_rows:
319
+ writer.writerow(row)
320
+
321
+ code_terms = [str(item).lower() for item in spec.get("code_terms") or []]
322
+ with (output_dir / "code_block_inventory.csv").open("w", encoding="utf-8", newline="") as handle:
323
+ fieldnames = ["block_index", "line_count", "char_count", "contains_code_term", "first_line"]
324
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
325
+ writer.writeheader()
326
+ for index, block in enumerate(code_blocks, start=1):
327
+ lines = [line for line in block.splitlines() if line.strip()]
328
+ contains = any(term and term in block.lower() for term in code_terms)
329
+ writer.writerow({
330
+ "block_index": index,
331
+ "line_count": len(lines),
332
+ "char_count": len(block),
333
+ "contains_code_term": "true" if contains else "false",
334
+ "first_line": lines[0][:200] if lines else "",
335
+ })
336
+
337
+ keyword_total = sum(int(row["count"]) for row in term_rows)
338
+ required_found = sum(1 for row in term_rows if row["category"] == "required" and int(row["count"]) > 0)
339
+ top_keyword = None
340
+ if term_rows:
341
+ top = max(term_rows, key=lambda row: (int(row["count"]), str(row["term"]).lower()))
342
+ top_keyword = str(top["term"]) if int(top["count"]) > 0 else None
343
+ summary = {
344
+ "software_name": str(spec.get("software_name") or ""),
345
+ "source_file": source_file,
346
+ "window_count": len(window_rows),
347
+ "heading_count": len(headings),
348
+ "code_block_count": len(code_blocks),
349
+ "keyword_total": keyword_total,
350
+ "unique_required_terms_found": required_found,
351
+ "top_keyword": top_keyword,
352
+ "source_character_count": len(clean_text),
353
+ }
354
+ _write_json(output_dir / "summary.json", summary)
355
+
356
+
357
+ def geojson_outputs(input_dir: Path, output_dir: Path) -> None:
358
+ payload = _read_json(input_dir / "events.geojson")
359
+ features = payload.get("features") if isinstance(payload, dict) else []
360
+ rows: list[dict[str, Any]] = []
361
+ for feature in features:
362
+ if not isinstance(feature, dict):
363
+ continue
364
+ props = feature.get("properties") if isinstance(feature.get("properties"), dict) else {}
365
+ geom = feature.get("geometry") if isinstance(feature.get("geometry"), dict) else {}
366
+ coords = geom.get("coordinates") if isinstance(geom.get("coordinates"), list) else []
367
+ mag = props.get("mag")
368
+ try:
369
+ mag = float(mag) if mag is not None else None
370
+ except (TypeError, ValueError):
371
+ mag = None
372
+ depth = None
373
+ if len(coords) >= 3:
374
+ try:
375
+ depth = float(coords[2])
376
+ except (TypeError, ValueError):
377
+ depth = None
378
+ time_ms = props.get("time")
379
+ date_utc = "unknown"
380
+ if isinstance(time_ms, (int, float)):
381
+ date_utc = dt.datetime.utcfromtimestamp(time_ms / 1000).date().isoformat()
382
+ rows.append({
383
+ "id": feature.get("id") or props.get("code") or "",
384
+ "mag": mag,
385
+ "depth": depth,
386
+ "place": str(props.get("place") or ""),
387
+ "region": _stable_region(str(props.get("place") or "")),
388
+ "date_utc": date_utc,
389
+ "feature": feature,
390
+ })
391
+ output_dir.mkdir(parents=True, exist_ok=True)
392
+ mags = [row["mag"] for row in rows if row["mag"] is not None]
393
+ depths = [row["depth"] for row in rows if row["depth"] is not None]
394
+ summary = {
395
+ "event_count": len(rows),
396
+ "magnitude": {
397
+ "count": len(mags),
398
+ "min": round(min(mags), 6) if mags else None,
399
+ "max": round(max(mags), 6) if mags else None,
400
+ "mean": round(statistics.fmean(mags), 6) if mags else None,
401
+ "median": round(statistics.median(mags), 6) if mags else None,
402
+ },
403
+ "depth_km": {
404
+ "count": len(depths),
405
+ "min": round(min(depths), 6) if depths else None,
406
+ "max": round(max(depths), 6) if depths else None,
407
+ "mean": round(statistics.fmean(depths), 6) if depths else None,
408
+ },
409
+ "time_range_utc": {
410
+ "start_date": min((row["date_utc"] for row in rows if row["date_utc"] != "unknown"), default=None),
411
+ "end_date": max((row["date_utc"] for row in rows if row["date_utc"] != "unknown"), default=None),
412
+ },
413
+ "quality_flags": {
414
+ "missing_magnitude": sum(1 for row in rows if row["mag"] is None),
415
+ "missing_depth": sum(1 for row in rows if row["depth"] is None),
416
+ "unique_regions": len({row["region"] for row in rows}),
417
+ },
418
+ }
419
+ _write_json(output_dir / "summary.json", summary)
420
+
421
+ grouped: dict[tuple[str, str], list[dict[str, Any]]] = {}
422
+ for row in rows:
423
+ grouped.setdefault((_mag_bin(row["mag"]), _depth_bin(row["depth"])), []).append(row)
424
+ with (output_dir / "magnitude_depth_bins.csv").open("w", encoding="utf-8", newline="") as handle:
425
+ fieldnames = ["mag_bin", "depth_bin", "event_count", "mean_magnitude", "max_magnitude"]
426
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
427
+ writer.writeheader()
428
+ for (mag_bin, depth_bin), group in sorted(grouped.items()):
429
+ group_mags = [row["mag"] for row in group if row["mag"] is not None]
430
+ writer.writerow({
431
+ "mag_bin": mag_bin,
432
+ "depth_bin": depth_bin,
433
+ "event_count": len(group),
434
+ "mean_magnitude": f"{statistics.fmean(group_mags):.6f}" if group_mags else "",
435
+ "max_magnitude": f"{max(group_mags):.6f}" if group_mags else "",
436
+ })
437
+
438
+ daily: dict[tuple[str, str], list[dict[str, Any]]] = {}
439
+ for row in rows:
440
+ daily.setdefault((row["region"], row["date_utc"]), []).append(row)
441
+ with (output_dir / "region_daily_counts.csv").open("w", encoding="utf-8", newline="") as handle:
442
+ fieldnames = ["region", "date_utc", "event_count", "max_magnitude"]
443
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
444
+ writer.writeheader()
445
+ for (region, date_utc), group in sorted(daily.items()):
446
+ group_mags = [row["mag"] for row in group if row["mag"] is not None]
447
+ writer.writerow({
448
+ "region": region,
449
+ "date_utc": date_utc,
450
+ "event_count": len(group),
451
+ "max_magnitude": f"{max(group_mags):.6f}" if group_mags else "",
452
+ })
453
+
454
+ filtered = [row["feature"] for row in rows if row["mag"] is not None and row["mag"] >= 4.5]
455
+ _write_json(output_dir / "filtered_events.geojson", {"type": "FeatureCollection", "features": filtered})
456
+
457
+
458
+ def csv_time_series_outputs(input_dir: Path, output_dir: Path) -> None:
459
+ spec = _read_json(input_dir / "analysis_spec.json")
460
+ csv_name = spec["input_file"]
461
+ date_column = spec["date_column"]
462
+ value_column = spec["value_column"]
463
+ rows: list[dict[str, Any]] = []
464
+ with (input_dir / csv_name).open("r", encoding="utf-8", newline="") as raw_handle:
465
+ lines = [line for line in raw_handle if not line.lstrip().startswith("#")]
466
+ reader = csv.DictReader(lines)
467
+ for item in reader:
468
+ raw_date = item.get(date_column, "")
469
+ try:
470
+ day = dt.date.fromisoformat(raw_date)
471
+ except ValueError:
472
+ if raw_date.isdigit() and len(raw_date) == 4:
473
+ day = dt.date(int(raw_date), 1, 1)
474
+ else:
475
+ continue
476
+ raw_value = item.get(value_column, "")
477
+ try:
478
+ value = float(raw_value)
479
+ except (TypeError, ValueError):
480
+ value = None
481
+ rows.append({"date": day, "value": value, "raw": item})
482
+ rows.sort(key=lambda item: item["date"])
483
+ valid = [row for row in rows if row["value"] is not None]
484
+ output_dir.mkdir(parents=True, exist_ok=True)
485
+ monthly: dict[str, list[float]] = {}
486
+ for row in valid:
487
+ key = row["date"].strftime("%Y-%m")
488
+ monthly.setdefault(key, []).append(row["value"])
489
+ with (output_dir / "monthly_statistics.csv").open("w", encoding="utf-8", newline="") as handle:
490
+ fieldnames = ["month", "count", "mean", "median", "min", "max"]
491
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
492
+ writer.writeheader()
493
+ for month, values in sorted(monthly.items()):
494
+ writer.writerow({
495
+ "month": month,
496
+ "count": len(values),
497
+ "mean": f"{statistics.fmean(values):.6f}",
498
+ "median": f"{statistics.median(values):.6f}",
499
+ "min": f"{min(values):.6f}",
500
+ "max": f"{max(values):.6f}",
501
+ })
502
+ existing_dates = {row["date"] for row in rows}
503
+ missing_days: list[dt.date] = []
504
+ if rows:
505
+ day = rows[0]["date"]
506
+ while day <= rows[-1]["date"]:
507
+ if day.weekday() < 5 and day not in existing_dates:
508
+ missing_days.append(day)
509
+ day += dt.timedelta(days=1)
510
+ with (output_dir / "missing_business_days.csv").open("w", encoding="utf-8", newline="") as handle:
511
+ writer = csv.DictWriter(handle, fieldnames=["date"])
512
+ writer.writeheader()
513
+ for day in missing_days:
514
+ writer.writerow({"date": day.isoformat()})
515
+ with (output_dir / "clean_series.csv").open("w", encoding="utf-8", newline="") as handle:
516
+ writer = csv.DictWriter(handle, fieldnames=["date", "value"])
517
+ writer.writeheader()
518
+ for row in valid:
519
+ writer.writerow({"date": row["date"].isoformat(), "value": f"{row['value']:.6f}"})
520
+ values = [row["value"] for row in valid]
521
+ summary = {
522
+ "series_name": spec.get("series_name", value_column),
523
+ "row_count": len(rows),
524
+ "valid_value_count": len(valid),
525
+ "missing_value_count": len(rows) - len(valid),
526
+ "missing_business_day_count": len(missing_days),
527
+ "date_range": {
528
+ "start": rows[0]["date"].isoformat() if rows else None,
529
+ "end": rows[-1]["date"].isoformat() if rows else None,
530
+ },
531
+ "value": {
532
+ "min": round(min(values), 6) if values else None,
533
+ "max": round(max(values), 6) if values else None,
534
+ "mean": round(statistics.fmean(values), 6) if values else None,
535
+ "median": round(statistics.median(values), 6) if values else None,
536
+ },
537
+ }
538
+ _write_json(output_dir / "summary.json", summary)
539
+
540
+
541
+ def _aggregate_annual_rows(rows: list[dict[str, Any]], aggregation: str) -> list[dict[str, Any]]:
542
+ if not aggregation:
543
+ return rows
544
+ grouped: dict[int, list[float]] = {}
545
+ for row in rows:
546
+ grouped.setdefault(int(row["year"]), []).append(float(row["value"]))
547
+ aggregated: list[dict[str, Any]] = []
548
+ for year, values in sorted(grouped.items()):
549
+ if aggregation == "mean":
550
+ value = statistics.fmean(values)
551
+ elif aggregation == "median":
552
+ value = statistics.median(values)
553
+ elif aggregation == "max":
554
+ value = max(values)
555
+ elif aggregation == "min":
556
+ value = min(values)
557
+ elif aggregation == "count":
558
+ value = float(len(values))
559
+ else:
560
+ raise ValueError(f"unsupported year_aggregation for csv_annual_series_audit: {aggregation}")
561
+ aggregated.append({"year": year, "value": value})
562
+ return aggregated
563
+
564
+
565
+ def csv_annual_series_outputs(input_dir: Path, output_dir: Path) -> None:
566
+ spec = _read_json(input_dir / "analysis_spec.json")
567
+ csv_name = spec["input_file"]
568
+ year_column = spec["year_column"]
569
+ value_column = spec["value_column"]
570
+ # Optional: derive the year from an ISO-8601 timestamp column (e.g. USGS FDSN
571
+ # `time` = "2022-06-29T19:17:58.929Z") instead of parsing an integer year.
572
+ # When unset, behaviour is unchanged (integer year column).
573
+ year_from_timestamp = bool(spec.get("year_from_timestamp", False))
574
+ year_aggregation = str(spec.get("year_aggregation") or "").strip().lower()
575
+ raw_rows: list[dict[str, Any]] = []
576
+ with (input_dir / csv_name).open("r", encoding="utf-8", newline="") as raw_handle:
577
+ lines = [line for line in raw_handle if not line.lstrip().startswith("#")]
578
+ reader = csv.DictReader(lines)
579
+ for item in reader:
580
+ raw_year = str(item.get(year_column, "")).strip()
581
+ try:
582
+ if year_from_timestamp:
583
+ # Take the leading 4-digit year of an ISO timestamp/date.
584
+ match = re.match(r"\s*(\d{4})", raw_year)
585
+ if not match:
586
+ continue
587
+ year = int(match.group(1))
588
+ else:
589
+ year = int(raw_year)
590
+ value = float(str(item.get(value_column, "")).strip())
591
+ except (TypeError, ValueError):
592
+ continue
593
+ raw_rows.append({"year": year, "value": value})
594
+ rows = _aggregate_annual_rows(raw_rows, year_aggregation)
595
+ rows.sort(key=lambda item: item["year"])
596
+ output_dir.mkdir(parents=True, exist_ok=True)
597
+ decades: dict[str, list[float]] = {}
598
+ for row in rows:
599
+ decade_start = (row["year"] // 10) * 10
600
+ decades.setdefault(f"{decade_start}s", []).append(row["value"])
601
+ with (output_dir / "decadal_statistics.csv").open("w", encoding="utf-8", newline="") as handle:
602
+ fieldnames = [
603
+ "decade_start",
604
+ "start_year",
605
+ "end_year",
606
+ "count",
607
+ "mean_departure",
608
+ "median_departure",
609
+ "min_departure",
610
+ "max_departure",
611
+ "sample_std_departure",
612
+ ]
613
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
614
+ writer.writeheader()
615
+ for decade, values in sorted(decades.items()):
616
+ decade_start = int(decade.rstrip("s"))
617
+ years = [row["year"] for row in rows if decade_start <= row["year"] <= decade_start + 9]
618
+ writer.writerow({
619
+ "decade_start": decade_start,
620
+ "start_year": min(years),
621
+ "end_year": max(years),
622
+ "count": len(values),
623
+ "mean_departure": f"{statistics.fmean(values):.6f}",
624
+ "median_departure": f"{statistics.median(values):.6f}",
625
+ "min_departure": f"{min(values):.6f}",
626
+ "max_departure": f"{max(values):.6f}",
627
+ "sample_std_departure": f"{statistics.stdev(values):.6f}" if len(values) >= 2 else "",
628
+ })
629
+ threshold = float(spec.get("threshold", 1.0))
630
+ with (output_dir / "threshold_years.csv").open("w", encoding="utf-8", newline="") as handle:
631
+ fieldnames = ["rank", "year", "departure", "threshold"]
632
+ writer = csv.DictWriter(handle, fieldnames=fieldnames)
633
+ writer.writeheader()
634
+ rank = 1
635
+ for row in rows:
636
+ if row["value"] >= threshold:
637
+ writer.writerow({
638
+ "rank": rank,
639
+ "year": row["year"],
640
+ "departure": f"{row['value']:.6f}",
641
+ "threshold": f"{threshold:.6f}",
642
+ })
643
+ rank += 1
644
+ with (output_dir / "clean_series.csv").open("w", encoding="utf-8", newline="") as handle:
645
+ writer = csv.DictWriter(handle, fieldnames=["Year", "Departure from Average"])
646
+ writer.writeheader()
647
+ for row in rows:
648
+ writer.writerow({"Year": row["year"], "Departure from Average": f"{row['value']:.6f}"})
649
+ values = [row["value"] for row in rows]
650
+ threshold_rows = [row for row in rows if row["value"] >= threshold]
651
+ min_row = min(rows, key=lambda row: row["value"]) if rows else None
652
+ max_row = max(rows, key=lambda row: row["value"]) if rows else None
653
+ summary = {
654
+ "series_name": spec.get("series_name", value_column),
655
+ "row_count": len(rows),
656
+ "year_range": {
657
+ "start": rows[0]["year"] if rows else None,
658
+ "end": rows[-1]["year"] if rows else None,
659
+ },
660
+ "value": {
661
+ "min": round(min(values), 6) if values else None,
662
+ "min_year": min_row["year"] if min_row else None,
663
+ "max": round(max(values), 6) if values else None,
664
+ "max_year": max_row["year"] if max_row else None,
665
+ "mean": round(statistics.fmean(values), 6) if values else None,
666
+ "median": round(statistics.median(values), 6) if values else None,
667
+ "sample_std": round(statistics.stdev(values), 6) if len(values) >= 2 else None,
668
+ },
669
+ "threshold": threshold,
670
+ "years_at_or_above_threshold": len(threshold_rows),
671
+ "first_threshold_year": threshold_rows[0]["year"] if threshold_rows else None,
672
+ "last_threshold_year": threshold_rows[-1]["year"] if threshold_rows else None,
673
+ }
674
+ if year_aggregation:
675
+ summary["year_aggregation"] = year_aggregation
676
+ summary["source_row_count"] = len(raw_rows)
677
+ _write_json(output_dir / "summary.json", summary)
678
+
679
+
20260907-002107-computing-math-7483af/tests/reference/internal/workflow_runtime.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ from workflow_adapters_runtime import software_tutorial_outputs
3
+
4
+ def run_reference(input_dir: Path, output_dir: Path) -> None:
5
+ software_tutorial_outputs(input_dir, output_dir)
20260907-002107-computing-math-7483af/tests/reference/reference_manifest.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "workflow_kind": "software_tutorial_doc_audit",
3
+ "task_id": "repair3_20260907_043_repair2_20260906_047_repair_20260906_software_0078",
4
+ "domain": "computing_math",
5
+ "task": "docker_bridge_tutorial_offline_audit",
6
+ "variant": "base",
7
+ "created_from": "standard reference workflow",
8
+ "required_outputs": [
9
+ {
10
+ "path": "summary.json",
11
+ "type": "json"
12
+ },
13
+ {
14
+ "path": "section_outline.csv",
15
+ "type": "csv"
16
+ },
17
+ {
18
+ "path": "keyword_inventory.csv",
19
+ "type": "csv"
20
+ },
21
+ {
22
+ "path": "code_block_inventory.csv",
23
+ "type": "csv"
24
+ }
25
+ ],
26
+ "numeric_tolerance": 1e-09,
27
+ "source_prior_sha256": "cef0d645b4725d5f4f91f73cde1389e9e2f9b69a2b22ed1132274f979764299a",
28
+ "gold_output_hashes": {
29
+ "summary.json": "cf2503abe57c7bf8138ac18a418370d8b6c6c86ac1aaf72911c1462ec8ab7751",
30
+ "section_outline.csv": "ca0685381edfcd5a6c7073f45ec3a7e83695c98eafd631e3c6c9ff90bac9a3ae",
31
+ "keyword_inventory.csv": "c2729ef6c725cb3796bf5702ef300161d8b908bffc9baf2aa48164d7748f4185",
32
+ "code_block_inventory.csv": "30fe74d82029b0cbdb380ceee6b5468ad59ef80ebff7eef7eb47d872b9199f47"
33
+ }
34
+ }
20260907-002107-computing-math-7483af/tests/reference/reference_solution.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import sys
5
+ from pathlib import Path
6
+
7
+
8
+ def main() -> int:
9
+ parser = argparse.ArgumentParser()
10
+ parser.add_argument("--input", required=True)
11
+ parser.add_argument("--output", required=True)
12
+ args = parser.parse_args()
13
+ sys.path.insert(0, str(Path(__file__).resolve().parent / "internal"))
14
+ from workflow_runtime import run_reference
15
+ run_reference(Path(args.input), Path(args.output))
16
+ return 0
17
+
18
+
19
+ if __name__ == "__main__":
20
+ raise SystemExit(main())
20260907-002107-computing-math-7483af/tests/test.sh ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -u
3
+
4
+ TESTS_DIR="${HARBOR_TESTS_DIR:-/tests}"
5
+ WORKSPACE_DIR="${HARBOR_WORKSPACE_DIR:-/workspace}"
6
+ LOGS_DIR="${HARBOR_LOGS_DIR:-/logs/verifier}"
7
+
8
+ mkdir -p "${LOGS_DIR}" "${WORKSPACE_DIR}/output"
9
+
10
+ python "${TESTS_DIR}/evaluator_runner.py" \
11
+ --output-dir "${WORKSPACE_DIR}/output" \
12
+ --reference-dir "${TESTS_DIR}/reference" \
13
+ --reward-json "${LOGS_DIR}/reward.json" \
14
+ --details-json "${LOGS_DIR}/ale_evaluator_details.json"
15
+
16
+ if [ ! -f "${LOGS_DIR}/reward.json" ]; then
17
+ echo '{"score":0.0,"format":0.0,"output_present":0.0,"evaluator_available":0.0,"item_count":0.0}' > "${LOGS_DIR}/reward.json"
18
+ fi
19
+
20
+ python - <<'PY' "${LOGS_DIR}/reward.json" "${LOGS_DIR}/reward.txt"
21
+ import json
22
+ import sys
23
+ from pathlib import Path
24
+ reward = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8"))
25
+ score = float(reward.get("score", 0.0))
26
+ Path(sys.argv[2]).write_text(f"{score}\n", encoding="utf-8")
27
+ PY
28
+
29
+ exit 0
20260907-002128-computing-math-734953/.DS_Store ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d6391ea6eaaca72274b0bce72d4021b430fc869a9d2ee086848e7c13f57b208
3
+ size 6148
20260907-002128-computing-math-734953/environment/Dockerfile ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+
3
+ WORKDIR /workspace
4
+
5
+ COPY public_data/input /workspace/input
6
+ COPY public_data/software /workspace/software
7
+ COPY public_data/task_card.json /workspace/task_card.json
8
+ COPY public_data/main.py /workspace/main.py
9
+ COPY public_data/README.md /workspace/README.md
10
+
11
+ RUN mkdir -p /workspace/output /workspace/report /logs/agent /logs/artifacts \
12
+ && chmod -R 777 /workspace/output /workspace/report /logs
20260907-002128-computing-math-734953/environment/public_data/README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Public Task Inputs
2
+
3
+ Files in this directory are copied into the workspace:
4
+
5
+ - `input/` -> `/workspace/input/`
6
+ - `software/` -> `/workspace/software/`
7
+ - `task_card.json` -> `/workspace/task_card.json`
8
+ - `main.py` -> `/workspace/main.py`
9
+
10
+ Hidden reference data and evaluator files are not present in the agent workspace.
11
+ Final deliverables must be written under `/workspace/output/`.
20260907-002128-computing-math-734953/environment/public_data/input/README.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ This directory contains the public staged input for this task.
2
+ input/analysis_spec.json is the authoritative public contract for input columns, grouping/filtering rules, required output files, and output schemas.
3
+ Primary data file: input/dockerfile_text_windows.csv.
4
+ Workflow kind: software_tutorial_doc_audit.
5
+ Required output files: output/summary.json, output/section_outline.csv, output/keyword_inventory.csv, output/code_block_inventory.csv.
6
+ Solve the task from the staged local files only; do not fetch fresh remote data during solve time.
20260907-002128-computing-math-734953/environment/public_data/input/analysis_spec.json ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "input_file": "dockerfile_text_windows.csv",
3
+ "source_file": "dockerfile_packaging_corpus.md",
4
+ "workflow_kind": "software_tutorial_doc_audit",
5
+ "software_name": "Docker / Postgres Official Image",
6
+ "tutorial_url": "https://raw.githubusercontent.com/docker-library/official-images/master/README.md",
7
+ "source_urls": [
8
+ "https://raw.githubusercontent.com/docker-library/official-images/master/README.md"
9
+ ],
10
+ "window_rule": {
11
+ "cleaning": "Strip HTML/script/style tags, decode entities, collapse whitespace, and preserve document text order.",
12
+ "window_size_words": 40,
13
+ "stride_words": 20,
14
+ "minimum_windows": 100
15
+ },
16
+ "heading_rule": "Extract h1-h6 headings from HTML; if no HTML headings are present, use Markdown # headings.",
17
+ "keyword_rule": "Count case-insensitive occurrences of required_terms and code_terms in the cleaned tutorial text.",
18
+ "required_terms": [
19
+ "Dockerfile",
20
+ "FROM",
21
+ "RUN",
22
+ "ENV",
23
+ "ENTRYPOINT",
24
+ "PGDATA",
25
+ "Tags",
26
+ "GitRepo"
27
+ ],
28
+ "code_terms": [
29
+ "postgres",
30
+ "docker-entrypoint.sh",
31
+ "FROM",
32
+ "RUN",
33
+ "ENV",
34
+ "ENTRYPOINT",
35
+ "apt-get"
36
+ ],
37
+ "executables": [
38
+ "docker",
39
+ "postgres",
40
+ "initdb"
41
+ ],
42
+ "required_system_packages": [
43
+ "docker.io",
44
+ "postgresql-client"
45
+ ],
46
+ "required_outputs": [
47
+ {
48
+ "path": "summary.json",
49
+ "type": "json"
50
+ },
51
+ {
52
+ "path": "section_outline.csv",
53
+ "type": "csv"
54
+ },
55
+ {
56
+ "path": "keyword_inventory.csv",
57
+ "type": "csv"
58
+ },
59
+ {
60
+ "path": "code_block_inventory.csv",
61
+ "type": "csv"
62
+ }
63
+ ],
64
+ "output_schemas": {
65
+ "summary.json": {
66
+ "software_name": "string",
67
+ "source_file": "string",
68
+ "window_count": "integer",
69
+ "heading_count": "integer",
70
+ "code_block_count": "integer",
71
+ "keyword_total": "integer",
72
+ "unique_required_terms_found": "integer",
73
+ "top_keyword": "string|null",
74
+ "source_character_count": "integer"
75
+ },
76
+ "section_outline.csv": [
77
+ "rank",
78
+ "heading_level",
79
+ "heading_text",
80
+ "slug"
81
+ ],
82
+ "keyword_inventory.csv": [
83
+ "term",
84
+ "category",
85
+ "count",
86
+ "first_window",
87
+ "appears_in_code"
88
+ ],
89
+ "code_block_inventory.csv": [
90
+ "block_index",
91
+ "line_count",
92
+ "char_count",
93
+ "contains_code_term",
94
+ "first_line"
95
+ ]
96
+ },
97
+ "notes": "Audit the staged offline official tutorial corpus. Do not fetch fresh documentation. All counts must be derived from the staged source file and tutorial_text_windows.csv."
98
+ }
20260907-002128-computing-math-734953/environment/public_data/input/dockerfile_packaging_corpus.md ADDED
@@ -0,0 +1,447 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Source 1: README.md
2
+
3
+ - URL: https://raw.githubusercontent.com/docker-library/official-images/master/README.md
4
+ - SHA256: 7b092c41c25d31902face488f7a5ed9928abb002548b1e3d64ee318afbbd2acf
5
+ - Bytes: 34724
6
+
7
+ ```markdown
8
+ # Docker Official Images
9
+
10
+ ## Table of Contents
11
+
12
+ <!-- AUTOGENERATED TOC -->
13
+
14
+ 1. [Docker Official Images](#docker-official-images)
15
+ 1. [Table of Contents](#table-of-contents)
16
+ 2. [What are "Official Images"?](#what-are-official-images)
17
+ 3. [Architectures other than amd64?](#architectures-other-than-amd64)
18
+ 4. [More FAQs?](#more-faqs)
19
+ 5. [Contributing to the standard library](#contributing-to-the-standard-library)
20
+ 1. [Review Guidelines](#review-guidelines)
21
+ 1. [Maintainership](#maintainership)
22
+ 2. [Repeatability](#repeatability)
23
+ 3. [Consistency](#consistency)
24
+ 4. [Clarity](#clarity)
25
+ 5. [init](#init)
26
+ 6. [Cacheability](#cacheability)
27
+ 7. [Security](#security)
28
+ 1. [Image Build](#image-build)
29
+ 2. [Runtime Configuration](#runtime-configuration)
30
+ 3. [Security Releases](#security-releases)
31
+ 8. [Multiple Architectures](#multiple-architectures)
32
+ 2. [Commitment](#commitment)
33
+ 6. [Library definition files](#library-definition-files)
34
+ 1. [Filenames](#filenames)
35
+ 2. [Tags and aliases](#tags-and-aliases)
36
+ 3. [Instruction format](#instruction-format)
37
+ 4. [Creating a new repository](#creating-a-new-repository)
38
+ 5. [Adding a new tag in an existing repository (that you're the maintainer of)](#adding-a-new-tag-in-an-existing-repository-that-youre-the-maintainer-of)
39
+ 6. [Change to a tag in an existing repository (that you're the maintainer of)](#change-to-a-tag-in-an-existing-repository-that-youre-the-maintainer-of)
40
+ 7. [Bashbrew](#bashbrew)
41
+
42
+ <!-- AUTOGENERATED TOC -->
43
+
44
+ ## What are "Official Images"?
45
+
46
+ The Docker Official Images are curated images [hosted on Docker Hub](https://hub.docker.com/u/library). The main tenets are:
47
+
48
+ - Focus on [Free](https://www.debian.org/social_contract#guidelines) and [Open-Source](https://opensource.org/) Software
49
+
50
+ - Support [multiple architectures](#architectures-other-than-amd64)
51
+
52
+ - Exemplify [`Dockerfile` best practices](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/)
53
+
54
+ - [Actively rebuild](#library-definition-files) for updates and security fixes
55
+
56
+ - Adhere to upstream recommendations
57
+
58
+ - Add minimal quality-of-life behavior for the container environment where fit
59
+
60
+ See [Docker's documentation](https://docs.docker.com/docker-hub/official_repos/) for a good high-level overview of the program.
61
+
62
+ In essence we strive to heed upstream's recommendations on how they intend for their software to be consumed. Many images are maintained in collaboration with the relevant upstream project if not maintained directly by them. Additionally we aim to exemplify the best practices for Dockerfiles to serve as a reference when making or deriving your own images from them.
63
+
64
+ (If you are a representative of an upstream for which there exists an image and you would like to get involved, please see the [Maintainership](#maintainership) section below!)
65
+
66
+ ## Architectures other than amd64?
67
+
68
+ Some images have been ported for other architectures, and many of these are officially supported (to various degrees).
69
+
70
+ - Architectures officially supported by Docker, Inc. for running Docker: (see [download.docker.com](https://download.docker.com/linux/))
71
+ - ARMv6 32-bit (`arm32v6`): https://hub.docker.com/u/arm32v6/
72
+ - ARMv7 32-bit (`arm32v7`): https://hub.docker.com/u/arm32v7/
73
+ - ARMv8 64-bit (`arm64v8`): https://hub.docker.com/u/arm64v8/
74
+ - Linux x86-64 (`amd64`): https://hub.docker.com/u/amd64/
75
+ - Windows x86-64 (`windows-amd64`): https://hub.docker.com/u/winamd64/
76
+ - Other architectures built by official images: (but *not* officially supported by Docker, Inc.)
77
+ - ARMv5 32-bit (`arm32v5`): https://hub.docker.com/u/arm32v5/
78
+ - IBM POWER8 (`ppc64le`): https://hub.docker.com/u/ppc64le/
79
+ - IBM z Systems (`s390x`): https://hub.docker.com/u/s390x/
80
+ - RISC-V 64-bit (`riscv64`): https://hub.docker.com/u/riscv64/
81
+ - x86/i686 (`i386`): https://hub.docker.com/u/i386/
82
+
83
+ These other architectures are included under the non-prefixed images via [OCI "image indexes"](https://github.com/opencontainers/image-spec/blob/v1.1.1/image-index.md), such that, for example, `docker run hello-world` should run as-is on all supported platforms.
84
+
85
+ If you're curious about how these are built, head over to [our FAQ entry](https://github.com/docker-library/faq#an-images-source-changed-in-git-now-what) to see an explanation of the process or visit [meta-scripts](https://github.com/docker-library/meta-scripts) to see the build process source files.
86
+
87
+ See the [multi-arch section](#multiple-architectures) below for recommendations in adding more architectures to an official image.
88
+
89
+ ## More FAQs?
90
+
91
+ Yes! We have [a dedicated FAQ repository](https://github.com/docker-library/faq) where we try to collect other common questions (both about the program and about our practices).
92
+
93
+ ## Contributing to the standard library
94
+
95
+ Thank you for your interest in the Docker official images project! We strive to make these instructions as simple and straightforward as possible, but if you find yourself lost, don't hesitate to seek us out on [Libera.Chat IRC](https://libera.chat) in channel `#docker-library` or by creating a GitHub issue here.
96
+
97
+ Be sure to familiarize yourself with [Official Repositories on Docker Hub](https://docs.docker.com/docker-hub/official_repos/) and the [Best practices for writing Dockerfiles](https://docs.docker.com/articles/dockerfile_best-practices/) in the Docker documentation. These will be the foundation of the review process performed by the official images maintainers. If you'd like the review process to go more smoothly, please ensure that your `Dockerfile`s adhere to all the points mentioned there, as well as [below](README.md#review-guidelines), before submitting a pull request.
98
+
99
+ Also, the Hub descriptions for these images are currently stored separately in the [`docker-library/docs` repository](https://github.com/docker-library/docs), whose [`README.md` file](https://github.com/docker-library/docs/blob/master/README.md) explains more about how it's structured and how to contribute to it. Please be prepared to submit a PR there as well, pending acceptance of your image here.
100
+
101
+ ### Review Guidelines
102
+
103
+ Because the official images are intended to be learning tools for those new to Docker as well as the base images for advanced users to build their production releases, we review each proposed `Dockerfile` to ensure that it meets a minimum standard for quality and maintainability. While some of that standard is hard to define (due to subjectivity), as much as possible is defined here, while also adhering to the "Best Practices" where appropriate.
104
+
105
+ A checklist which may be used by the maintainers during review can be found in [`NEW-IMAGE-CHECKLIST.md`](NEW-IMAGE-CHECKLIST.md).
106
+
107
+ #### Maintainership
108
+
109
+ Version bumps and security fixes should be attended to in a timely manner.
110
+
111
+ If you do not represent upstream and upstream becomes interested in maintaining the image, steps should be taken to ensure a smooth transition of image maintainership over to upstream.
112
+
113
+ For upstreams interested in taking over maintainership of an existing repository, the first step is to get involved in the existing repository. Making comments on issues, proposing changes, and making yourself known within the "image community" (even if that "community" is just the current maintainer) are all important places to start to ensure that the transition is unsurprising to existing contributors and users.
114
+
115
+ When taking over an existing repository, please ensure that the entire Git history of the original repository is kept in the new upstream-maintained repository to make sure the review process isn't stalled during the transition. This is most easily accomplished by forking the new from the existing repository, but can also be accomplished by fetching the commits directly from the original and pushing them into the new repo (ie, `git fetch https://github.com/jsmith/example.git master`, `git rebase FETCH_HEAD`, `git push -f`). On GitHub, an alternative is to move ownership of the git repository. This can be accomplished without giving either group admin access to the other owner's repository:
116
+
117
+ - create temporary intermediary organization
118
+ - [docker-library-transitioner](https://github.com/docker-library-transitioner) is available for this purpose if you would like our help
119
+ - give old and new owners admin access to intermediary organization
120
+ - old owner transfers repo ownership to intermediary organization
121
+ - new owner transfers repo ownership to its new home
122
+ - recommend that old owner does not fork new repo back into the old organization to ensure that GitHub redirects will just work
123
+
124
+ #### Repeatability
125
+
126
+ Rebuilding the same `Dockerfile` should result in the same version of the image being packaged, even if the second build happens several versions later, or the build should fail outright, such that an inadvertent rebuild of a `Dockerfile` tagged as `0.1.0` doesn't end up containing `0.2.3`. For example, if using `apt` to install the main program for the image, be sure to pin it to a specific version (ex: `... apt-get install -y my-package=0.1.0 ...`). For dependent packages installed by `apt` there is not usually a need to pin them to a version.
127
+
128
+ No official images can be derived from, or depend on, non-official images (allowing the non-image [`scratch`](https://hub.docker.com/_/scratch/) and the intentionally limited exceptions pinned in [`.external-pins`](.external-pins) -- see also [`.external-pins/list.sh`](.external-pins/list.sh)).
129
+
130
+ #### Consistency
131
+
132
+ All official images should provide a consistent interface. A beginning user should be able to `docker run official-image bash` (or `sh`) without needing to learn about `--entrypoint`. It is also nice for advanced users to take advantage of entrypoint, so that they can `docker run official-image --arg1 --arg2` without having to specify the binary to execute.
133
+
134
+ 1. If the startup process does not need arguments, just use `CMD`:
135
+
136
+ ```Dockerfile
137
+ CMD ["irb"]
138
+ ```
139
+
140
+ 2. If there is initialization that needs to be done on start, like creating the initial database, use an `ENTRYPOINT` along with `CMD`:
141
+
142
+ ```Dockerfile
143
+ ENTRYPOINT ["/docker-entrypoint.sh"]
144
+ CMD ["postgres"]
145
+ ```
146
+
147
+ 1. Ensure that `docker run official-image bash` (or `sh`) works too. The easiest way is to check for the expected command and if it is something else, just `exec "$@"` (run whatever was passed, properly keeping the arguments escaped).
148
+
149
+ ```sh
150
+ #!/bin/sh
151
+ set -e
152
+
153
+ # this if will check if the first argument is a flag
154
+ # but only works if all arguments require a hyphenated flag
155
+ # -v; -SL; -f arg; etc will work, but not arg1 arg2
156
+ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
157
+ set -- mongod "$@"
158
+ fi
159
+
160
+ # check for the expected command
161
+ if [ "$1" = 'mongod' ]; then
162
+ # init db stuff....
163
+ # use gosu (or su-exec) to drop to a non-root user
164
+ exec gosu mongod "$@"
165
+ fi
166
+
167
+ # else default to run whatever the user wanted like "bash" or "sh"
168
+ exec "$@"
169
+ ```
170
+
171
+ 3. If the image only contains the main executable and its linked libraries (ie no shell) then it is fine to use the executable as the `ENTRYPOINT`, since that is the only thing that can run:
172
+
173
+ ```Dockerfile
174
+ ENTRYPOINT ["fully-static-binary"]
175
+ CMD ["--help"]
176
+ ```
177
+
178
+ The most common indicator of whether this is appropriate is that the image `Dockerfile` starts with [`scratch`](https://registry.hub.docker.com/_/scratch/) (`FROM scratch`).
179
+
180
+ #### Clarity
181
+
182
+ Try to make the `Dockerfile` easy to understand/read. It may be tempting, for the sake of brevity, to put complicated initialization details into a standalone script and merely add a `RUN` command in the `Dockerfile`. However, this causes the resulting `Dockerfile` to be overly opaque, and such `Dockerfile`s are unlikely to pass review. Instead, it is recommended to put all the commands for initialization into the `Dockerfile` as appropriate `RUN` or `ENV` command combinations. To find good examples, look at the current official images.
183
+
184
+ Some examples at the time of writing:
185
+
186
+ - [php](https://github.com/docker-library/php/blob/b4aeb948e2e240c732d78890ff03285b16e8edda/5.6/Dockerfile)
187
+ - [python](https://github.com/docker-library/python/blob/3e5826ad0c6e29f07f6dc7ff8f30b4c54385d1bb/3.4/Dockerfile)
188
+ - [ruby:2.2](https://github.com/docker-library/ruby/blob/e34b201a0f0b49818fc8373f6a9148e13d546bdf/2.2/Dockerfile)
189
+
190
+ #### init
191
+
192
+ Following the Docker guidelines it is highly recommended that the resulting image be just one concern per container; predominantly this means just one process per container, so there is no need for a full init system. There are two situations where an init-like process would be helpful for the container. The first being signal handling. If the process launched does not handle `SIGTERM` by exiting, it will not be killed since it is PID 1 in the container (see "NOTE" at the end of the [Foreground section](https://docs.docker.com/engine/reference/run/#foreground) in the docker docs). The second situation would be zombie reaping. If the process spawns child processes and does not properly reap them it will lead to a full process table, which can prevent the whole system from spawning any new processes. For both of these concerns we recommend [tini](https://github.com/krallin/tini). It is incredibly small, has minimal external dependencies, fills each of these roles, and does only the necessary parts of reaping and signal forwarding.
193
+
194
+ Be sure to use tini in `CMD` or `ENTRYPOINT` as appropriate.
195
+
196
+ It is best to install tini from a distribution-provided package (ex. `apt-get install tini`). If tini is not available in your distribution or is too old, here is a snippet of a `Dockerfile` to add in tini:
197
+
198
+ ```Dockerfile
199
+ # Install tini for signal processing and zombie killing
200
+ ENV TINI_VERSION v0.18.0
201
+ ENV TINI_SIGN_KEY 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7
202
+ RUN set -eux; \
203
+ wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini"; \
204
+ wget -O /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc"; \
205
+ export GNUPGHOME="$(mktemp -d)"; \
206
+ gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$TINI_SIGN_KEY"; \
207
+ gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini; \
208
+ command -v gpgconf && gpgconf --kill all || :; \
209
+ rm -r "$GNUPGHOME" /usr/local/bin/tini.asc; \
210
+ chmod +x /usr/local/bin/tini; \
211
+ tini --version
212
+ ```
213
+
214
+ #### Cacheability
215
+
216
+ This is one place that experience ends up trumping documentation for the path to enlightenment, but the following tips might help:
217
+
218
+ - Avoid `COPY`/`ADD` whenever possible, but when necessary, be as specific as possible (ie, `COPY one-file.sh /somewhere/` instead of `COPY . /somewhere`).
219
+
220
+ The reason for this is that the cache for `COPY` instructions considers file `mtime` changes to be a cache bust, which can make the cache behavior of `COPY` unpredictable sometimes, especially when `.git` is part of what needs to be `COPY`ed (for example).
221
+
222
+ - Ensure that lines which are less likely to change come before lines that are more likely to change (with the caveat that each line should generate an image that still runs successfully without assumptions of later lines).
223
+
224
+ For example, the line that contains the software version number (`ENV MYSOFTWARE_VERSION 4.2`) should come after a line that sets up the APT repository `.list` file (`RUN echo 'deb http://example.com/mysoftware/debian some-suite main' > /etc/apt/sources.list.d/mysoftware.list`).
225
+
226
+ #### Security
227
+
228
+ ##### Image Build
229
+
230
+ The `Dockerfile` should be written to help mitigate interception attacks during build. Our requirements focus on three main objectives: verifying the source, verifying author, and verifying the content; these are respectively accomplished by the following: using https where possible; importing PGP keys with the full fingerprint in the `Dockerfile` to check signatures; embedding checksums directly in the `Dockerfile`. All three should be used when possible. Just https and embedded checksum can be used when no signature is published. As a last resort, just an embedded checksum is acceptable if the site doesn't have https available and no signature.
231
+
232
+ The purpose in recommending the use of https for downloading needed artifacts is that it ensures that the download is from a trusted source which also happens to make interception much more difficult.
233
+
234
+ The purpose in recommending PGP signature verification is to ensure that only an authorized user published the given artifact. When importing PGP keys, please use the [the `keys.openpgp.org` service](https://keys.openpgp.org/about) when possible (preferring `keyserver.ubuntu.com` otherwise). See also the FAQ section on [keys and verification](https://github.com/docker-library/faq/#openpgp--gnupg-keys-and-verification).
235
+
236
+ The purpose in recommending checksum verification is to verify that the artifact is as expected. This ensures that when remote content changes, the Dockerfile also will change and provide a natural `docker build` cache bust. As a bonus, this also prevents accidentally downloading newer-than-expected artifacts on poorly versioned files.
237
+
238
+ Below are some examples:
239
+
240
+ - **Preferred**: *download over https, PGP key full fingerprint import and `asc` verification, embedded checksum verified.*
241
+
242
+ ```Dockerfile
243
+ ENV PYTHON_DOWNLOAD_SHA512 (sha512-value-here)
244
+ RUN set -eux; \
245
+ curl -fL "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz" -o python.tar.xz; \
246
+ curl -fL "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz.asc" -o python.tar.xz.asc; \
247
+ export GNUPGHOME="$(mktemp -d)"; \
248
+ # gpg: key F73C700D: public key "Larry Hastings <larry@hastings.org>" imported
249
+ gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 97FC712E4C024BBEA48A61ED3A5CA953F73C700D; \
250
+ gpg --batch --verify python.tar.xz.asc python.tar.xz; \
251
+ rm -r "$GNUPGHOME" python.tar.xz.asc; \
252
+ echo "$PYTHON_DOWNLOAD_SHA512 *python.tar.xz" | sha512sum --strict --check; \
253
+ # install
254
+ ```
255
+
256
+ - **Alternate**: *full key fingerprint imported to apt which will check signatures and checksums when packages are downloaded and installed.*
257
+
258
+ ```Dockerfile
259
+ RUN set -eux; \
260
+ key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \
261
+ export GNUPGHOME="$(mktemp -d)"; \
262
+ gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key"; \
263
+ gpg --batch --armor --export "$key" > /etc/apt/keyrings/mysql.asc; \
264
+ gpgconf --kill all; \
265
+ rm -rf "$GNUPGHOME"; \
266
+ apt-key list > /dev/null
267
+
268
+ RUN set -eux; \
269
+ echo "deb [ signed-by=/etc/apt/keyrings/mysql.asc ] http://repo.mysql.com/apt/debian/ bookworm mysql-${MYSQL_MAJOR}" > /etc/apt/sources.list.d/mysql.list; \
270
+ apt-get update; \
271
+ apt-get install -y mysql-community-client="${MYSQL_VERSION}" mysql-community-server-core="${MYSQL_VERSION}"; \
272
+ rm -rf /var/lib/apt/lists/*; \
273
+ # ...
274
+ ```
275
+
276
+ (As a side note, `rm -rf /var/lib/apt/lists/*` is *roughly* the opposite of `apt-get update` -- it ensures that the layer doesn't include the extra ~8MB of APT package list data, and enforces [appropriate `apt-get update` usage](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#apt-get).)
277
+
278
+ - **Less Secure Alternate**: *embed the checksum into the `Dockerfile`.*
279
+
280
+ ```Dockerfile
281
+ ENV RUBY_DOWNLOAD_SHA256 (sha256-value-here)
282
+ RUN set -eux; \
283
+ curl -fL -o ruby.tar.gz "https://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_VERSION.tar.gz"; \
284
+ echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.gz" | sha256sum --strict --check; \
285
+ # install
286
+ ```
287
+
288
+ - **Note:** the use of either SHA1 or MD5 should be considered a "checksum of last resort" as both are considered generally unsafe:
289
+
290
+ - ["Single-block collision for MD5" from 2012](https://marc-stevens.nl/research/md5-1block-collision/)
291
+ - ["Announcing the first SHA1 collision" from 2017](https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html)
292
+
293
+ - **Unacceptable**: *download the file over http(s) with no verification.*
294
+
295
+ ```Dockerfile
296
+ RUN curl -fL "https://julialang.s3.amazonaws.com/bin/linux/x64/${JULIA_VERSION%[.-]*}/julia-${JULIA_VERSION}-linux-x86_64.tar.gz" | tar ... \
297
+ # install
298
+ ```
299
+
300
+ ##### Runtime Configuration
301
+
302
+ By default, Docker containers are executed with reduced privileges: whitelisted Linux capabilities, Control Groups, and a default Seccomp profile (1.10+ w/ host support). Software running in a container may require additional privileges in order to function correctly, and there are a number of command line options to customize container execution. See [`docker run` Reference](https://docs.docker.com/engine/reference/run/) and [Seccomp for Docker](https://docs.docker.com/engine/security/seccomp/) for reference.
303
+
304
+ Official Repositories that require additional privileges should specify the minimal set of command line options for the software to function, and may still be rejected if this introduces significant portability or security issues. In general, `--privileged` is not allowed, but a combination of `--cap-add` and `--device` options may be acceptable. Additionally, `--volume` can be tricky as there are many host filesystem locations that introduce portability/security issues (e.g. X11 socket).
305
+
306
+ ##### Security Releases
307
+
308
+ For image updates which constitute a security fix, there are a few things we recommend to help ensure your update is merged, built, and released as quickly as possible:
309
+
310
+ 1. [Send an email to `doi@docker.com`](mailto:doi@docker.com) a few (business) days in advance to give us a heads up and a timing estimate (so we can schedule time for the incoming update appropriately).
311
+ 2. Include `[security]` in the title of your pull request (for example, `[security] Update FooBar to 1.2.5, 1.3.7, 2.0.1`).
312
+ 3. Keep the pull request free of changes that are unrelated to the security fix -- we'll still be doing review of the update, but it will be expedited so this will help us help you.
313
+ 4. Be active and responsive to comments on the pull request after it's opened (as usual, but even more so if the timing of the release is of importance).
314
+
315
+ #### Multiple Architectures
316
+
317
+ Each repo can specify multiple architectures for any and all tags. If no architecture is specified, images are built in Linux on `amd64` (aka x86-64). To specify more or different architectures, use the `Architectures` field (comma-delimited list, whitespace is trimmed). Valid architectures are found in [Bashbrew's `oci-platform.go` file](https://github.com/docker-library/bashbrew/blob/v0.1.2/architecture/oci-platform.go#L14-L27):
318
+
319
+ - `amd64`
320
+ - `arm32v6`
321
+ - `arm32v7`
322
+ - `arm64v8`
323
+ - `i386`
324
+ - `ppc64le`
325
+ - `riscv64`
326
+ - `s390x`
327
+ - `windows-amd64`
328
+
329
+ The `Architectures` of any given tag must be a strict subset of the `Architectures` of the tag it is `FROM`.
330
+
331
+ Images must have a single `Dockerfile` per entry in the library file that can be used for multiple architectures. This means that each supported architecture will have the same `FROM` line (e.g. `FROM debian:bookworm`). See [`golang`](https://github.com/docker-library/official-images/blob/master/library/golang), [`docker`](https://github.com/docker-library/official-images/blob/master/library/docker), [`haproxy`](https://github.com/docker-library/official-images/blob/master/library/haproxy), and [`php`](https://github.com/docker-library/official-images/blob/master/library/php) for examples of library files using one `Dockerfile` per entry and see their respective git repos for example `Dockerfile`s.
332
+
333
+ If different parts of the Dockerfile only happen in one architecture or another, use control flow (e.g.`if`/`case`) along with `dpkg --print-architecture` or `apk -print-arch` to detect the userspace architecture. Only use `uname` for architecture detection when more accurate tools cannot be installed. See [golang](https://github.com/docker-library/golang/blob/72bc141d781ae54ef20f71aa1105449cb6c2edc4/1.20/bookworm/Dockerfile#L26-L63) for an example where some architectures require building binaries from the upstream source packages and some merely download the binary release.
334
+
335
+ For base images like `debian` it will be necessary to have a different `Dockerfile` and build context in order to `ADD` architecture specific binaries and this is a valid exception to the above. Since these images use the same `Tags`, they need to be in the same entry. Use the architecture specific fields for `GitRepo`, `GitFetch`, `GitCommit`, and `Directory`, which are the architecture concatenated with hyphen (`-`) and the field (e.g. `arm32v7-GitCommit`). Any architecture that does not have an architecture-specific field will use the default field (e.g. no `arm32v7-Directory` means `Directory` will be used for `arm32v7`). See the [`debian`](https://github.com/docker-library/official-images/blob/master/library/debian) or [`ubuntu`](https://github.com/docker-library/official-images/blob/master/library/ubuntu) files in the library for examples. The following is an example for [`hello-world`](https://github.com/docker-library/official-images/blob/master/library/hello-world):
336
+
337
+ ```
338
+ Maintainers: Tianon Gravi <admwiggin@gmail.com> (@tianon),
339
+ Joseph Ferguson <yosifkit@gmail.com> (@yosifkit)
340
+ GitRepo: https://github.com/docker-library/hello-world.git
341
+ GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87
342
+
343
+ Tags: latest
344
+ Architectures: amd64, arm32v5, arm32v7, arm64v8, ppc64le, s390x
345
+ # all the same commit; easy for us to generate this way since they could be different
346
+ amd64-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87
347
+ amd64-Directory: amd64/hello-world
348
+ arm32v5-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87
349
+ arm32v5-Directory: arm32v5/hello-world
350
+ arm32v7-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87
351
+ arm32v7-Directory: arm32v7/hello-world
352
+ arm64v8-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87
353
+ arm64v8-Directory: arm64v8/hello-world
354
+ ppc64le-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87
355
+ ppc64le-Directory: ppc64le/hello-world
356
+ s390x-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87
357
+ s390x-Directory: s390x/hello-world
358
+
359
+ Tags: nanoserver
360
+ Architectures: windows-amd64
361
+ # if there is only one architecture, you can use the unprefixed fields
362
+ Directory: amd64/hello-world/nanoserver
363
+ # or use the prefixed versions
364
+ windows-amd64-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87
365
+ Constraints: nanoserver
366
+ ```
367
+
368
+ See the [instruction format section](#instruction-format) for more information on the format of the library file.
369
+
370
+ ### Commitment
371
+
372
+ Proposing a new official image should not be undertaken lightly. We expect and require a commitment to maintain your image (including and especially timely updates as appropriate, as noted above).
373
+
374
+ ## Library definition files
375
+
376
+ The library definition files are plain text files found in the [`library/` directory of the `official-images` repository](https://github.com/docker-library/official-images/tree/master/library). Each library file controls the current "supported" set of image tags that appear on the Docker Hub description. Tags that are removed from a library file do not get removed from the Docker Hub, so that old versions can continue to be available for use, but are not maintained by upstream or the maintainer of the official image. Tags in the library file are only built through an update to that library file or as a result of its base image being updated (ie, an image `FROM debian:bookworm` would be rebuilt when `debian:bookworm` is built). Only what is in the library file will be rebuilt when a base has updates.
377
+
378
+ Given this policy, it is worth clarifying a few cases: backfilled versions, release candidates, and continuous integration builds. When a new repository is proposed, it is common to include some older unsupported versions in the initial pull request with the agreement to remove them right after acceptance. Don't confuse this with a comprehensive historical archive which is not the intention. Another common case where the term "supported" is stretched a bit is with release candidates. A release candidate is really just a naming convention for what are expected to be shorter-lived releases, so they are totally acceptable and encouraged. Unlike a release candidate, continuous integration builds which have a fully automated release cycle based on code commits or a regular schedule are not appropriate.
379
+
380
+ It is highly recommended that you browse some of the existing `library/` file contents (and history to get a feel for how they change over time) before creating a new one to become familiar with the prevailing conventions and further help streamline the review process (so that we can focus on content instead of esoteric formatting or tag usage/naming).
381
+
382
+ ### Filenames
383
+
384
+ The filename of a definition file will determine the name of the image repository it creates on the Docker Hub. For example, the `library/ubuntu` file will create tags in the `ubuntu` repository.
385
+
386
+ ### Tags and aliases
387
+
388
+ The tags of a repository should reflect upstream's versions or variations. For example, Ubuntu 14.04 is also known as Ubuntu Trusty Tahr, but often as simply Ubuntu Trusty (especially in usage), so `ubuntu:14.04` (version number) and `ubuntu:trusty` (version name) are appropriate aliases for the same image contents. In Docker, the `latest` tag is a special case, but it's a bit of a misnomer; `latest` really is the "default" tag. When one does `docker run xyz`, Docker interprets that to mean `docker run xyz:latest`. Given that background, no other tag ever contains the string `latest`, since it's not something users are expected or encouraged to actually type out (ie, `xyz:latest` should really be used as simply `xyz`). Put another way, having an alias for the "highest 2.2-series release of XYZ" should be `xyz:2.2`, not `xyz:2.2-latest`. Similarly, if there is an Alpine variant of `xyz:latest`, it should be aliased as `xyz:alpine`, not `xyz:alpine-latest` or `xyz:latest-alpine`.
389
+
390
+ It is strongly encouraged that version number tags be given aliases which make it easy for the user to stay on the "most recent" release of a particular series. For example, given currently supported XYZ Software versions of 2.3.7 and 2.2.4, suggested aliases would be `Tags: 2.3.7, 2.3, 2, latest` and `Tags: 2.2.4, 2.2`, respectively. In this example, the user can use `xyz:2.2` to easily use the most recent patch release of the 2.2 series, or `xyz:2` if less granularity is needed (Python is a good example of where that's most obviously useful -- `python:2` and `python:3` are very different, and can be thought of as the `latest` tag for each of the major release tracks of Python).
391
+
392
+ As described above, `latest` is really "default", so the image that it is an alias for should reflect which version or variation of the software users should use if they do not know or do not care which version they use. Using Ubuntu as an example, `ubuntu:latest` points to the most recent LTS release, given that it is what the majority of users should be using if they know they want Ubuntu but do not know or care which version (especially considering it will be the most "stable" and well-supported release at any given time).
393
+
394
+ ### Instruction format
395
+
396
+ The manifest file format is officially based on [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt), and as such should be familiar to folks who are already familiar with the "headers" of many popular internet protocols/formats such as HTTP or email.
397
+
398
+ The primary additions are inspired by the way Debian commonly uses 2822 -- namely, lines starting with `#` are ignored and "entries" are separated by a blank line.
399
+
400
+ The first entry is the "global" metadata for the image. The only required field in the global entry is `Maintainers`, whose value is comma-separated in the format of `Name <email> (@github)` or `Name (@github)`. Any field specified in the global entry will be the default for the rest of the entries and can be overridden in an individual entry.
401
+
402
+ # this is a comment and will be ignored
403
+ Maintainers: John Smith <jsmith@example.com> (@example-jsmith),
404
+ Anne Smith <asmith@example.com> (@example-asmith)
405
+ GitRepo: https://github.com/example/docker-example.git
406
+ GitCommit: deadbeefdeadbeefdeadbeefdeadbeefdeadbeef
407
+
408
+ # this is also a comment, and will also be ignored
409
+
410
+ Tags: 1.2.3, 1.2, 1, latest
411
+ Directory: 1
412
+
413
+ Tags: 2.0-rc1, 2.0-rc, 2-rc, rc
414
+ GitRepo: https://github.com/example/docker-example-rc.git
415
+ GitFetch: refs/heads/2.0-pre-release
416
+ GitCommit: beefdeadbeefdeadbeefdeadbeefdeadbeefdead
417
+ Directory: 2
418
+ File: Dockerfile-to-use
419
+
420
+ Bashbrew will fetch code out of the Git repository (`GitRepo`) at the commit specified (`GitCommit`). If the commit referenced is not available by fetching `master` of the associated `GitRepo`, it becomes necessary to supply a value for `GitFetch` in order to tell Bashbrew what ref to fetch in order to get the commit necessary.
421
+
422
+ The built image will be tagged as `<manifest-filename>:<tag>` (ie, `library/golang` with a `Tags` value of `1.6, 1, latest` will create tags of `golang:1.6`, `golang:1`, and `golang:latest`).
423
+
424
+ Optionally, if `Directory` is present, Bashbrew will look for the `Dockerfile` inside the specified subdirectory instead of at the root (and `Directory` will be used as the ["context" for the build](https://docs.docker.com/reference/builder/) instead of the top-level of the repository). If `File` is present, the specified filename instead of `Dockerfile` will be used.
425
+
426
+ See the [multi-arch section](#multiple-architectures) for details on how to specify a different `GitRepo`, `GitFetch`, `GitCommit`, or `Directory` for a specific architecture.
427
+
428
+ ### Creating a new repository
429
+
430
+ - Create a new file in the `library/` folder. Its name will be the name of your repository on the Hub.
431
+ - Add your tag definitions using the appropriate syntax (see above).
432
+ - Create a pull request adding the file from your forked repository to this one. Please be sure to add details as to what your repository does.
433
+
434
+ ### Adding a new tag in an existing repository (that you're the maintainer of)
435
+
436
+ - Add your tag definition using the instruction format documented above.
437
+ - Create a pull request from your Git repository to this one. Please be sure to add details about what's new, if possible.
438
+
439
+ ### Change to a tag in an existing repository (that you're the maintainer of)
440
+
441
+ - Update the relevant tag definition using the instruction format documented above.
442
+ - Create a pull request from your Git repository to this one. Please be sure to add details about what's changed, if possible.
443
+
444
+ ## Bashbrew
445
+
446
+ Bashbrew (`bashbrew`) is a tool for cloning, building, tagging, and pushing the Docker official images. See [the Bashbrew `README`](https://github.com/docker-library/bashbrew#readme) for more information.
447
+ ```
20260907-002128-computing-math-734953/environment/public_data/input/dockerfile_text_windows.csv ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ window_id,start_word,end_word,text,contains_code_term,matched_required_terms
2
+ 1,0,40,"# Source 1: README.md - URL: https://raw.githubusercontent.com/docker-library/official-images/master/README.md - SHA256: 7b092c41c25d31902face488f7a5ed9928abb002548b1e3d64ee318afbbd2acf - Bytes: 34724 ```markdown # Docker Official Images ## Table of Contents 1. [Docker Official Images](#docker-official-images) 1. [Table of Contents](#table-of-contents) 2. [What are ""Official Images""?](#what-are-official-images) 3. [Architectures other than amd64?](#architectures-other-than-amd64)",false,
3
+ 2,20,60,"of Contents 1. [Docker Official Images](#docker-official-images) 1. [Table of Contents](#table-of-contents) 2. [What are ""Official Images""?](#what-are-official-images) 3. [Architectures other than amd64?](#architectures-other-than-amd64) 4. [More FAQs?](#more-faqs) 5. [Contributing to the standard library](#contributing-to-the-standard-library) 1. [Review Guidelines](#review-guidelines) 1. [Maintainership](#maintainership) 2. [Repeatability](#repeatability) 3. [Consistency](#consistency) 4. [Clarity](#clarity)",false,
4
+ 3,40,80,4. [More FAQs?](#more-faqs) 5. [Contributing to the standard library](#contributing-to-the-standard-library) 1. [Review Guidelines](#review-guidelines) 1. [Maintainership](#maintainership) 2. [Repeatability](#repeatability) 3. [Consistency](#consistency) 4. [Clarity](#clarity) 5. [init](#init) 6. [Cacheability](#cacheability) 7. [Security](#security) 1. [Image Build](#image-build) 2. [Runtime Configuration](#runtime-configuration) 3. [Security Releases](#security-releases) 8. [Multiple Architectures](#multiple-architectures) 2. [Commitment](#commitment),true,RUN
5
+ 4,60,100,5. [init](#init) 6. [Cacheability](#cacheability) 7. [Security](#security) 1. [Image Build](#image-build) 2. [Runtime Configuration](#runtime-configuration) 3. [Security Releases](#security-releases) 8. [Multiple Architectures](#multiple-architectures) 2. [Commitment](#commitment) 6. [Library definition files](#library-definition-files) 1. [Filenames](#filenames) 2. [Tags and aliases](#tags-and-aliases) 3. [Instruction format](#instruction-format) 4. [Creating a new repository](#creating-a-new-repository) 5. [Adding,true,RUN|Tags
6
+ 5,80,120,6. [Library definition files](#library-definition-files) 1. [Filenames](#filenames) 2. [Tags and aliases](#tags-and-aliases) 3. [Instruction format](#instruction-format) 4. [Creating a new repository](#creating-a-new-repository) 5. [Adding a new tag in an existing repository (that you're the maintainer of)](#adding-a-new-tag-in-an-existing-repository-that-youre-the-maintainer-of) 6. [Change to a tag in an existing,false,Tags
7
+ 6,100,140,"a new tag in an existing repository (that you're the maintainer of)](#adding-a-new-tag-in-an-existing-repository-that-youre-the-maintainer-of) 6. [Change to a tag in an existing repository (that you're the maintainer of)](#change-to-a-tag-in-an-existing-repository-that-youre-the-maintainer-of) 7. [Bashbrew](#bashbrew) ## What are ""Official Images""? The Docker Official Images are curated images",false,
8
+ 7,120,160,"repository (that you're the maintainer of)](#change-to-a-tag-in-an-existing-repository-that-youre-the-maintainer-of) 7. [Bashbrew](#bashbrew) ## What are ""Official Images""? The Docker Official Images are curated images [hosted on Docker Hub](https://hub.docker.com/u/library). The main tenets are: - Focus on [Free](https://www.debian.org/social_contract#guidelines) and [Open-Source](https://opensource.org/) Software - Support [multiple architectures](#architectures-other-than-amd64) -",false,
9
+ 8,140,180,[hosted on Docker Hub](https://hub.docker.com/u/library). The main tenets are: - Focus on [Free](https://www.debian.org/social_contract#guidelines) and [Open-Source](https://opensource.org/) Software - Support [multiple architectures](#architectures-other-than-amd64) - Exemplify [`Dockerfile` best practices](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/) - [Actively rebuild](#library-definition-files) for updates and security fixes - Adhere to upstream recommendations - Add minimal,false,Dockerfile
10
+ 9,160,200,Exemplify [`Dockerfile` best practices](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/) - [Actively rebuild](#library-definition-files) for updates and security fixes - Adhere to upstream recommendations - Add minimal quality-of-life behavior for the container environment where fit See [Docker's documentation](https://docs.docker.com/docker-hub/official_repos/) for a good high-level overview of the program. In,true,Dockerfile|ENV
11
+ 10,180,220,quality-of-life behavior for the container environment where fit See [Docker's documentation](https://docs.docker.com/docker-hub/official_repos/) for a good high-level overview of the program. In essence we strive to heed upstream's recommendations on how they intend for their software to be consumed. Many images are,true,ENV
12
+ 11,200,240,essence we strive to heed upstream's recommendations on how they intend for their software to be consumed. Many images are maintained in collaboration with the relevant upstream project if not maintained directly by them. Additionally we aim to exemplify the,false,
13
+ 12,220,260,maintained in collaboration with the relevant upstream project if not maintained directly by them. Additionally we aim to exemplify the best practices for Dockerfiles to serve as a reference when making or deriving your own images from them. (If you,true,Dockerfile|FROM
14
+ 13,240,280,"best practices for Dockerfiles to serve as a reference when making or deriving your own images from them. (If you are a representative of an upstream for which there exists an image and you would like to get involved, please",true,Dockerfile|FROM
15
+ 14,260,300,"are a representative of an upstream for which there exists an image and you would like to get involved, please see the [Maintainership](#maintainership) section below!) ## Architectures other than amd64? Some images have been ported for other architectures, and many",false,
16
+ 15,280,320,"see the [Maintainership](#maintainership) section below!) ## Architectures other than amd64? Some images have been ported for other architectures, and many of these are officially supported (to various degrees). - Architectures officially supported by Docker, Inc. for running Docker: (see [download.docker.com](https://download.docker.com/linux/))",true,RUN
17
+ 16,300,340,"of these are officially supported (to various degrees). - Architectures officially supported by Docker, Inc. for running Docker: (see [download.docker.com](https://download.docker.com/linux/)) - ARMv6 32-bit (`arm32v6`): https://hub.docker.com/u/arm32v6/ - ARMv7 32-bit (`arm32v7`): https://hub.docker.com/u/arm32v7/ - ARMv8 64-bit (`arm64v8`): https://hub.docker.com/u/arm64v8/ - Linux x86-64 (`amd64`): https://hub.docker.com/u/amd64/",true,RUN
18
+ 17,320,360,"- ARMv6 32-bit (`arm32v6`): https://hub.docker.com/u/arm32v6/ - ARMv7 32-bit (`arm32v7`): https://hub.docker.com/u/arm32v7/ - ARMv8 64-bit (`arm64v8`): https://hub.docker.com/u/arm64v8/ - Linux x86-64 (`amd64`): https://hub.docker.com/u/amd64/ - Windows x86-64 (`windows-amd64`): https://hub.docker.com/u/winamd64/ - Other architectures built by official images: (but *not* officially supported by Docker, Inc.) -",false,
19
+ 18,340,380,"- Windows x86-64 (`windows-amd64`): https://hub.docker.com/u/winamd64/ - Other architectures built by official images: (but *not* officially supported by Docker, Inc.) - ARMv5 32-bit (`arm32v5`): https://hub.docker.com/u/arm32v5/ - IBM POWER8 (`ppc64le`): https://hub.docker.com/u/ppc64le/ - IBM z Systems (`s390x`): https://hub.docker.com/u/s390x/ - RISC-V 64-bit (`riscv64`): https://hub.docker.com/u/riscv64/",false,
20
+ 19,360,400,"ARMv5 32-bit (`arm32v5`): https://hub.docker.com/u/arm32v5/ - IBM POWER8 (`ppc64le`): https://hub.docker.com/u/ppc64le/ - IBM z Systems (`s390x`): https://hub.docker.com/u/s390x/ - RISC-V 64-bit (`riscv64`): https://hub.docker.com/u/riscv64/ - x86/i686 (`i386`): https://hub.docker.com/u/i386/ These other architectures are included under the non-prefixed images via [OCI ""image indexes""](https://github.com/opencontainers/image-spec/blob/v1.1.1/image-index.md), such that, for",false,
21
+ 20,380,420,"- x86/i686 (`i386`): https://hub.docker.com/u/i386/ These other architectures are included under the non-prefixed images via [OCI ""image indexes""](https://github.com/opencontainers/image-spec/blob/v1.1.1/image-index.md), such that, for example, `docker run hello-world` should run as-is on all supported platforms. If you're curious about how these are built, head",true,RUN
22
+ 21,400,440,"example, `docker run hello-world` should run as-is on all supported platforms. If you're curious about how these are built, head over to [our FAQ entry](https://github.com/docker-library/faq#an-images-source-changed-in-git-now-what) to see an explanation of the process or visit [meta-scripts](https://github.com/docker-library/meta-scripts) to see the build process",true,RUN
23
+ 22,420,460,over to [our FAQ entry](https://github.com/docker-library/faq#an-images-source-changed-in-git-now-what) to see an explanation of the process or visit [meta-scripts](https://github.com/docker-library/meta-scripts) to see the build process source files. See the [multi-arch section](#multiple-architectures) below for recommendations in adding more architectures to an official image. ## More FAQs?,false,
24
+ 23,440,480,source files. See the [multi-arch section](#multiple-architectures) below for recommendations in adding more architectures to an official image. ## More FAQs? Yes! We have [a dedicated FAQ repository](https://github.com/docker-library/faq) where we try to collect other common questions (both about the program and,false,
25
+ 24,460,500,Yes! We have [a dedicated FAQ repository](https://github.com/docker-library/faq) where we try to collect other common questions (both about the program and about our practices). ## Contributing to the standard library Thank you for your interest in the Docker official images project!,false,
26
+ 25,480,520,"about our practices). ## Contributing to the standard library Thank you for your interest in the Docker official images project! We strive to make these instructions as simple and straightforward as possible, but if you find yourself lost, don't hesitate",false,
27
+ 26,500,540,"We strive to make these instructions as simple and straightforward as possible, but if you find yourself lost, don't hesitate to seek us out on [Libera.Chat IRC](https://libera.chat) in channel `#docker-library` or by creating a GitHub issue here. Be sure to",false,
28
+ 27,520,560,to seek us out on [Libera.Chat IRC](https://libera.chat) in channel `#docker-library` or by creating a GitHub issue here. Be sure to familiarize yourself with [Official Repositories on Docker Hub](https://docs.docker.com/docker-hub/official_repos/) and the [Best practices for writing Dockerfiles](https://docs.docker.com/articles/dockerfile_best-practices/) in the Docker documentation. These,false,Dockerfile
29
+ 28,540,580,familiarize yourself with [Official Repositories on Docker Hub](https://docs.docker.com/docker-hub/official_repos/) and the [Best practices for writing Dockerfiles](https://docs.docker.com/articles/dockerfile_best-practices/) in the Docker documentation. These will be the foundation of the review process performed by the official images maintainers. If you'd like the review process,false,Dockerfile
30
+ 29,560,600,"will be the foundation of the review process performed by the official images maintainers. If you'd like the review process to go more smoothly, please ensure that your `Dockerfile`s adhere to all the points mentioned there, as well as [below](README.md#review-guidelines),",false,Dockerfile
31
+ 30,580,620,"to go more smoothly, please ensure that your `Dockerfile`s adhere to all the points mentioned there, as well as [below](README.md#review-guidelines), before submitting a pull request. Also, the Hub descriptions for these images are currently stored separately in the [`docker-library/docs` repository](https://github.com/docker-library/docs),",false,Dockerfile
32
+ 31,600,640,"before submitting a pull request. Also, the Hub descriptions for these images are currently stored separately in the [`docker-library/docs` repository](https://github.com/docker-library/docs), whose [`README.md` file](https://github.com/docker-library/docs/blob/master/README.md) explains more about how it's structured and how to contribute to it. Please be prepared to submit",false,
33
+ 32,620,660,"whose [`README.md` file](https://github.com/docker-library/docs/blob/master/README.md) explains more about how it's structured and how to contribute to it. Please be prepared to submit a PR there as well, pending acceptance of your image here. ### Review Guidelines Because the official images are intended",false,
34
+ 33,640,680,"a PR there as well, pending acceptance of your image here. ### Review Guidelines Because the official images are intended to be learning tools for those new to Docker as well as the base images for advanced users to build",false,
35
+ 34,660,700,"to be learning tools for those new to Docker as well as the base images for advanced users to build their production releases, we review each proposed `Dockerfile` to ensure that it meets a minimum standard for quality and maintainability.",false,Dockerfile
36
+ 35,680,720,"their production releases, we review each proposed `Dockerfile` to ensure that it meets a minimum standard for quality and maintainability. While some of that standard is hard to define (due to subjectivity), as much as possible is defined here, while",false,Dockerfile
37
+ 36,700,740,"While some of that standard is hard to define (due to subjectivity), as much as possible is defined here, while also adhering to the ""Best Practices"" where appropriate. A checklist which may be used by the maintainers during review can",false,
38
+ 37,720,760,"also adhering to the ""Best Practices"" where appropriate. A checklist which may be used by the maintainers during review can be found in [`NEW-IMAGE-CHECKLIST.md`](NEW-IMAGE-CHECKLIST.md). #### Maintainership Version bumps and security fixes should be attended to in a timely manner. If",false,
39
+ 38,740,780,"be found in [`NEW-IMAGE-CHECKLIST.md`](NEW-IMAGE-CHECKLIST.md). #### Maintainership Version bumps and security fixes should be attended to in a timely manner. If you do not represent upstream and upstream becomes interested in maintaining the image, steps should be taken to ensure a",false,
40
+ 39,760,800,"you do not represent upstream and upstream becomes interested in maintaining the image, steps should be taken to ensure a smooth transition of image maintainership over to upstream. For upstreams interested in taking over maintainership of an existing repository, the",false,
41
+ 40,780,820,"smooth transition of image maintainership over to upstream. For upstreams interested in taking over maintainership of an existing repository, the first step is to get involved in the existing repository. Making comments on issues, proposing changes, and making yourself known",false,
42
+ 41,800,840,"first step is to get involved in the existing repository. Making comments on issues, proposing changes, and making yourself known within the ""image community"" (even if that ""community"" is just the current maintainer) are all important places to start to",false,
43
+ 42,820,860,"within the ""image community"" (even if that ""community"" is just the current maintainer) are all important places to start to ensure that the transition is unsurprising to existing contributors and users. When taking over an existing repository, please ensure that",false,
44
+ 43,840,880,"ensure that the transition is unsurprising to existing contributors and users. When taking over an existing repository, please ensure that the entire Git history of the original repository is kept in the new upstream-maintained repository to make sure the review",false,
45
+ 44,860,900,"the entire Git history of the original repository is kept in the new upstream-maintained repository to make sure the review process isn't stalled during the transition. This is most easily accomplished by forking the new from the existing repository, but",true,FROM
46
+ 45,880,920,"process isn't stalled during the transition. This is most easily accomplished by forking the new from the existing repository, but can also be accomplished by fetching the commits directly from the original and pushing them into the new repo (ie,",true,FROM
47
+ 46,900,940,"can also be accomplished by fetching the commits directly from the original and pushing them into the new repo (ie, `git fetch https://github.com/jsmith/example.git master`, `git rebase FETCH_HEAD`, `git push -f`). On GitHub, an alternative is to move ownership of the",true,FROM
48
+ 47,920,960,"`git fetch https://github.com/jsmith/example.git master`, `git rebase FETCH_HEAD`, `git push -f`). On GitHub, an alternative is to move ownership of the git repository. This can be accomplished without giving either group admin access to the other owner's repository: - create temporary",false,
49
+ 48,940,980,git repository. This can be accomplished without giving either group admin access to the other owner's repository: - create temporary intermediary organization - [docker-library-transitioner](https://github.com/docker-library-transitioner) is available for this purpose if you would like our help - give old and new,false,
50
+ 49,960,1000,intermediary organization - [docker-library-transitioner](https://github.com/docker-library-transitioner) is available for this purpose if you would like our help - give old and new owners admin access to intermediary organization - old owner transfers repo ownership to intermediary organization - new owner transfers repo,false,
51
+ 50,980,1020,owners admin access to intermediary organization - old owner transfers repo ownership to intermediary organization - new owner transfers repo ownership to its new home - recommend that old owner does not fork new repo back into the old organization,false,
52
+ 51,1000,1040,ownership to its new home - recommend that old owner does not fork new repo back into the old organization to ensure that GitHub redirects will just work #### Repeatability Rebuilding the same `Dockerfile` should result in the same version,false,Dockerfile
53
+ 52,1020,1060,"to ensure that GitHub redirects will just work #### Repeatability Rebuilding the same `Dockerfile` should result in the same version of the image being packaged, even if the second build happens several versions later, or the build should fail outright,",false,Dockerfile
54
+ 53,1040,1080,"of the image being packaged, even if the second build happens several versions later, or the build should fail outright, such that an inadvertent rebuild of a `Dockerfile` tagged as `0.1.0` doesn't end up containing `0.2.3`. For example, if using",false,Dockerfile
55
+ 54,1060,1100,"such that an inadvertent rebuild of a `Dockerfile` tagged as `0.1.0` doesn't end up containing `0.2.3`. For example, if using `apt` to install the main program for the image, be sure to pin it to a specific version (ex: `...",false,Dockerfile
56
+ 55,1080,1120,"`apt` to install the main program for the image, be sure to pin it to a specific version (ex: `... apt-get install -y my-package=0.1.0 ...`). For dependent packages installed by `apt` there is not usually a need to pin them",true,
57
+ 56,1100,1140,"apt-get install -y my-package=0.1.0 ...`). For dependent packages installed by `apt` there is not usually a need to pin them to a version. No official images can be derived from, or depend on, non-official images (allowing the non-image [`scratch`](https://hub.docker.com/_/scratch/) and",true,FROM
58
+ 57,1120,1160,"to a version. No official images can be derived from, or depend on, non-official images (allowing the non-image [`scratch`](https://hub.docker.com/_/scratch/) and the intentionally limited exceptions pinned in [`.external-pins`](.external-pins) -- see also [`.external-pins/list.sh`](.external-pins/list.sh)). #### Consistency All official images should provide a consistent",true,FROM
59
+ 58,1140,1180,the intentionally limited exceptions pinned in [`.external-pins`](.external-pins) -- see also [`.external-pins/list.sh`](.external-pins/list.sh)). #### Consistency All official images should provide a consistent interface. A beginning user should be able to `docker run official-image bash` (or `sh`) without needing to learn about `--entrypoint`.,true,RUN|ENTRYPOINT
60
+ 59,1160,1200,"interface. A beginning user should be able to `docker run official-image bash` (or `sh`) without needing to learn about `--entrypoint`. It is also nice for advanced users to take advantage of entrypoint, so that they can `docker run official-image --arg1",true,RUN|ENTRYPOINT
61
+ 60,1180,1220,"It is also nice for advanced users to take advantage of entrypoint, so that they can `docker run official-image --arg1 --arg2` without having to specify the binary to execute. 1. If the startup process does not need arguments, just use",true,RUN|ENTRYPOINT
62
+ 61,1200,1240,"--arg2` without having to specify the binary to execute. 1. If the startup process does not need arguments, just use `CMD`: ```Dockerfile CMD [""irb""] ``` 2. If there is initialization that needs to be done on start, like creating the",false,Dockerfile
63
+ 62,1220,1260,"`CMD`: ```Dockerfile CMD [""irb""] ``` 2. If there is initialization that needs to be done on start, like creating the initial database, use an `ENTRYPOINT` along with `CMD`: ```Dockerfile ENTRYPOINT [""/docker-entrypoint.sh""] CMD [""postgres""] ``` 1. Ensure that `docker run official-image",true,Dockerfile|RUN|ENTRYPOINT
64
+ 63,1240,1280,"initial database, use an `ENTRYPOINT` along with `CMD`: ```Dockerfile ENTRYPOINT [""/docker-entrypoint.sh""] CMD [""postgres""] ``` 1. Ensure that `docker run official-image bash` (or `sh`) works too. The easiest way is to check for the expected command and if it is something",true,Dockerfile|RUN|ENTRYPOINT
65
+ 64,1260,1300,"bash` (or `sh`) works too. The easiest way is to check for the expected command and if it is something else, just `exec ""$@""` (run whatever was passed, properly keeping the arguments escaped). ```sh #!/bin/sh set -e # this if",true,RUN
66
+ 65,1280,1320,"else, just `exec ""$@""` (run whatever was passed, properly keeping the arguments escaped). ```sh #!/bin/sh set -e # this if will check if the first argument is a flag # but only works if all arguments require a hyphenated flag",true,RUN
67
+ 66,1300,1340,"will check if the first argument is a flag # but only works if all arguments require a hyphenated flag # -v; -SL; -f arg; etc will work, but not arg1 arg2 if [ ""$#"" -eq 0 ] || [",false,
68
+ 67,1320,1360,"# -v; -SL; -f arg; etc will work, but not arg1 arg2 if [ ""$#"" -eq 0 ] || [ ""${1#-}"" != ""$1"" ]; then set -- mongod ""$@"" fi # check for the expected command if [ ""$1"" =",false,
69
+ 68,1340,1380,"""${1#-}"" != ""$1"" ]; then set -- mongod ""$@"" fi # check for the expected command if [ ""$1"" = 'mongod' ]; then # init db stuff.... # use gosu (or su-exec) to drop to a non-root user exec gosu",false,
70
+ 69,1360,1400,"'mongod' ]; then # init db stuff.... # use gosu (or su-exec) to drop to a non-root user exec gosu mongod ""$@"" fi # else default to run whatever the user wanted like ""bash"" or ""sh"" exec ""$@"" ``` 3.",true,RUN
71
+ 70,1380,1420,"mongod ""$@"" fi # else default to run whatever the user wanted like ""bash"" or ""sh"" exec ""$@"" ``` 3. If the image only contains the main executable and its linked libraries (ie no shell) then it is fine to",true,RUN
72
+ 71,1400,1440,"If the image only contains the main executable and its linked libraries (ie no shell) then it is fine to use the executable as the `ENTRYPOINT`, since that is the only thing that can run: ```Dockerfile ENTRYPOINT [""fully-static-binary""] CMD [""--help""]",true,Dockerfile|RUN|ENTRYPOINT
73
+ 72,1420,1460,"use the executable as the `ENTRYPOINT`, since that is the only thing that can run: ```Dockerfile ENTRYPOINT [""fully-static-binary""] CMD [""--help""] ``` The most common indicator of whether this is appropriate is that the image `Dockerfile` starts with [`scratch`](https://registry.hub.docker.com/_/scratch/) (`FROM scratch`).",true,Dockerfile|FROM|RUN|ENTRYPOINT
74
+ 73,1440,1480,"``` The most common indicator of whether this is appropriate is that the image `Dockerfile` starts with [`scratch`](https://registry.hub.docker.com/_/scratch/) (`FROM scratch`). #### Clarity Try to make the `Dockerfile` easy to understand/read. It may be tempting, for the sake of brevity, to",true,Dockerfile|FROM
75
+ 74,1460,1500,"#### Clarity Try to make the `Dockerfile` easy to understand/read. It may be tempting, for the sake of brevity, to put complicated initialization details into a standalone script and merely add a `RUN` command in the `Dockerfile`. However, this causes",true,Dockerfile|RUN
76
+ 75,1480,1520,"put complicated initialization details into a standalone script and merely add a `RUN` command in the `Dockerfile`. However, this causes the resulting `Dockerfile` to be overly opaque, and such `Dockerfile`s are unlikely to pass review. Instead, it is recommended to",true,Dockerfile|RUN
77
+ 76,1500,1540,"the resulting `Dockerfile` to be overly opaque, and such `Dockerfile`s are unlikely to pass review. Instead, it is recommended to put all the commands for initialization into the `Dockerfile` as appropriate `RUN` or `ENV` command combinations. To find good examples,",true,Dockerfile|RUN|ENV
78
+ 77,1520,1560,"put all the commands for initialization into the `Dockerfile` as appropriate `RUN` or `ENV` command combinations. To find good examples, look at the current official images. Some examples at the time of writing: - [php](https://github.com/docker-library/php/blob/b4aeb948e2e240c732d78890ff03285b16e8edda/5.6/Dockerfile) - [python](https://github.com/docker-library/python/blob/3e5826ad0c6e29f07f6dc7ff8f30b4c54385d1bb/3.4/Dockerfile) - [ruby:2.2](https://github.com/docker-library/ruby/blob/e34b201a0f0b49818fc8373f6a9148e13d546bdf/2.2/Dockerfile) ####",true,Dockerfile|RUN|ENV
79
+ 78,1540,1580,look at the current official images. Some examples at the time of writing: - [php](https://github.com/docker-library/php/blob/b4aeb948e2e240c732d78890ff03285b16e8edda/5.6/Dockerfile) - [python](https://github.com/docker-library/python/blob/3e5826ad0c6e29f07f6dc7ff8f30b4c54385d1bb/3.4/Dockerfile) - [ruby:2.2](https://github.com/docker-library/ruby/blob/e34b201a0f0b49818fc8373f6a9148e13d546bdf/2.2/Dockerfile) #### init Following the Docker guidelines it is highly recommended that the resulting image be just one concern per container; predominantly,false,Dockerfile
80
+ 79,1560,1600,"init Following the Docker guidelines it is highly recommended that the resulting image be just one concern per container; predominantly this means just one process per container, so there is no need for a full init system. There are two",false,
81
+ 80,1580,1620,"this means just one process per container, so there is no need for a full init system. There are two situations where an init-like process would be helpful for the container. The first being signal handling. If the process launched",false,
82
+ 81,1600,1640,"situations where an init-like process would be helpful for the container. The first being signal handling. If the process launched does not handle `SIGTERM` by exiting, it will not be killed since it is PID 1 in the container (see",false,
83
+ 82,1620,1660,"does not handle `SIGTERM` by exiting, it will not be killed since it is PID 1 in the container (see ""NOTE"" at the end of the [Foreground section](https://docs.docker.com/engine/reference/run/#foreground) in the docker docs). The second situation would be zombie reaping. If",true,RUN
84
+ 83,1640,1680,"""NOTE"" at the end of the [Foreground section](https://docs.docker.com/engine/reference/run/#foreground) in the docker docs). The second situation would be zombie reaping. If the process spawns child processes and does not properly reap them it will lead to a full process table, which",true,RUN
85
+ 84,1660,1700,"the process spawns child processes and does not properly reap them it will lead to a full process table, which can prevent the whole system from spawning any new processes. For both of these concerns we recommend [tini](https://github.com/krallin/tini). It is",true,FROM
86
+ 85,1680,1720,"can prevent the whole system from spawning any new processes. For both of these concerns we recommend [tini](https://github.com/krallin/tini). It is incredibly small, has minimal external dependencies, fills each of these roles, and does only the necessary parts of reaping and",true,FROM
87
+ 86,1700,1740,"incredibly small, has minimal external dependencies, fills each of these roles, and does only the necessary parts of reaping and signal forwarding. Be sure to use tini in `CMD` or `ENTRYPOINT` as appropriate. It is best to install tini from",true,FROM|ENTRYPOINT
88
+ 87,1720,1760,"signal forwarding. Be sure to use tini in `CMD` or `ENTRYPOINT` as appropriate. It is best to install tini from a distribution-provided package (ex. `apt-get install tini`). If tini is not available in your distribution or is too old, here",true,FROM|ENTRYPOINT
89
+ 88,1740,1780,"a distribution-provided package (ex. `apt-get install tini`). If tini is not available in your distribution or is too old, here is a snippet of a `Dockerfile` to add in tini: ```Dockerfile # Install tini for signal processing and zombie killing",true,Dockerfile
90
+ 89,1760,1800,"is a snippet of a `Dockerfile` to add in tini: ```Dockerfile # Install tini for signal processing and zombie killing ENV TINI_VERSION v0.18.0 ENV TINI_SIGN_KEY 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 RUN set -eux; \ wget -O /usr/local/bin/tini ""https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini""; \ wget -O /usr/local/bin/tini.asc ""https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc""; \",true,Dockerfile|RUN|ENV
91
+ 90,1780,1820,"ENV TINI_VERSION v0.18.0 ENV TINI_SIGN_KEY 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 RUN set -eux; \ wget -O /usr/local/bin/tini ""https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini""; \ wget -O /usr/local/bin/tini.asc ""https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc""; \ export GNUPGHOME=""$(mktemp -d)""; \ gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ""$TINI_SIGN_KEY""; \ gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini; \ command -v gpgconf",true,RUN|ENV
92
+ 91,1800,1840,"export GNUPGHOME=""$(mktemp -d)""; \ gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ""$TINI_SIGN_KEY""; \ gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini; \ command -v gpgconf && gpgconf --kill all || :; \ rm -r ""$GNUPGHOME"" /usr/local/bin/tini.asc; \ chmod +x /usr/local/bin/tini; \ tini --version ``` ####",false,
93
+ 92,1820,1860,"&& gpgconf --kill all || :; \ rm -r ""$GNUPGHOME"" /usr/local/bin/tini.asc; \ chmod +x /usr/local/bin/tini; \ tini --version ``` #### Cacheability This is one place that experience ends up trumping documentation for the path to enlightenment, but the following tips",false,
94
+ 93,1840,1880,"Cacheability This is one place that experience ends up trumping documentation for the path to enlightenment, but the following tips might help: - Avoid `COPY`/`ADD` whenever possible, but when necessary, be as specific as possible (ie, `COPY one-file.sh /somewhere/` instead",false,
95
+ 94,1860,1900,"might help: - Avoid `COPY`/`ADD` whenever possible, but when necessary, be as specific as possible (ie, `COPY one-file.sh /somewhere/` instead of `COPY . /somewhere`). The reason for this is that the cache for `COPY` instructions considers file `mtime` changes to",false,
96
+ 95,1880,1920,"of `COPY . /somewhere`). The reason for this is that the cache for `COPY` instructions considers file `mtime` changes to be a cache bust, which can make the cache behavior of `COPY` unpredictable sometimes, especially when `.git` is part of",false,
97
+ 96,1900,1940,"be a cache bust, which can make the cache behavior of `COPY` unpredictable sometimes, especially when `.git` is part of what needs to be `COPY`ed (for example). - Ensure that lines which are less likely to change come before lines",false,
98
+ 97,1920,1960,what needs to be `COPY`ed (for example). - Ensure that lines which are less likely to change come before lines that are more likely to change (with the caveat that each line should generate an image that still runs successfully,true,RUN
99
+ 98,1940,1980,"that are more likely to change (with the caveat that each line should generate an image that still runs successfully without assumptions of later lines). For example, the line that contains the software version number (`ENV MYSOFTWARE_VERSION 4.2`) should come",true,RUN|ENV
100
+ 99,1960,2000,"without assumptions of later lines). For example, the line that contains the software version number (`ENV MYSOFTWARE_VERSION 4.2`) should come after a line that sets up the APT repository `.list` file (`RUN echo 'deb http://example.com/mysoftware/debian some-suite main' > /etc/apt/sources.list.d/mysoftware.list`). ####",true,RUN|ENV
101
+ 100,1980,2020,after a line that sets up the APT repository `.list` file (`RUN echo 'deb http://example.com/mysoftware/debian some-suite main' > /etc/apt/sources.list.d/mysoftware.list`). #### Security ##### Image Build The `Dockerfile` should be written to help mitigate interception attacks during build. Our requirements focus on,true,Dockerfile|RUN
102
+ 101,2000,2040,"Security ##### Image Build The `Dockerfile` should be written to help mitigate interception attacks during build. Our requirements focus on three main objectives: verifying the source, verifying author, and verifying the content; these are respectively accomplished by the following: using",false,Dockerfile
103
+ 102,2020,2060,"three main objectives: verifying the source, verifying author, and verifying the content; these are respectively accomplished by the following: using https where possible; importing PGP keys with the full fingerprint in the `Dockerfile` to check signatures; embedding checksums directly in",false,Dockerfile
104
+ 103,2040,2080,https where possible; importing PGP keys with the full fingerprint in the `Dockerfile` to check signatures; embedding checksums directly in the `Dockerfile`. All three should be used when possible. Just https and embedded checksum can be used when no signature,false,Dockerfile
105
+ 104,2060,2100,"the `Dockerfile`. All three should be used when possible. Just https and embedded checksum can be used when no signature is published. As a last resort, just an embedded checksum is acceptable if the site doesn't have https available and",false,Dockerfile
106
+ 105,2080,2120,"is published. As a last resort, just an embedded checksum is acceptable if the site doesn't have https available and no signature. The purpose in recommending the use of https for downloading needed artifacts is that it ensures that the",false,
107
+ 106,2100,2140,no signature. The purpose in recommending the use of https for downloading needed artifacts is that it ensures that the download is from a trusted source which also happens to make interception much more difficult. The purpose in recommending PGP,true,FROM
108
+ 107,2120,2160,"download is from a trusted source which also happens to make interception much more difficult. The purpose in recommending PGP signature verification is to ensure that only an authorized user published the given artifact. When importing PGP keys, please use",true,FROM
109
+ 108,2140,2180,"signature verification is to ensure that only an authorized user published the given artifact. When importing PGP keys, please use the [the `keys.openpgp.org` service](https://keys.openpgp.org/about) when possible (preferring `keyserver.ubuntu.com` otherwise). See also the FAQ section on [keys and verification](https://github.com/docker-library/faq/#openpgp--gnupg-keys-and-verification). The purpose",false,
110
+ 109,2160,2200,"the [the `keys.openpgp.org` service](https://keys.openpgp.org/about) when possible (preferring `keyserver.ubuntu.com` otherwise). See also the FAQ section on [keys and verification](https://github.com/docker-library/faq/#openpgp--gnupg-keys-and-verification). The purpose in recommending checksum verification is to verify that the artifact is as expected. This ensures that when remote content changes,",false,
111
+ 110,2180,2220,"in recommending checksum verification is to verify that the artifact is as expected. This ensures that when remote content changes, the Dockerfile also will change and provide a natural `docker build` cache bust. As a bonus, this also prevents accidentally",false,Dockerfile
112
+ 111,2200,2240,"the Dockerfile also will change and provide a natural `docker build` cache bust. As a bonus, this also prevents accidentally downloading newer-than-expected artifacts on poorly versioned files. Below are some examples: - **Preferred**: *download over https, PGP key full fingerprint",false,Dockerfile
113
+ 112,2220,2260,"downloading newer-than-expected artifacts on poorly versioned files. Below are some examples: - **Preferred**: *download over https, PGP key full fingerprint import and `asc` verification, embedded checksum verified.* ```Dockerfile ENV PYTHON_DOWNLOAD_SHA512 (sha512-value-here) RUN set -eux; \ curl -fL ""https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz"" -o python.tar.xz;",true,Dockerfile|RUN|ENV
114
+ 113,2240,2280,"import and `asc` verification, embedded checksum verified.* ```Dockerfile ENV PYTHON_DOWNLOAD_SHA512 (sha512-value-here) RUN set -eux; \ curl -fL ""https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz"" -o python.tar.xz; \ curl -fL ""https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz.asc"" -o python.tar.xz.asc; \ export GNUPGHOME=""$(mktemp -d)""; \ # gpg: key F73C700D: public key ""Larry Hastings """,true,Dockerfile|RUN|ENV
115
+ 114,2260,2300,"\ curl -fL ""https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz.asc"" -o python.tar.xz.asc; \ export GNUPGHOME=""$(mktemp -d)""; \ # gpg: key F73C700D: public key ""Larry Hastings "" imported gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 97FC712E4C024BBEA48A61ED3A5CA953F73C700D; \ gpg --batch --verify python.tar.xz.asc python.tar.xz; \ rm -r ""$GNUPGHOME"" python.tar.xz.asc; \ echo",false,
116
+ 115,2280,2320,"imported gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 97FC712E4C024BBEA48A61ED3A5CA953F73C700D; \ gpg --batch --verify python.tar.xz.asc python.tar.xz; \ rm -r ""$GNUPGHOME"" python.tar.xz.asc; \ echo ""$PYTHON_DOWNLOAD_SHA512 *python.tar.xz"" | sha512sum --strict --check; \ # install ``` - **Alternate**: *full key fingerprint imported to apt which will",false,
117
+ 116,2300,2340,"""$PYTHON_DOWNLOAD_SHA512 *python.tar.xz"" | sha512sum --strict --check; \ # install ``` - **Alternate**: *full key fingerprint imported to apt which will check signatures and checksums when packages are downloaded and installed.* ```Dockerfile RUN set -eux; \ key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \ export GNUPGHOME=""$(mktemp -d)"";",true,Dockerfile|RUN
118
+ 117,2320,2360,"check signatures and checksums when packages are downloaded and installed.* ```Dockerfile RUN set -eux; \ key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \ export GNUPGHOME=""$(mktemp -d)""; \ gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ""$key""; \ gpg --batch --armor --export ""$key"" > /etc/apt/keyrings/mysql.asc; \ gpgconf --kill all; \",true,Dockerfile|RUN
119
+ 118,2340,2380,"\ gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ""$key""; \ gpg --batch --armor --export ""$key"" > /etc/apt/keyrings/mysql.asc; \ gpgconf --kill all; \ rm -rf ""$GNUPGHOME""; \ apt-key list > /dev/null RUN set -eux; \ echo ""deb [ signed-by=/etc/apt/keyrings/mysql.asc ] http://repo.mysql.com/apt/debian/ bookworm mysql-${MYSQL_MAJOR}""",true,RUN
120
+ 119,2360,2400,"rm -rf ""$GNUPGHOME""; \ apt-key list > /dev/null RUN set -eux; \ echo ""deb [ signed-by=/etc/apt/keyrings/mysql.asc ] http://repo.mysql.com/apt/debian/ bookworm mysql-${MYSQL_MAJOR}"" > /etc/apt/sources.list.d/mysql.list; \ apt-get update; \ apt-get install -y mysql-community-client=""${MYSQL_VERSION}"" mysql-community-server-core=""${MYSQL_VERSION}""; \ rm -rf /var/lib/apt/lists/*; \ # ... ``` (As",true,RUN
121
+ 120,2380,2420,"> /etc/apt/sources.list.d/mysql.list; \ apt-get update; \ apt-get install -y mysql-community-client=""${MYSQL_VERSION}"" mysql-community-server-core=""${MYSQL_VERSION}""; \ rm -rf /var/lib/apt/lists/*; \ # ... ``` (As a side note, `rm -rf /var/lib/apt/lists/*` is *roughly* the opposite of `apt-get update` -- it ensures that the layer doesn't",true,
122
+ 121,2400,2440,"a side note, `rm -rf /var/lib/apt/lists/*` is *roughly* the opposite of `apt-get update` -- it ensures that the layer doesn't include the extra ~8MB of APT package list data, and enforces [appropriate `apt-get update` usage](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#apt-get).) - **Less Secure Alternate**: *embed",true,Dockerfile
123
+ 122,2420,2460,"include the extra ~8MB of APT package list data, and enforces [appropriate `apt-get update` usage](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#apt-get).) - **Less Secure Alternate**: *embed the checksum into the `Dockerfile`.* ```Dockerfile ENV RUBY_DOWNLOAD_SHA256 (sha256-value-here) RUN set -eux; \ curl -fL -o ruby.tar.gz ""https://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_VERSION.tar.gz""; \ echo",true,Dockerfile|RUN|ENV
124
+ 123,2440,2480,"the checksum into the `Dockerfile`.* ```Dockerfile ENV RUBY_DOWNLOAD_SHA256 (sha256-value-here) RUN set -eux; \ curl -fL -o ruby.tar.gz ""https://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_VERSION.tar.gz""; \ echo ""$RUBY_DOWNLOAD_SHA256 *ruby.tar.gz"" | sha256sum --strict --check; \ # install ``` - **Note:** the use of either SHA1 or MD5 should",true,Dockerfile|RUN|ENV
125
+ 124,2460,2500,"""$RUBY_DOWNLOAD_SHA256 *ruby.tar.gz"" | sha256sum --strict --check; \ # install ``` - **Note:** the use of either SHA1 or MD5 should be considered a ""checksum of last resort"" as both are considered generally unsafe: - [""Single-block collision for MD5"" from 2012](https://marc-stevens.nl/research/md5-1block-collision/)",true,FROM
126
+ 125,2480,2520,"be considered a ""checksum of last resort"" as both are considered generally unsafe: - [""Single-block collision for MD5"" from 2012](https://marc-stevens.nl/research/md5-1block-collision/) - [""Announcing the first SHA1 collision"" from 2017](https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html) - **Unacceptable**: *download the file over http(s) with no verification.* ```Dockerfile RUN",true,Dockerfile|FROM|RUN
127
+ 126,2500,2540,"- [""Announcing the first SHA1 collision"" from 2017](https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html) - **Unacceptable**: *download the file over http(s) with no verification.* ```Dockerfile RUN curl -fL ""https://julialang.s3.amazonaws.com/bin/linux/x64/${JULIA_VERSION%[.-]*}/julia-${JULIA_VERSION}-linux-x86_64.tar.gz"" | tar ... \ # install ``` ##### Runtime Configuration By default, Docker containers are executed with",true,Dockerfile|FROM|RUN
128
+ 127,2520,2560,"curl -fL ""https://julialang.s3.amazonaws.com/bin/linux/x64/${JULIA_VERSION%[.-]*}/julia-${JULIA_VERSION}-linux-x86_64.tar.gz"" | tar ... \ # install ``` ##### Runtime Configuration By default, Docker containers are executed with reduced privileges: whitelisted Linux capabilities, Control Groups, and a default Seccomp profile (1.10+ w/ host support). Software running in a",true,RUN
129
+ 128,2540,2580,"reduced privileges: whitelisted Linux capabilities, Control Groups, and a default Seccomp profile (1.10+ w/ host support). Software running in a container may require additional privileges in order to function correctly, and there are a number of command line options to",true,RUN
130
+ 129,2560,2600,"container may require additional privileges in order to function correctly, and there are a number of command line options to customize container execution. See [`docker run` Reference](https://docs.docker.com/engine/reference/run/) and [Seccomp for Docker](https://docs.docker.com/engine/security/seccomp/) for reference. Official Repositories that require additional privileges should",true,RUN
131
+ 130,2580,2620,"customize container execution. See [`docker run` Reference](https://docs.docker.com/engine/reference/run/) and [Seccomp for Docker](https://docs.docker.com/engine/security/seccomp/) for reference. Official Repositories that require additional privileges should specify the minimal set of command line options for the software to function, and may still be rejected if this",true,RUN
132
+ 131,2600,2640,"specify the minimal set of command line options for the software to function, and may still be rejected if this introduces significant portability or security issues. In general, `--privileged` is not allowed, but a combination of `--cap-add` and `--device` options",false,
133
+ 132,2620,2660,"introduces significant portability or security issues. In general, `--privileged` is not allowed, but a combination of `--cap-add` and `--device` options may be acceptable. Additionally, `--volume` can be tricky as there are many host filesystem locations that introduce portability/security issues (e.g.",false,
134
+ 133,2640,2680,"may be acceptable. Additionally, `--volume` can be tricky as there are many host filesystem locations that introduce portability/security issues (e.g. X11 socket). ##### Security Releases For image updates which constitute a security fix, there are a few things we recommend",false,
135
+ 134,2660,2700,"X11 socket). ##### Security Releases For image updates which constitute a security fix, there are a few things we recommend to help ensure your update is merged, built, and released as quickly as possible: 1. [Send an email to `doi@docker.com`](mailto:doi@docker.com)",false,
136
+ 135,2680,2720,"to help ensure your update is merged, built, and released as quickly as possible: 1. [Send an email to `doi@docker.com`](mailto:doi@docker.com) a few (business) days in advance to give us a heads up and a timing estimate (so we can schedule",false,
137
+ 136,2700,2740,"a few (business) days in advance to give us a heads up and a timing estimate (so we can schedule time for the incoming update appropriately). 2. Include `[security]` in the title of your pull request (for example, `[security] Update",false,
138
+ 137,2720,2760,"time for the incoming update appropriately). 2. Include `[security]` in the title of your pull request (for example, `[security] Update FooBar to 1.2.5, 1.3.7, 2.0.1`). 3. Keep the pull request free of changes that are unrelated to the security fix",false,
139
+ 138,2740,2780,"FooBar to 1.2.5, 1.3.7, 2.0.1`). 3. Keep the pull request free of changes that are unrelated to the security fix -- we'll still be doing review of the update, but it will be expedited so this will help us help",false,
140
+ 139,2760,2800,"-- we'll still be doing review of the update, but it will be expedited so this will help us help you. 4. Be active and responsive to comments on the pull request after it's opened (as usual, but even more",false,
141
+ 140,2780,2820,"you. 4. Be active and responsive to comments on the pull request after it's opened (as usual, but even more so if the timing of the release is of importance). #### Multiple Architectures Each repo can specify multiple architectures for",false,
142
+ 141,2800,2840,"so if the timing of the release is of importance). #### Multiple Architectures Each repo can specify multiple architectures for any and all tags. If no architecture is specified, images are built in Linux on `amd64` (aka x86-64). To specify",false,Tags
143
+ 142,2820,2860,"any and all tags. If no architecture is specified, images are built in Linux on `amd64` (aka x86-64). To specify more or different architectures, use the `Architectures` field (comma-delimited list, whitespace is trimmed). Valid architectures are found in [Bashbrew's `oci-platform.go`",false,Tags
144
+ 143,2840,2880,"more or different architectures, use the `Architectures` field (comma-delimited list, whitespace is trimmed). Valid architectures are found in [Bashbrew's `oci-platform.go` file](https://github.com/docker-library/bashbrew/blob/v0.1.2/architecture/oci-platform.go#L14-L27): - `amd64` - `arm32v6` - `arm32v7` - `arm64v8` - `i386` - `ppc64le` - `riscv64` - `s390x` - `windows-amd64` The",false,
145
+ 144,2860,2900,file](https://github.com/docker-library/bashbrew/blob/v0.1.2/architecture/oci-platform.go#L14-L27): - `amd64` - `arm32v6` - `arm32v7` - `arm64v8` - `i386` - `ppc64le` - `riscv64` - `s390x` - `windows-amd64` The `Architectures` of any given tag must be a strict subset of the `Architectures` of the tag it is `FROM`. Images,true,FROM
146
+ 145,2880,2920,`Architectures` of any given tag must be a strict subset of the `Architectures` of the tag it is `FROM`. Images must have a single `Dockerfile` per entry in the library file that can be used for multiple architectures. This means,true,Dockerfile|FROM
147
+ 146,2900,2940,"must have a single `Dockerfile` per entry in the library file that can be used for multiple architectures. This means that each supported architecture will have the same `FROM` line (e.g. `FROM debian:bookworm`). See [`golang`](https://github.com/docker-library/official-images/blob/master/library/golang), [`docker`](https://github.com/docker-library/official-images/blob/master/library/docker), [`haproxy`](https://github.com/docker-library/official-images/blob/master/library/haproxy), and [`php`](https://github.com/docker-library/official-images/blob/master/library/php) for",true,Dockerfile|FROM
148
+ 147,2920,2960,"that each supported architecture will have the same `FROM` line (e.g. `FROM debian:bookworm`). See [`golang`](https://github.com/docker-library/official-images/blob/master/library/golang), [`docker`](https://github.com/docker-library/official-images/blob/master/library/docker), [`haproxy`](https://github.com/docker-library/official-images/blob/master/library/haproxy), and [`php`](https://github.com/docker-library/official-images/blob/master/library/php) for examples of library files using one `Dockerfile` per entry and see their respective git repos for example `Dockerfile`s. If different",true,Dockerfile|FROM
149
+ 148,2940,2980,"examples of library files using one `Dockerfile` per entry and see their respective git repos for example `Dockerfile`s. If different parts of the Dockerfile only happen in one architecture or another, use control flow (e.g.`if`/`case`) along with `dpkg --print-architecture` or",false,Dockerfile
150
+ 149,2960,3000,"parts of the Dockerfile only happen in one architecture or another, use control flow (e.g.`if`/`case`) along with `dpkg --print-architecture` or `apk -print-arch` to detect the userspace architecture. Only use `uname` for architecture detection when more accurate tools cannot be installed.",false,Dockerfile
151
+ 150,2980,3020,`apk -print-arch` to detect the userspace architecture. Only use `uname` for architecture detection when more accurate tools cannot be installed. See [golang](https://github.com/docker-library/golang/blob/72bc141d781ae54ef20f71aa1105449cb6c2edc4/1.20/bookworm/Dockerfile#L26-L63) for an example where some architectures require building binaries from the upstream source packages and some merely download,true,Dockerfile|FROM
152
+ 151,3000,3040,See [golang](https://github.com/docker-library/golang/blob/72bc141d781ae54ef20f71aa1105449cb6c2edc4/1.20/bookworm/Dockerfile#L26-L63) for an example where some architectures require building binaries from the upstream source packages and some merely download the binary release. For base images like `debian` it will be necessary to have a different `Dockerfile` and build context,true,Dockerfile|FROM
153
+ 152,3020,3060,the binary release. For base images like `debian` it will be necessary to have a different `Dockerfile` and build context in order to `ADD` architecture specific binaries and this is a valid exception to the above. Since these images use,false,Dockerfile
154
+ 153,3040,3080,"in order to `ADD` architecture specific binaries and this is a valid exception to the above. Since these images use the same `Tags`, they need to be in the same entry. Use the architecture specific fields for `GitRepo`, `GitFetch`, `GitCommit`,",false,Tags|GitRepo
155
+ 154,3060,3100,"the same `Tags`, they need to be in the same entry. Use the architecture specific fields for `GitRepo`, `GitFetch`, `GitCommit`, and `Directory`, which are the architecture concatenated with hyphen (`-`) and the field (e.g. `arm32v7-GitCommit`). Any architecture that does not",false,Tags|GitRepo
156
+ 155,3080,3120,"and `Directory`, which are the architecture concatenated with hyphen (`-`) and the field (e.g. `arm32v7-GitCommit`). Any architecture that does not have an architecture-specific field will use the default field (e.g. no `arm32v7-Directory` means `Directory` will be used for `arm32v7`). See",false,
157
+ 156,3100,3140,have an architecture-specific field will use the default field (e.g. no `arm32v7-Directory` means `Directory` will be used for `arm32v7`). See the [`debian`](https://github.com/docker-library/official-images/blob/master/library/debian) or [`ubuntu`](https://github.com/docker-library/official-images/blob/master/library/ubuntu) files in the library for examples. The following is an example for [`hello-world`](https://github.com/docker-library/official-images/blob/master/library/hello-world): ``` Maintainers: Tianon,false,
158
+ 157,3120,3160,"the [`debian`](https://github.com/docker-library/official-images/blob/master/library/debian) or [`ubuntu`](https://github.com/docker-library/official-images/blob/master/library/ubuntu) files in the library for examples. The following is an example for [`hello-world`](https://github.com/docker-library/official-images/blob/master/library/hello-world): ``` Maintainers: Tianon Gravi (@tianon), Joseph Ferguson (@yosifkit) GitRepo: https://github.com/docker-library/hello-world.git GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 Tags: latest Architectures: amd64, arm32v5, arm32v7, arm64v8, ppc64le, s390x # all",false,Tags|GitRepo
159
+ 158,3140,3180,"Gravi (@tianon), Joseph Ferguson (@yosifkit) GitRepo: https://github.com/docker-library/hello-world.git GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 Tags: latest Architectures: amd64, arm32v5, arm32v7, arm64v8, ppc64le, s390x # all the same commit; easy for us to generate this way since they could be different amd64-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 amd64-Directory: amd64/hello-world arm32v5-GitCommit:",false,Tags|GitRepo
160
+ 159,3160,3200,the same commit; easy for us to generate this way since they could be different amd64-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 amd64-Directory: amd64/hello-world arm32v5-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 arm32v5-Directory: arm32v5/hello-world arm32v7-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 arm32v7-Directory: arm32v7/hello-world arm64v8-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 arm64v8-Directory: arm64v8/hello-world ppc64le-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 ppc64le-Directory: ppc64le/hello-world s390x-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 s390x-Directory: s390x/hello-world Tags:,false,Tags
161
+ 160,3180,3220,"7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 arm32v5-Directory: arm32v5/hello-world arm32v7-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 arm32v7-Directory: arm32v7/hello-world arm64v8-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 arm64v8-Directory: arm64v8/hello-world ppc64le-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 ppc64le-Directory: ppc64le/hello-world s390x-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 s390x-Directory: s390x/hello-world Tags: nanoserver Architectures: windows-amd64 # if there is only one architecture, you can use the unprefixed fields Directory: amd64/hello-world/nanoserver # or",false,Tags
162
+ 161,3200,3240,"nanoserver Architectures: windows-amd64 # if there is only one architecture, you can use the unprefixed fields Directory: amd64/hello-world/nanoserver # or use the prefixed versions windows-amd64-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 Constraints: nanoserver ``` See the [instruction format section](#instruction-format) for more information on the format",false,
163
+ 162,3220,3260,use the prefixed versions windows-amd64-GitCommit: 7d0ee592e4ed60e2da9d59331e16ecdcadc1ed87 Constraints: nanoserver ``` See the [instruction format section](#instruction-format) for more information on the format of the library file. ### Commitment Proposing a new official image should not be undertaken lightly. We expect and require,false,
164
+ 163,3240,3280,"of the library file. ### Commitment Proposing a new official image should not be undertaken lightly. We expect and require a commitment to maintain your image (including and especially timely updates as appropriate, as noted above). ## Library definition files",false,
165
+ 164,3260,3300,"a commitment to maintain your image (including and especially timely updates as appropriate, as noted above). ## Library definition files The library definition files are plain text files found in the [`library/` directory of the `official-images` repository](https://github.com/docker-library/official-images/tree/master/library). Each library file",false,
166
+ 165,3280,3320,"The library definition files are plain text files found in the [`library/` directory of the `official-images` repository](https://github.com/docker-library/official-images/tree/master/library). Each library file controls the current ""supported"" set of image tags that appear on the Docker Hub description. Tags that are removed from",true,FROM|Tags
167
+ 166,3300,3340,"controls the current ""supported"" set of image tags that appear on the Docker Hub description. Tags that are removed from a library file do not get removed from the Docker Hub, so that old versions can continue to be available",true,FROM|Tags
168
+ 167,3320,3360,"a library file do not get removed from the Docker Hub, so that old versions can continue to be available for use, but are not maintained by upstream or the maintainer of the official image. Tags in the library file",true,FROM|Tags
169
+ 168,3340,3380,"for use, but are not maintained by upstream or the maintainer of the official image. Tags in the library file are only built through an update to that library file or as a result of its base image being updated",false,Tags
170
+ 169,3360,3400,"are only built through an update to that library file or as a result of its base image being updated (ie, an image `FROM debian:bookworm` would be rebuilt when `debian:bookworm` is built). Only what is in the library file will",true,FROM
171
+ 170,3380,3420,"(ie, an image `FROM debian:bookworm` would be rebuilt when `debian:bookworm` is built). Only what is in the library file will be rebuilt when a base has updates. Given this policy, it is worth clarifying a few cases: backfilled versions, release",true,FROM
172
+ 171,3400,3440,"be rebuilt when a base has updates. Given this policy, it is worth clarifying a few cases: backfilled versions, release candidates, and continuous integration builds. When a new repository is proposed, it is common to include some older unsupported versions",false,
173
+ 172,3420,3460,"candidates, and continuous integration builds. When a new repository is proposed, it is common to include some older unsupported versions in the initial pull request with the agreement to remove them right after acceptance. Don't confuse this with a comprehensive",false,
174
+ 173,3440,3480,"in the initial pull request with the agreement to remove them right after acceptance. Don't confuse this with a comprehensive historical archive which is not the intention. Another common case where the term ""supported"" is stretched a bit is with",false,
175
+ 174,3460,3500,"historical archive which is not the intention. Another common case where the term ""supported"" is stretched a bit is with release candidates. A release candidate is really just a naming convention for what are expected to be shorter-lived releases, so",false,
176
+ 175,3480,3520,"release candidates. A release candidate is really just a naming convention for what are expected to be shorter-lived releases, so they are totally acceptable and encouraged. Unlike a release candidate, continuous integration builds which have a fully automated release cycle",false,
177
+ 176,3500,3540,"they are totally acceptable and encouraged. Unlike a release candidate, continuous integration builds which have a fully automated release cycle based on code commits or a regular schedule are not appropriate. It is highly recommended that you browse some of",false,
178
+ 177,3520,3560,based on code commits or a regular schedule are not appropriate. It is highly recommended that you browse some of the existing `library/` file contents (and history to get a feel for how they change over time) before creating a,false,
179
+ 178,3540,3580,the existing `library/` file contents (and history to get a feel for how they change over time) before creating a new one to become familiar with the prevailing conventions and further help streamline the review process (so that we can,false,
180
+ 179,3560,3600,new one to become familiar with the prevailing conventions and further help streamline the review process (so that we can focus on content instead of esoteric formatting or tag usage/naming). ### Filenames The filename of a definition file will determine,false,
181
+ 180,3580,3620,"focus on content instead of esoteric formatting or tag usage/naming). ### Filenames The filename of a definition file will determine the name of the image repository it creates on the Docker Hub. For example, the `library/ubuntu` file will create tags",false,Tags
182
+ 181,3600,3640,"the name of the image repository it creates on the Docker Hub. For example, the `library/ubuntu` file will create tags in the `ubuntu` repository. ### Tags and aliases The tags of a repository should reflect upstream's versions or variations. For",false,Tags
183
+ 182,3620,3660,"in the `ubuntu` repository. ### Tags and aliases The tags of a repository should reflect upstream's versions or variations. For example, Ubuntu 14.04 is also known as Ubuntu Trusty Tahr, but often as simply Ubuntu Trusty (especially in usage), so",false,Tags
184
+ 183,3640,3680,"example, Ubuntu 14.04 is also known as Ubuntu Trusty Tahr, but often as simply Ubuntu Trusty (especially in usage), so `ubuntu:14.04` (version number) and `ubuntu:trusty` (version name) are appropriate aliases for the same image contents. In Docker, the `latest` tag",false,
185
+ 184,3660,3700,"`ubuntu:14.04` (version number) and `ubuntu:trusty` (version name) are appropriate aliases for the same image contents. In Docker, the `latest` tag is a special case, but it's a bit of a misnomer; `latest` really is the ""default"" tag. When one does",false,
186
+ 185,3680,3720,"is a special case, but it's a bit of a misnomer; `latest` really is the ""default"" tag. When one does `docker run xyz`, Docker interprets that to mean `docker run xyz:latest`. Given that background, no other tag ever contains the",true,RUN
187
+ 186,3700,3740,"`docker run xyz`, Docker interprets that to mean `docker run xyz:latest`. Given that background, no other tag ever contains the string `latest`, since it's not something users are expected or encouraged to actually type out (ie, `xyz:latest` should really be",true,RUN
188
+ 187,3720,3760,"string `latest`, since it's not something users are expected or encouraged to actually type out (ie, `xyz:latest` should really be used as simply `xyz`). Put another way, having an alias for the ""highest 2.2-series release of XYZ"" should be `xyz:2.2`,",false,
189
+ 188,3740,3780,"used as simply `xyz`). Put another way, having an alias for the ""highest 2.2-series release of XYZ"" should be `xyz:2.2`, not `xyz:2.2-latest`. Similarly, if there is an Alpine variant of `xyz:latest`, it should be aliased as `xyz:alpine`, not `xyz:alpine-latest` or",false,
190
+ 189,3760,3800,"not `xyz:2.2-latest`. Similarly, if there is an Alpine variant of `xyz:latest`, it should be aliased as `xyz:alpine`, not `xyz:alpine-latest` or `xyz:latest-alpine`. It is strongly encouraged that version number tags be given aliases which make it easy for the user to",false,Tags
191
+ 190,3780,3820,"`xyz:latest-alpine`. It is strongly encouraged that version number tags be given aliases which make it easy for the user to stay on the ""most recent"" release of a particular series. For example, given currently supported XYZ Software versions of 2.3.7",false,Tags
192
+ 191,3800,3840,"stay on the ""most recent"" release of a particular series. For example, given currently supported XYZ Software versions of 2.3.7 and 2.2.4, suggested aliases would be `Tags: 2.3.7, 2.3, 2, latest` and `Tags: 2.2.4, 2.2`, respectively. In this example, the",false,Tags
193
+ 192,3820,3860,"and 2.2.4, suggested aliases would be `Tags: 2.3.7, 2.3, 2, latest` and `Tags: 2.2.4, 2.2`, respectively. In this example, the user can use `xyz:2.2` to easily use the most recent patch release of the 2.2 series, or `xyz:2` if less",false,Tags
194
+ 193,3840,3880,"user can use `xyz:2.2` to easily use the most recent patch release of the 2.2 series, or `xyz:2` if less granularity is needed (Python is a good example of where that's most obviously useful -- `python:2` and `python:3` are very",false,
195
+ 194,3860,3900,"granularity is needed (Python is a good example of where that's most obviously useful -- `python:2` and `python:3` are very different, and can be thought of as the `latest` tag for each of the major release tracks of Python). As",false,
196
+ 195,3880,3920,"different, and can be thought of as the `latest` tag for each of the major release tracks of Python). As described above, `latest` is really ""default"", so the image that it is an alias for should reflect which version or",false,
197
+ 196,3900,3940,"described above, `latest` is really ""default"", so the image that it is an alias for should reflect which version or variation of the software users should use if they do not know or do not care which version they use.",false,
198
+ 197,3920,3960,"variation of the software users should use if they do not know or do not care which version they use. Using Ubuntu as an example, `ubuntu:latest` points to the most recent LTS release, given that it is what the majority",false,
199
+ 198,3940,3980,"Using Ubuntu as an example, `ubuntu:latest` points to the most recent LTS release, given that it is what the majority of users should be using if they know they want Ubuntu but do not know or care which version (especially",false,
200
+ 199,3960,4000,"of users should be using if they know they want Ubuntu but do not know or care which version (especially considering it will be the most ""stable"" and well-supported release at any given time). ### Instruction format The manifest file",false,
201
+ 200,3980,4020,"considering it will be the most ""stable"" and well-supported release at any given time). ### Instruction format The manifest file format is officially based on [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt), and as such should be familiar to folks who are already familiar with",false,
202
+ 201,4000,4040,"format is officially based on [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt), and as such should be familiar to folks who are already familiar with the ""headers"" of many popular internet protocols/formats such as HTTP or email. The primary additions are inspired by the way",false,
203
+ 202,4020,4060,"the ""headers"" of many popular internet protocols/formats such as HTTP or email. The primary additions are inspired by the way Debian commonly uses 2822 -- namely, lines starting with `#` are ignored and ""entries"" are separated by a blank line.",false,
204
+ 203,4040,4080,"Debian commonly uses 2822 -- namely, lines starting with `#` are ignored and ""entries"" are separated by a blank line. The first entry is the ""global"" metadata for the image. The only required field in the global entry is `Maintainers`,",false,
205
+ 204,4060,4100,"The first entry is the ""global"" metadata for the image. The only required field in the global entry is `Maintainers`, whose value is comma-separated in the format of `Name (@github)` or `Name (@github)`. Any field specified in the global entry",false,
206
+ 205,4080,4120,whose value is comma-separated in the format of `Name (@github)` or `Name (@github)`. Any field specified in the global entry will be the default for the rest of the entries and can be overridden in an individual entry. # this,false,
207
+ 206,4100,4140,"will be the default for the rest of the entries and can be overridden in an individual entry. # this is a comment and will be ignored Maintainers: John Smith (@example-jsmith), Anne Smith (@example-asmith) GitRepo: https://github.com/example/docker-example.git GitCommit: deadbeefdeadbeefdeadbeefdeadbeefdeadbeef # this",false,GitRepo
208
+ 207,4120,4160,"is a comment and will be ignored Maintainers: John Smith (@example-jsmith), Anne Smith (@example-asmith) GitRepo: https://github.com/example/docker-example.git GitCommit: deadbeefdeadbeefdeadbeefdeadbeefdeadbeef # this is also a comment, and will also be ignored Tags: 1.2.3, 1.2, 1, latest Directory: 1 Tags: 2.0-rc1, 2.0-rc, 2-rc,",false,Tags|GitRepo
209
+ 208,4140,4180,"is also a comment, and will also be ignored Tags: 1.2.3, 1.2, 1, latest Directory: 1 Tags: 2.0-rc1, 2.0-rc, 2-rc, rc GitRepo: https://github.com/example/docker-example-rc.git GitFetch: refs/heads/2.0-pre-release GitCommit: beefdeadbeefdeadbeefdeadbeefdeadbeefdead Directory: 2 File: Dockerfile-to-use Bashbrew will fetch code out of the Git repository",false,Dockerfile|Tags|GitRepo
210
+ 209,4160,4200,"rc GitRepo: https://github.com/example/docker-example-rc.git GitFetch: refs/heads/2.0-pre-release GitCommit: beefdeadbeefdeadbeefdeadbeefdeadbeefdead Directory: 2 File: Dockerfile-to-use Bashbrew will fetch code out of the Git repository (`GitRepo`) at the commit specified (`GitCommit`). If the commit referenced is not available by fetching `master` of the associated `GitRepo`,",false,Dockerfile|GitRepo
211
+ 210,4180,4220,"(`GitRepo`) at the commit specified (`GitCommit`). If the commit referenced is not available by fetching `master` of the associated `GitRepo`, it becomes necessary to supply a value for `GitFetch` in order to tell Bashbrew what ref to fetch in order",false,GitRepo
212
+ 211,4200,4240,"it becomes necessary to supply a value for `GitFetch` in order to tell Bashbrew what ref to fetch in order to get the commit necessary. The built image will be tagged as ` : ` (ie, `library/golang` with a `Tags`",false,Tags
213
+ 212,4220,4260,"to get the commit necessary. The built image will be tagged as ` : ` (ie, `library/golang` with a `Tags` value of `1.6, 1, latest` will create tags of `golang:1.6`, `golang:1`, and `golang:latest`). Optionally, if `Directory` is present, Bashbrew will",false,Tags
214
+ 213,4240,4280,"value of `1.6, 1, latest` will create tags of `golang:1.6`, `golang:1`, and `golang:latest`). Optionally, if `Directory` is present, Bashbrew will look for the `Dockerfile` inside the specified subdirectory instead of at the root (and `Directory` will be used as the",false,Dockerfile|Tags
215
+ 214,4260,4300,"look for the `Dockerfile` inside the specified subdirectory instead of at the root (and `Directory` will be used as the [""context"" for the build](https://docs.docker.com/reference/builder/) instead of the top-level of the repository). If `File` is present, the specified filename instead of",false,Dockerfile
216
+ 215,4280,4320,"[""context"" for the build](https://docs.docker.com/reference/builder/) instead of the top-level of the repository). If `File` is present, the specified filename instead of `Dockerfile` will be used. See the [multi-arch section](#multiple-architectures) for details on how to specify a different `GitRepo`, `GitFetch`, `GitCommit`, or",false,Dockerfile|GitRepo
217
+ 216,4300,4340,"`Dockerfile` will be used. See the [multi-arch section](#multiple-architectures) for details on how to specify a different `GitRepo`, `GitFetch`, `GitCommit`, or `Directory` for a specific architecture. ### Creating a new repository - Create a new file in the `library/` folder. Its",false,Dockerfile|GitRepo
218
+ 217,4320,4360,`Directory` for a specific architecture. ### Creating a new repository - Create a new file in the `library/` folder. Its name will be the name of your repository on the Hub. - Add your tag definitions using the appropriate syntax,false,
219
+ 218,4340,4380,name will be the name of your repository on the Hub. - Add your tag definitions using the appropriate syntax (see above). - Create a pull request adding the file from your forked repository to this one. Please be sure,true,FROM
220
+ 219,4360,4400,(see above). - Create a pull request adding the file from your forked repository to this one. Please be sure to add details as to what your repository does. ### Adding a new tag in an existing repository (that you're,true,FROM
221
+ 220,4380,4420,to add details as to what your repository does. ### Adding a new tag in an existing repository (that you're the maintainer of) - Add your tag definition using the instruction format documented above. - Create a pull request from,true,FROM
222
+ 221,4400,4440,"the maintainer of) - Add your tag definition using the instruction format documented above. - Create a pull request from your Git repository to this one. Please be sure to add details about what's new, if possible. ### Change to",true,FROM
223
+ 222,4420,4460,"your Git repository to this one. Please be sure to add details about what's new, if possible. ### Change to a tag in an existing repository (that you're the maintainer of) - Update the relevant tag definition using the instruction",false,
224
+ 223,4440,4480,a tag in an existing repository (that you're the maintainer of) - Update the relevant tag definition using the instruction format documented above. - Create a pull request from your Git repository to this one. Please be sure to add,true,FROM
225
+ 224,4460,4500,"format documented above. - Create a pull request from your Git repository to this one. Please be sure to add details about what's changed, if possible. ## Bashbrew Bashbrew (`bashbrew`) is a tool for cloning, building, tagging, and pushing the",true,FROM
226
+ 225,4480,4511,"details about what's changed, if possible. ## Bashbrew Bashbrew (`bashbrew`) is a tool for cloning, building, tagging, and pushing the Docker official images. See [the Bashbrew `README`](https://github.com/docker-library/bashbrew#readme) for more information. ```",false,
20260907-002128-computing-math-734953/environment/public_data/input/source_context_windows.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
20260907-002128-computing-math-734953/environment/public_data/input/tutorial_metadata.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "software_name": "Docker / Postgres Official Image",
3
+ "tutorial_url": "https://raw.githubusercontent.com/docker-library/official-images/master/README.md",
4
+ "source_urls": [
5
+ "https://raw.githubusercontent.com/docker-library/official-images/master/README.md"
6
+ ],
7
+ "source_file": "dockerfile_packaging_corpus.md",
8
+ "window_file": "dockerfile_text_windows.csv",
9
+ "window_rule": {
10
+ "cleaning": "Strip HTML/script/style tags, decode entities, collapse whitespace, and preserve document text order.",
11
+ "window_size_words": 40,
12
+ "stride_words": 20,
13
+ "minimum_windows": 100
14
+ },
15
+ "required_terms": [
16
+ "Dockerfile",
17
+ "FROM",
18
+ "RUN",
19
+ "ENV",
20
+ "ENTRYPOINT",
21
+ "PGDATA",
22
+ "Tags",
23
+ "GitRepo"
24
+ ],
25
+ "code_terms": [
26
+ "postgres",
27
+ "docker-entrypoint.sh",
28
+ "FROM",
29
+ "RUN",
30
+ "ENV",
31
+ "ENTRYPOINT",
32
+ "apt-get"
33
+ ],
34
+ "note": "Provenance and public extraction rules only; scored aggregate values are intentionally not stored here."
35
+ }