Skip to content

Commit 71af1be

Browse files
Finish portability review controls without requiring Git for Cargo tests
1 parent 858dfeb commit 71af1be

4 files changed

Lines changed: 201 additions & 72 deletions

File tree

‎.github/workflows/ci-integrity.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ jobs:
117117
done
118118
exit "$fail"
119119
120+
- name: Repository path portability
121+
run: |
122+
set -euo pipefail
123+
rustc --version
124+
CHECKER="$RUNNER_TEMP/check-repository-paths"
125+
rustc --edition 2021 --test scripts/ci/check-repository-paths.rs -o "$CHECKER-tests"
126+
"$CHECKER-tests"
127+
rustc --edition 2021 scripts/ci/check-repository-paths.rs -o "$CHECKER"
128+
"$CHECKER" "$GITHUB_WORKSPACE"
129+
120130
- name: Retain raw native result and immutable source identity
121131
if: always()
122132
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
@@ -140,6 +150,7 @@ jobs:
140150
echo '| Native lock | Official v0.2.0 result, unchanged published reconciliation and bidirectional lock sync |'
141151
echo '| Tree allowlist | Complete action/workflow path and exact SHA, without a live Settings claim |'
142152
echo '| YAML parse | Readable workflow documents with a jobs map |'
153+
echo '| Repository paths | Windows device/component restrictions and case/file-directory collisions in the complete tracked inventory |'
143154
echo '| Startup triage | Source/API observations; no inferred platform root cause from zero jobs alone |'
144155
echo ''
145156
echo 'The raw artifact records not_run if consumer verification never executed, or running if no native exit was recorded.'

‎docs/echo-362-portability.adoc‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: CC-BY-SA-4.0
2+
= Windows checkout portability — Echo Types issue 362
3+
4+
The eight historical reports previously containing colons in their filenames
5+
are renamed with hyphens. Their original Git blob hashes are unchanged;
6+
report contents and ISO timestamps remain untouched. A fresh complete Windows
7+
clone of the repair branch succeeded without omitting any tracked artifact.
8+
9+
The Chapel writer removes colons from filenames only. The existing Chapel
10+
end-to-end gate checks the names of both generated report types. No local
11+
Chapel execution is claimed: the compiler is not installed locally.
12+
13+
The dedicated CI path checker tests invalid Windows components, reserved
14+
device names (including superscript digits and console devices), and
15+
case/file-directory collisions. It checks the explicit Git worktree root;
16+
it is not a Cargo integration test and does not break packaged-source tests
17+
or accidentally inspect a vendored crate's enclosing repository.
18+
19+
The two original portability controls failed on the old tracked inventory
20+
and passed after the eight artifact renames. The expanded checker has its
21+
own unit controls and a real source-checkout run in CI.
22+
23+
Creusot with Pearlite contracts and Verus are `OPEN`, not run for this CI
24+
utility; the executable controls are tests, not a formal Windows filesystem
25+
or Chapel proof. Exact hosted results remain in this change's pull request.
26+
27+
The repository Actions policy was brought into the already approved canonical
28+
namespace-transfer policy by adding
29+
`metadatastician/standards/.github/workflows/*@*`. Existing allowlist entries,
30+
GitHub/verified-creator settings and mandatory SHA pinning were preserved.
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
// SPDX-License-Identifier: MPL-2.0
2+
//! Checkout-only CI check; deliberately outside Cargo's integration tests.
3+
use std::{collections::BTreeMap, path::Path, process::Command};
4+
5+
fn portable_component(component: &str) -> bool {
6+
if component.is_empty()
7+
|| component.ends_with(['.', ' '])
8+
|| component
9+
.chars()
10+
.any(|c| c.is_control() || "<>:\"\\|?*".contains(c))
11+
{
12+
return false;
13+
}
14+
let stem = component
15+
.split('.')
16+
.next()
17+
.unwrap_or("")
18+
.to_ascii_uppercase();
19+
let numbered_device = stem
20+
.strip_prefix("COM")
21+
.or_else(|| stem.strip_prefix("LPT"));
22+
!matches!(
23+
stem.as_str(),
24+
"CON" | "PRN" | "AUX" | "NUL" | "CONIN$" | "CONOUT$"
25+
) && !numbered_device.is_some_and(|n| {
26+
matches!(
27+
n,
28+
"1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "¹" | "²" | "³"
29+
)
30+
})
31+
}
32+
33+
fn inventory_errors(paths: &[&str]) -> Vec<String> {
34+
let mut errors = Vec::new();
35+
let mut seen = BTreeMap::<String, (String, bool)>::new();
36+
for path in paths {
37+
let components: Vec<_> = path.split('/').collect();
38+
let mut prefix = String::new();
39+
for (index, component) in components.iter().enumerate() {
40+
if !portable_component(component) {
41+
errors.push(format!("invalid component in {path:?}"));
42+
}
43+
if !prefix.is_empty() {
44+
prefix.push('/');
45+
}
46+
prefix.push_str(component);
47+
let file = index + 1 == components.len();
48+
let key = prefix.to_uppercase();
49+
if let Some((old, old_file)) = seen.get(&key) {
50+
if old != &prefix || *old_file != file {
51+
errors.push(format!(
52+
"case or file/directory collision: {old:?} and {prefix:?}"
53+
));
54+
}
55+
} else {
56+
seen.insert(key, (prefix.clone(), file));
57+
}
58+
}
59+
}
60+
errors
61+
}
62+
63+
fn check_checkout(root: &Path) -> Result<(), String> {
64+
let root = root.canonicalize().map_err(|e| e.to_string())?;
65+
let top = Command::new("git")
66+
.current_dir(&root)
67+
.args(["rev-parse", "--show-toplevel"])
68+
.output()
69+
.map_err(|e| format!("git is required: {e}"))?;
70+
if !top.status.success() {
71+
return Err("the requested root is not a Git checkout".into());
72+
}
73+
let top = std::str::from_utf8(&top.stdout)
74+
.map_err(|e| e.to_string())?
75+
.trim();
76+
if Path::new(top).canonicalize().map_err(|e| e.to_string())? != root {
77+
return Err("refusing to inspect an enclosing repository's index".into());
78+
}
79+
let output = Command::new("git")
80+
.current_dir(&root)
81+
.args(["ls-files", "-z"])
82+
.output()
83+
.map_err(|e| e.to_string())?;
84+
if !output.status.success() {
85+
return Err("git ls-files failed".into());
86+
}
87+
let text = std::str::from_utf8(&output.stdout).map_err(|e| e.to_string())?;
88+
let paths: Vec<_> = text.split('\0').filter(|p| !p.is_empty()).collect();
89+
if paths.is_empty() {
90+
return Err("empty inventory cannot establish portability".into());
91+
}
92+
let errors = inventory_errors(&paths);
93+
if !errors.is_empty() {
94+
return Err(errors.join("\n"));
95+
}
96+
println!(
97+
"{} tracked paths passed the portability checks",
98+
paths.len()
99+
);
100+
Ok(())
101+
}
102+
103+
fn main() -> Result<(), String> {
104+
let root = std::env::args_os()
105+
.nth(1)
106+
.ok_or("usage: check-repository-paths REPOSITORY_ROOT")?;
107+
check_checkout(Path::new(&root))
108+
}
109+
110+
#[cfg(test)]
111+
mod tests {
112+
use super::*;
113+
#[test]
114+
fn windows_device_and_component_controls() {
115+
for bad in [
116+
"report:12.json",
117+
"CON",
118+
"nul.txt",
119+
"COM1.log",
120+
"LPT9",
121+
"COM¹.txt",
122+
"COM²",
123+
"COM³",
124+
"LPT¹",
125+
"LPT²",
126+
"LPT³",
127+
"CONIN$",
128+
"CONOUT$",
129+
"tail.",
130+
"tail ",
131+
"a?b",
132+
"a\\b",
133+
"line\nbreak",
134+
] {
135+
assert!(!portable_component(bad), "accepted {bad:?}");
136+
}
137+
for good in [
138+
"assemblyline-2026-04-12T11-23-37Z.json",
139+
".github",
140+
"Cargo.toml",
141+
"com10.txt",
142+
] {
143+
assert!(portable_component(good), "rejected {good:?}");
144+
}
145+
}
146+
#[test]
147+
fn inventory_detects_case_and_file_directory_collisions() {
148+
for paths in [
149+
vec!["reports/Run.json", "reports/run.json"],
150+
vec!["src/Foo/a.rs", "src/foo/b.rs"],
151+
vec!["foo", "FOO/bar.rs"],
152+
] {
153+
assert!(
154+
!inventory_errors(&paths).is_empty(),
155+
"accepted collision: {paths:?}"
156+
);
157+
}
158+
assert!(inventory_errors(&["src/a.rs", "src/b.rs"]).is_empty());
159+
}
160+
}

‎tests/repository_paths.rs‎

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)