Skip to main content

ac_algorithm/
solution.rs

1//! Solution snapshots: the source file is the source of truth; metadata
2//! records identity and the hash of the exact byte string under test.
3
4use std::path::PathBuf;
5use std::time::SystemTime;
6
7use serde::{Deserialize, Serialize};
8
9use crate::ids::{SolutionId, TaskId};
10
11/// A recorded solution for a task.
12///
13/// `source_path` points at the editable file (the source of truth per
14/// `product-requirements.md` ยง5); `source_sha256` pins the byte string that
15/// tests and submissions refer to, so preview/test/submit always agree on
16/// the same content (ADR-0005 invariant 3).
17#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
18pub struct Solution {
19    /// Solution identifier.
20    pub id: SolutionId,
21    /// Task this solution targets.
22    pub task: TaskId,
23    /// Path to the editable source file.
24    pub source_path: PathBuf,
25    /// Lowercase hex SHA-256 of the source bytes at snapshot time.
26    pub source_sha256: String,
27    /// Local revision counter, bumped on each recorded snapshot.
28    pub revision: u64,
29    /// When the snapshot was recorded.
30    pub created_at: SystemTime,
31}