Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .stkr/project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ include = ["**/*.rs", "**/*.py", "**/Cargo.toml", "mise.toml", ".stkr/project.to
exclude = ["crates/dokime-gui/src-tauri/src/rpc/generated.rs"]

[barrels]
# Deliberate public façades, not accidental re-export files: the authoring
# prelude and the one namespace a sidecar author imports from.
exclude = ["crates/dokime-runtime/src/prelude.rs", "crates/dokime-runtime/src/plugin/sidecar.rs"]
# Deliberate Public Import Surfaces: Authoring, Criterion Evidence And GUI Test Ports.
exclude = [
"crates/dokime-runtime/src/prelude.rs",
"crates/dokime-runtime/src/plugin/sidecar.rs",
"crates/dokime-runtime/src/evidence.rs",
"crates/dokime-gui/src-tauri/src/testing.rs",
]

[markdown]
include = ["**/README.md", "CHANGELOG.md", "CONTRIBUTING.md", "SECURITY.md", "LICENSE.md", ".github/**", "openspec/**", "docs/**/*.md"]
Expand Down
12 changes: 9 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,23 @@ restores generated contracts and extracts the Rust archive once before concurren
readers start. Standalone Rust lanes also reuse one extraction for listing and
execution; standalone system runs unpack their binaries and shared runtime inputs
without the other test layers, keeping extraction within hosted disk capacity.
The entry runs all ten
lanes even if one fails and returns failure if any lane fails. Full lane logs,
The aggregate owns a native mise task lock across preparation, consumers and
collection. Its referenced tasks share that permit and run concurrently; the
ordinary one-task default remains in place for standalone language tasks.
Canonical mise task references schedule all eleven product lanes concurrently,
plus the tooling integration tests. Each prepared leaf records its actual exit
code; the final collection returns failure for any failed or missing result. Full lane logs,
exit codes, wall times and an aggregate `time-summary.md`/`.json` live under
`target/test-reports/run-<profile>-<native>/`; every lane also keeps its own time
summary under `target/test-reports/<category>-<language>/`. Individual lane tasks
remain independently usable; avoid running the same lane twice in one checkout.
Run tooling alone with `mise run test:python:integration --project tools/python`;
add `--select schedule` to select its scheduling tests.
Only one native desktop lane may use an interactive desktop session at a time,
including runs from other worktrees. Reserve an idle test host for wall-clock
comparisons; simultaneous external test runs can trip existing liveness guards.

The scheduler reserves CPU headroom for the desktop and divides the remaining
Shared preparation reserves CPU headroom for the desktop and divides the remaining
logical CPU slots across the four Rust nextest lanes, Python integration and both
Vitest lanes. All seven pools use that worker count. Standalone
Rust lanes keep nextest's CPU-sized pool; standalone Python integration uses
Expand Down
26 changes: 0 additions & 26 deletions crates/dokime-packaging/src/installer/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,32 +423,6 @@ name='x'"
);
}

#[test]
fn license_file_containment() {
let pack = tempfile::tempdir().unwrap();
let outside = tempfile::tempdir().unwrap();
std::fs::create_dir(pack.path().join("terms")).unwrap();
std::fs::write(pack.path().join("terms/EULA.txt"), "terms").unwrap();
std::fs::write(outside.path().join("EULA.txt"), "terms").unwrap();
let escape = format!("../{}/EULA.txt", outside.path().file_name().unwrap().to_str().unwrap());

let mut license = License {
spdx: Some("LicenseRef-Acme-Proprietary".into()),
file: Some("terms/EULA.txt".into()),
};
license.resolve(pack.path()).unwrap();
assert_eq!(license.file.as_deref(), Some(pack.path().join("terms/EULA.txt").canonicalize().unwrap().as_path()));

for file in [escape.as_str(), "/EULA.txt", "C:/EULA.txt", r"terms\EULA.txt", "missing.txt", "terms"] {
let mut license = License {
spdx: Some("LicenseRef-Acme-Proprietary".into()),
file: Some(file.into()),
};
let Err(Error::License { field, .. }) = license.resolve(pack.path()) else { panic!("{file}") };
assert_eq!(field, "file", "{file}");
}
}

#[test]
fn native_formats() {
let format = if cfg!(target_os = "windows") { "nsis" } else { "deb" };
Expand Down
2 changes: 2 additions & 0 deletions crates/dokime-packaging/tests/integration/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/* === Modules === */

mod license_file_containment;

/* === Re-Exports === */

/* === Imports === */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* ***
*
* Dokime
*
* SPDX-License-Identifier: Apache-2.0
*
* ***
*/

// Terms File Containment Through The Public Manifest Reader

/* === Modules === */

/* === Re-Exports === */

/* === Imports === */

// Standard Library Imports

// Third Party Imports

// Local Imports
use dokime_packaging::{Error, installer::Manifest};

/* === Constants === */

/* === Macros === */

/* === Type Aliases === */

/* === Structs === */

/* === Enums === */

/* === Traits === */

/* === Implementations === */

/* === Public Functions === */

/* === Private Functions === */

/* === Tests === */

#[test]
fn license_file_containment() {
let pack = tempfile::tempdir().unwrap();
let outside = tempfile::tempdir().unwrap();
std::fs::create_dir(pack.path().join("terms")).unwrap();
std::fs::write(pack.path().join("terms/EULA.txt"), "terms").unwrap();
std::fs::write(outside.path().join("EULA.txt"), "terms").unwrap();
let escape = format!("../{}/EULA.txt", outside.path().file_name().unwrap().to_str().unwrap());

let manifest = pack.path().join("installer.toml");
let read = |file: &str| {
let text = format!(
"[installer]\nversion='1.2.3'\nformats=[]\n[dokime]\nversion='1.2.3'\n[license]\nspdx='LicenseRef-Acme-Proprietary'\nfile={file:?}"
);
std::fs::write(&manifest, text).unwrap();
Manifest::read(&manifest)
};
let license = read("terms/EULA.txt").unwrap().license.unwrap();
assert_eq!(license.file.as_deref(), Some(pack.path().join("terms/EULA.txt").canonicalize().unwrap().as_path()));

for file in [escape.as_str(), "/EULA.txt", "C:/EULA.txt", r"terms\EULA.txt", "missing.txt", "terms"] {
let Err(Error::License { field, .. }) = read(file) else { panic!("{file}") };
assert_eq!(field, "file", "{file}");
}
}
45 changes: 0 additions & 45 deletions crates/dokime-runtime/src/artifacts/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,48 +396,3 @@ fn read(path: &Path, from: u64, pending: u64, sweeping: bool) -> io::Result<Vec<
}

/* === Tests === */

#[cfg(all(test, feature = "native"))]
mod tests {
use super::*;
use crate::artifacts::Artifacts;

struct Sink;

impl ArtifactSink for Sink {
fn push(&self, _: ArtifactChunk) {}
}

#[test]
fn temporary_artifacts_cleanup_without_sweep() {
for failure in [false, true] {
let artifacts = Artifacts::new("temporary-owner", Arc::new(Sink));
let root = artifacts.root().unwrap();
let area = root.parent().unwrap().to_owned();
std::fs::write(root.join("evidence.bin"), b"captured evidence").unwrap();
let outcome = std::panic::catch_unwind(std::panic::AssertUnwindSafe(move || {
let _owner = artifacts;
assert!(!failure, "injected artifact fixture failure");
}));
assert_eq!(outcome.is_err(), failure);
assert!(!area.exists(), "artifact scratch survived owner teardown: {}", area.display());
}
}

#[test]
fn temporary_artifacts_follow_the_last_clone_and_isolate_equal_tokens() {
let first = Artifacts::new("same-token", Arc::new(Sink));
let second = Artifacts::new("same-token", Arc::new(Sink));
let first_root = first.root().unwrap();
let second_root = second.root().unwrap();
assert_ne!(first_root, second_root);
let retained = first.clone();
drop(first);
assert!(first_root.exists());
drop(retained);
assert!(!first_root.exists());
assert!(second_root.exists());
drop(second);
assert!(!second_root.exists());
}
}
5 changes: 0 additions & 5 deletions crates/dokime-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,3 @@ pub mod brand {
}

/* === Tests === */

// Public Within The Unit-Test Build Only: Each Target Uses Its Own Part Of The Shared Story Support.
#[cfg(all(test, feature = "native"))]
#[path = "../tests/support/services/mod.rs"]
pub mod service_support;
8 changes: 1 addition & 7 deletions crates/dokime-runtime/src/report/render/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,12 +828,11 @@ mod tests {
}

#[test]
fn fixture_report_save_measurement() {
fn fixture_report_save_preserves_bytes_and_decodes_once_per_member() {
use crate::report::{CapturedExecutionReportInput, cycle::CycleMember};
use std::{
io::{BufWriter, Read},
sync::atomic::Ordering,
time::Instant,
};
let captured: CapturedExecutionReportInput = serde_json::from_str(include_str!("../fixtures/execution-report-input.json")).unwrap();
let input = harmos::storage::ReadBatch::new(captured);
Expand All @@ -850,22 +849,19 @@ mod tests {
read: &read,
};
let mut baseline_file = None;
let started = Instant::now();
for _ in 0..20 {
let mut writer = BufWriter::with_capacity(1024 * 1024, tempfile::tempfile().unwrap());
drop(member.read().unwrap());
report.write(&mut writer).unwrap();
writer.flush().unwrap();
baseline_file = Some(writer.into_inner().unwrap());
}
let before = started.elapsed() / 20;
let mut baseline_bytes = Vec::new();
let mut baseline_file = baseline_file.unwrap();
std::io::Seek::rewind(&mut baseline_file).unwrap();
baseline_file.read_to_end(&mut baseline_bytes).unwrap();
let baseline_decodes = member.decodes.load(Ordering::Relaxed);
let mut candidate_file = None;
let started = Instant::now();
for _ in 0..20 {
let mut writer = BufWriter::with_capacity(1024 * 1024, tempfile::tempfile().unwrap());
let captured = member.read().unwrap();
Expand All @@ -876,14 +872,12 @@ mod tests {
writer.flush().unwrap();
candidate_file = Some(writer.into_inner().unwrap());
}
let after = started.elapsed() / 20;
let mut candidate_bytes = Vec::new();
let mut candidate_file = candidate_file.unwrap();
std::io::Seek::rewind(&mut candidate_file).unwrap();
candidate_file.read_to_end(&mut candidate_bytes).unwrap();
assert_eq!(member.decodes.load(Ordering::Relaxed) - baseline_decodes, 20);
assert!(baseline_decodes > 20);
assert_eq!(candidate_bytes, baseline_bytes);
eprintln!("Fixture Report Save: before={before:?}, after={after:?}, bytes={}", candidate_bytes.len());
}
}
1 change: 1 addition & 0 deletions crates/dokime-runtime/tests/integration/artifacts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

pub(crate) mod diagnostics;
pub(crate) mod publication;
mod temporary_cleanup;

/* === Re-Exports === */

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* ***
*
* Dokime
*
* SPDX-License-Identifier: Apache-2.0
*
* ***
*/

// Artifact Scratch Ownership Across Clones And Unwinding

/* === Modules === */

/* === Re-Exports === */

/* === Imports === */

// Standard Library Imports
use std::sync::Arc;

// Third Party Imports

// Local Imports
use dokime_runtime::{
artifacts::{ArtifactSink, Artifacts},
transport::ArtifactChunk,
};

/* === Constants === */

/* === Macros === */

/* === Type Aliases === */

/* === Structs === */

struct Sink;

/* === Enums === */

/* === Traits === */

/* === Implementations === */

impl ArtifactSink for Sink {
fn push(&self, _: ArtifactChunk) {}
}

/* === Public Functions === */

/* === Private Functions === */

/* === Tests === */

#[test]
fn temporary_artifacts_cleanup_without_sweep() {
for failure in [false, true] {
let artifacts = Artifacts::new("temporary-owner", Arc::new(Sink));
let root = artifacts.root().unwrap();
let area = root.parent().unwrap().to_owned();
std::fs::write(root.join("evidence.bin"), b"captured evidence").unwrap();
let outcome = std::panic::catch_unwind(std::panic::AssertUnwindSafe(move || {
let _owner = artifacts;
assert!(!failure, "injected artifact fixture failure");
}));
assert_eq!(outcome.is_err(), failure);
assert!(!area.exists(), "artifact scratch survived owner teardown: {}", area.display());
}
}

#[test]
fn temporary_artifacts_follow_the_last_clone_and_isolate_equal_tokens() {
let first = Artifacts::new("same-token", Arc::new(Sink));
let second = Artifacts::new("same-token", Arc::new(Sink));
let first_root = first.root().unwrap();
let second_root = second.root().unwrap();
assert_ne!(first_root, second_root);
let retained = first.clone();
drop(first);
assert!(first_root.exists());
drop(retained);
assert!(!first_root.exists());
assert!(second_root.exists());
drop(second);
assert!(!second_root.exists());
}
Loading
Loading