wip: shield index relations, dev evaluation tasks, Q-063 audit notes

Verifier borrow/provenance work, new phase3 shield_index conformance cases,
dev-intervals/dev-lru/dev-shards tasks with evaluate.py harness, and agent skill/hook config.
This commit is contained in:
dev committed 2026-10-17 12:30:37 +03:00
1 parent 2d750a0525
commit e3fc896a0a
68 files changed
+2132 -37

No files matched your search

@@ -0,0 +1,6 @@
[package]
name = "lru"
version = "0.1.0"
edition = "2021"
[dependencies]
@@ -0,0 +1,61 @@
use std::collections::HashMap;
use std::io::{Read, Write};
fn token(t: &str) -> bool {
(1..=16).contains(&t.len()) && t.bytes().all(|b| b.is_ascii_lowercase() || b.is_ascii_digit())
}
fn main() {
let mut input = String::new();
std::io::stdin().read_to_string(&mut input).unwrap();
let mut lines: Vec<&str> = input.split('\n').collect();
if input.ends_with('\n') {
lines.pop();
}
let cap: usize = lines[0]["capacity ".len()..].parse().unwrap();
// key -> (value, last use); recency is the use counter.
let mut map: HashMap<String, (String, u64)> = HashMap::new();
let (mut clock, mut hits, mut misses, mut evictions) = (0u64, 0u64, 0u64, 0u64);
let mut out = String::new();
for line in &lines[1..] {
let parts: Vec<&str> = line.split(' ').collect();
let args = &parts[1..];
if !args.iter().all(|a| token(a)) {
out.push_str("error\n");
continue;
}
clock += 1;
match (parts[0], args) {
("put", [k, v]) => {
if map.contains_key(*k) {
out.push_str("ok\n");
} else if map.len() == cap {
let old = map.iter().min_by_key(|(_, (_, t))| *t).map(|(k, _)| k.clone()).unwrap();
map.remove(&old);
evictions += 1;
out.push_str(&format!("evict {old}\n"));
} else {
out.push_str("ok\n");
}
map.insert(k.to_string(), (v.to_string(), clock));
}
("get", [k]) => match map.get_mut(*k) {
Some((v, t)) => { *t = clock; hits += 1; out.push_str(&format!("{v}\n")); }
None => { misses += 1; out.push_str("miss\n"); }
},
("peek", [k]) => out.push_str(&format!("{}\n", map.get(*k).map_or("miss", |(v, _)| v.as_str()))),
("del", [k]) => out.push_str(if map.remove(*k).is_some() { "ok\n" } else { "miss\n" }),
("stats", []) => out.push_str(&format!("size {} hits {hits} misses {misses} evictions {evictions}\n", map.len())),
("dump", []) => {
let mut keys: Vec<(&String, u64)> = map.iter().map(|(k, (_, t))| (k, *t)).collect();
keys.sort_by(|a, b| b.1.cmp(&a.1));
let s: Vec<&str> = keys.iter().map(|(k, _)| k.as_str()).collect();
out.push_str(if s.is_empty() { "empty" } else { "" });
out.push_str(&s.join(" "));
out.push('\n');
}
_ => out.push_str("error\n"),
}
}
std::io::stdout().write_all(out.as_bytes()).unwrap();
}
+29
View File
@@ -0,0 +1,29 @@
#!/bin/sh
# Public test: the example from the task statement.
cargo build -q --offline || { echo "FAIL: build"; exit 1; }
got=$(printf '%s' 'capacity 2
put a 1
put b 2
get a
put c 3
peek b
dump
get b
stats
put a 9
get a
del zz
' | ./target/debug/lru) || { echo "FAIL: the program exited with an error"; exit 1; }
expected=$(printf "%s" 'ok
ok
1
evict b
miss
c a
miss
size 2 hits 1 misses 1 evictions 1
ok
9
miss
')
if [ "$got" = "$expected" ]; then echo PASS; else echo "FAIL"; echo "--- expected"; printf '%s' "$expected"; echo "--- got"; printf '%s' "$got"; exit 1; fi