Integrate the ignored-workspace corpus into verification

Give the Git Sentry launch shape one Rust owner, update the physical corpus to supply every authority, and make the default repository gate distinguish unavailable physical prerequisites from corpus failures.
This commit is contained in:
ms2k 2026-07-19 02:39:45 +09:00
commit a0055f67f1
3 changed files with 210 additions and 17 deletions

View file

@ -1,8 +1,7 @@
use std::env;
use std::io::{self, Read, Write};
use std::path::PathBuf;
use lazaret_ignored_workspace::{GitSentry, GitSentryConfiguration};
use lazaret_ignored_workspace::{GitSentry, GitSentryLaunch};
fn main() {
if let Err(error) = run() {
@ -12,18 +11,8 @@ fn main() {
}
fn run() -> io::Result<()> {
let arguments = env::args_os().skip(1).collect::<Vec<_>>();
if arguments.len() != 4 {
return Err(io::Error::other(
"usage: lazaret-git-sentry MOUNTED_WORKSPACE HOST_GIT_COMMON_DIRECTORY TRANSIENT_HOOKS TRANSIENT_CONFIG",
));
}
let sentry = GitSentry::install(&GitSentryConfiguration {
mounted_workspace: PathBuf::from(&arguments[0]),
host_git_common_directory: PathBuf::from(&arguments[1]),
transient_hooks: PathBuf::from(&arguments[2]),
transient_config: PathBuf::from(&arguments[3]),
})?;
let launch = GitSentryLaunch::parse(env::args_os().skip(1).collect())?;
let sentry = GitSentry::install(&launch.configuration())?;
println!("ready");
io::stdout().flush()?;
io::stdin().read_to_end(&mut Vec::new())?;

View file

@ -7,4 +7,4 @@ mod sentry;
pub use classifier::{Classification, ClassificationSnapshot, GitClassifier, git_common_directory};
pub use daemon::{PRIVATE_ROUTER_ROLE, dispatch_private_router};
pub use filesystem::{IgnoredWorkspace, MountConfiguration};
pub use sentry::{GitSentry, GitSentryConfiguration};
pub use sentry::{GitSentry, GitSentryConfiguration, GitSentryLaunch};

View file

@ -1,3 +1,4 @@
use std::ffi::OsString;
use std::fs::File;
use std::io;
use std::path::{Path, PathBuf};
@ -18,6 +19,53 @@ pub struct GitSentryConfiguration {
pub transient_config: PathBuf,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct GitSentryLaunch {
arguments: [PathBuf; 4],
}
impl GitSentryLaunch {
#[must_use]
pub fn new(configuration: GitSentryConfiguration) -> Self {
Self {
arguments: [
configuration.mounted_workspace,
configuration.host_git_common_directory,
configuration.transient_hooks,
configuration.transient_config,
],
}
}
/// # Errors
/// Refuses any argument count other than the exact Git Sentry launch shape.
pub fn parse(arguments: Vec<OsString>) -> io::Result<Self> {
let arguments: [OsString; 4] = arguments.try_into().map_err(|_| {
io::Error::other(
"usage: lazaret-git-sentry MOUNTED_WORKSPACE HOST_GIT_COMMON_DIRECTORY TRANSIENT_HOOKS TRANSIENT_CONFIG",
)
})?;
Ok(Self {
arguments: arguments.map(PathBuf::from),
})
}
#[must_use]
pub fn configuration(&self) -> GitSentryConfiguration {
GitSentryConfiguration {
mounted_workspace: self.arguments[0].clone(),
host_git_common_directory: self.arguments[1].clone(),
transient_hooks: self.arguments[2].clone(),
transient_config: self.arguments[3].clone(),
}
}
#[must_use]
pub fn arguments(&self) -> [OsString; 4] {
self.arguments.clone().map(PathBuf::into_os_string)
}
}
pub struct GitSentry {
config: InstalledMount,
hooks: InstalledMount,
@ -266,3 +314,42 @@ fn require_regular_file(file: &File) -> io::Result<()> {
Err(io::Error::other("host Git config is not a regular file"))
}
}
#[cfg(test)]
mod tests {
use std::ffi::OsString;
use std::path::PathBuf;
use super::{GitSentryConfiguration, GitSentryLaunch};
fn configuration() -> GitSentryConfiguration {
GitSentryConfiguration {
mounted_workspace: PathBuf::from("/workspace"),
host_git_common_directory: PathBuf::from("/host/.git"),
transient_hooks: PathBuf::from("/transient/hooks"),
transient_config: PathBuf::from("/transient/config"),
}
}
#[test]
fn launch_arguments_round_trip_through_the_binary_parser() {
let launch = GitSentryLaunch::new(configuration());
let parsed = GitSentryLaunch::parse(launch.arguments().into()).unwrap();
assert_eq!(parsed, launch);
assert_eq!(
parsed.configuration().transient_config,
PathBuf::from("/transient/config")
);
}
#[test]
fn launch_parser_requires_every_ordered_authority() {
for count in [0, 1, 2, 3, 5] {
let arguments = (0..count)
.map(|index| OsString::from(format!("/{index}")))
.collect();
assert!(GitSentryLaunch::parse(arguments).is_err());
}
}
}