M5a plan, task 04: check.rs given complete; later tests use no tags
Task 04's second session stopped too. It checked its code against the markup test cases in its reasoning, and the tag it spelled out ended its reasoning. Building tags from pieces keeps them out of files, not out of the model's thoughts. check.rs is now given whole, with the tags from pieces, and task 04 fills only entries.rs. The three later tests that used a tag only as something the check refuses now use an instruction phrase or an invisible character. They pass against the reference. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -71,19 +71,32 @@ const PHRASES: &[&str] = &[
|
||||
|
||||
/// Whether `c` is refused by rule 2.
|
||||
pub fn invisible(c: char) -> bool {
|
||||
// `let code = u32::from(c)`. True when ALSO_INVISIBLE contains it, or it lies in one of the
|
||||
// DEFAULT_IGNORABLE ranges, both ends included: `(low..=high).contains(&code)`.
|
||||
todo!()
|
||||
let code = u32::from(c);
|
||||
ALSO_INVISIBLE.contains(&code)
|
||||
|| DEFAULT_IGNORABLE
|
||||
.iter()
|
||||
.any(|&(low, high)| (low..=high).contains(&code))
|
||||
}
|
||||
|
||||
/// The first rule `text` breaks, in the order of the spec, or `Ok`.
|
||||
pub fn check(text: &str) -> Result<(), Refused> {
|
||||
// Return the first that applies, in this order.
|
||||
// 1. Any char with `c.is_control()` that is not '\n' and not '\t' -> Err(Refused::Control).
|
||||
// 2. Any char for which `invisible(c)` -> Err(Refused::Invisible).
|
||||
// 3. Lower-case the text (`to_lowercase()`); if it contains any string of MARKUP ->
|
||||
// Err(Refused::Markup).
|
||||
// 4. Collapse whitespace: the words of the lower-cased text (`split_whitespace()`) joined by
|
||||
// one space; if that contains any of PHRASES -> Err(Refused::Phrase). Otherwise Ok(()).
|
||||
todo!()
|
||||
if text
|
||||
.chars()
|
||||
.any(|c| c.is_control() && c != '\n' && c != '\t')
|
||||
{
|
||||
return Err(Refused::Control);
|
||||
}
|
||||
if text.chars().any(invisible) {
|
||||
return Err(Refused::Invisible);
|
||||
}
|
||||
let lower = text.to_lowercase();
|
||||
if MARKUP.iter().any(|m| lower.contains(m)) {
|
||||
return Err(Refused::Markup);
|
||||
}
|
||||
// Runs of spaces, tabs and newlines count as one space.
|
||||
let collapsed = lower.split_whitespace().collect::<Vec<_>>().join(" ");
|
||||
if PHRASES.iter().any(|p| collapsed.contains(p)) {
|
||||
return Err(Refused::Phrase);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user