Notes were written to a file and shown back nowhere — the shape trials.py's own docstring calls this project's signature failure in a new medium. The log now carries the player's comments where they were made. Position is the feature: a remark like "why did that do nothing?" is about the move above it, and collected at the bottom it is a sentence with no subject. round/step cannot order a note against the log because several commands share a step, so the server records how many commands had been played — which it knows exactly — and the page places it there. A comment must not be readable as something the game did. The log is the recorder's vocabulary; notes render in their own block, attributed to the player, quoted. The .note CSS already existed and nothing had ever used it. No column was added to the trial log. trials.py skipped any row that was not five cells, silently, so a sixth column would have made `make trials` report zero notes for every log at once. That latent defect is fixed on its own terms: a wrong column count now raises, and the walk reports the real reason rather than blaming a missing block for every failure. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
499d9fe3d7
commit
4ddff3b17c
8 changed files with 455 additions and 26 deletions
|
|
@ -587,7 +587,7 @@ mod affordances {
|
|||
mod gamelog {
|
||||
//! CB-WP-0018 T02.
|
||||
|
||||
use crate::doc::{document_with_log, LogLine};
|
||||
use crate::doc::{document_with_log, Account, LogLine};
|
||||
use cb_kernel::PlayerId;
|
||||
|
||||
fn line(effects: &[&str]) -> LogLine {
|
||||
|
|
@ -598,6 +598,104 @@ mod gamelog {
|
|||
}
|
||||
}
|
||||
|
||||
fn note(after: usize, text: &str) -> crate::doc::LogNote {
|
||||
crate::doc::LogNote {
|
||||
after,
|
||||
round: 2,
|
||||
step: "Select".into(),
|
||||
text: text.into(),
|
||||
}
|
||||
}
|
||||
|
||||
/// CB-WP-0032. A comment appears where it was written.
|
||||
///
|
||||
/// **Position is the whole feature.** A remark like *"why did that do
|
||||
/// nothing?"* is about the move above it; collected at the bottom it
|
||||
/// is a list of sentences with no subjects.
|
||||
#[test]
|
||||
fn comments_appear_in_the_log_where_they_were_written() {
|
||||
let lines = vec![line(&["e0"]), line(&["e1"]), line(&["e2"])];
|
||||
let html = document_with_log(
|
||||
&crate::testfix::view(Some(PlayerId(0))),
|
||||
&[],
|
||||
crate::TEST_ENDPOINTS,
|
||||
Some(PlayerId(0)),
|
||||
false,
|
||||
Account {
|
||||
lines: &lines,
|
||||
notes: &[
|
||||
note(0, "before I moved"),
|
||||
note(2, "why did that do nothing"),
|
||||
],
|
||||
},
|
||||
&[],
|
||||
);
|
||||
let text = crate::text_of(&html);
|
||||
let at = |needle: &str| {
|
||||
text.find(needle)
|
||||
.unwrap_or_else(|| panic!("missing {needle:?}"))
|
||||
};
|
||||
// Written before any move: above the first effect.
|
||||
assert!(at("before I moved") < at("e0"), "{text}");
|
||||
// Written after two commands: after the second, before the third.
|
||||
assert!(at("e1") < at("why did that do nothing"), "{text}");
|
||||
assert!(at("why did that do nothing") < at("e2"), "{text}");
|
||||
}
|
||||
|
||||
/// A comment must not be readable as something the game did.
|
||||
///
|
||||
/// The log is the RECORDER's vocabulary — what the scenario file will
|
||||
/// say. A note styled like a log line would be a sentence the game
|
||||
/// never produced, sitting in the account of what the game produced,
|
||||
/// and `ADR-0014 D4` turns on that distinction being visible.
|
||||
#[test]
|
||||
fn a_comment_is_not_dressed_as_a_game_event() {
|
||||
let lines = vec![line(&["e0"])];
|
||||
let html = document_with_log(
|
||||
&crate::testfix::view(Some(PlayerId(0))),
|
||||
&[],
|
||||
crate::TEST_ENDPOINTS,
|
||||
Some(PlayerId(0)),
|
||||
false,
|
||||
Account {
|
||||
lines: &lines,
|
||||
notes: &[note(1, "select_action action=SOLVE")],
|
||||
},
|
||||
&[],
|
||||
);
|
||||
assert!(
|
||||
html.contains("class=\"note\""),
|
||||
"the note had no marking of its own"
|
||||
);
|
||||
let text = crate::text_of(&html);
|
||||
// Attributed to the player, and to a position.
|
||||
assert!(text.contains("you \u{2014} round 2, Select"), "{text}");
|
||||
}
|
||||
|
||||
/// A post-game note is written when every command has been played, so
|
||||
/// its `after` can exceed a log this page happens to be showing. It
|
||||
/// must still appear — a dropped comment is the failure the whole
|
||||
/// note channel exists to avoid.
|
||||
#[test]
|
||||
fn a_comment_past_the_end_of_the_log_is_still_shown() {
|
||||
let html = document_with_log(
|
||||
&crate::testfix::view(Some(PlayerId(0))),
|
||||
&[],
|
||||
crate::TEST_ENDPOINTS,
|
||||
Some(PlayerId(0)),
|
||||
false,
|
||||
Account {
|
||||
lines: &[],
|
||||
notes: &[note(9, "so that is why it failed")],
|
||||
},
|
||||
&[],
|
||||
);
|
||||
assert!(
|
||||
crate::text_of(&html).contains("so that is why it failed"),
|
||||
"a comment was silently dropped"
|
||||
);
|
||||
}
|
||||
|
||||
fn page(log: &[LogLine]) -> String {
|
||||
document_with_log(
|
||||
&crate::testfix::view(Some(PlayerId(0))),
|
||||
|
|
@ -605,7 +703,7 @@ mod gamelog {
|
|||
crate::TEST_ENDPOINTS,
|
||||
Some(PlayerId(0)),
|
||||
false,
|
||||
log,
|
||||
Account::of(log),
|
||||
&[],
|
||||
)
|
||||
}
|
||||
|
|
@ -1133,7 +1231,7 @@ mod notes {
|
|||
crate::TEST_ENDPOINTS,
|
||||
Some(PlayerId(0)),
|
||||
false,
|
||||
&[],
|
||||
crate::doc::Account::of(&[]),
|
||||
&[hostile.to_string()],
|
||||
);
|
||||
assert!(
|
||||
|
|
@ -1161,7 +1259,7 @@ mod notes {
|
|||
crate::TEST_ENDPOINTS,
|
||||
Some(PlayerId(0)),
|
||||
false,
|
||||
&[],
|
||||
crate::doc::Account::of(&[]),
|
||||
&[],
|
||||
);
|
||||
assert!(
|
||||
|
|
@ -1189,7 +1287,7 @@ mod two_columns {
|
|||
crate::TEST_ENDPOINTS,
|
||||
Some(PlayerId(0)),
|
||||
false,
|
||||
&[],
|
||||
crate::doc::Account::of(&[]),
|
||||
meta,
|
||||
)
|
||||
}
|
||||
|
|
@ -1360,7 +1458,14 @@ mod ending_page {
|
|||
use crate::{doc, jsrun};
|
||||
|
||||
fn page() -> String {
|
||||
doc::ending(None, "the game ended", "/command?t=x", None, &[], &[])
|
||||
doc::ending(
|
||||
None,
|
||||
"the game ended",
|
||||
"/command?t=x",
|
||||
None,
|
||||
crate::doc::Account::of(&[]),
|
||||
&[],
|
||||
)
|
||||
}
|
||||
|
||||
/// The label must say what the control DOES. Asserted on the rendered
|
||||
|
|
@ -1439,7 +1544,14 @@ mod ending_page {
|
|||
#[test]
|
||||
fn click_targets_do_not_wear_the_drag_affordance() {
|
||||
let pages = [
|
||||
doc::ending(None, "m", "/command?t=x", None, &[], &[]),
|
||||
doc::ending(
|
||||
None,
|
||||
"m",
|
||||
"/command?t=x",
|
||||
None,
|
||||
crate::doc::Account::of(&[]),
|
||||
&[],
|
||||
),
|
||||
doc::document(
|
||||
&crate::testfix::view(Some(PlayerId(0))),
|
||||
&[games_ground::GroundCommand::SelectAction {
|
||||
|
|
@ -1490,7 +1602,14 @@ mod ending_page {
|
|||
o.group_success = false;
|
||||
}
|
||||
let head = |v: &games_ground::view::GroundView| {
|
||||
crate::text_of(&doc::ending(Some(v), "m", "/command?t=x", None, &[], &[]))
|
||||
crate::text_of(&doc::ending(
|
||||
Some(v),
|
||||
"m",
|
||||
"/command?t=x",
|
||||
None,
|
||||
crate::doc::Account::of(&[]),
|
||||
&[],
|
||||
))
|
||||
};
|
||||
assert!(
|
||||
head(&won).contains("game solved"),
|
||||
|
|
@ -1512,7 +1631,7 @@ mod ending_page {
|
|||
"P1 ran out of input",
|
||||
"/command?t=x",
|
||||
None,
|
||||
&[],
|
||||
crate::doc::Account::of(&[]),
|
||||
&[],
|
||||
));
|
||||
assert!(!none.contains("game solved") && !none.contains("game over"));
|
||||
|
|
@ -1526,7 +1645,14 @@ mod ending_page {
|
|||
fn a_cooperative_game_shows_contributions_and_refuses_to_rank_them() {
|
||||
let mut v = crate::testfix::view(None);
|
||||
v.mode = games_ground::ScoringMode::SharedGround;
|
||||
let text = crate::text_of(&doc::ending(Some(&v), "m", "/command?t=x", None, &[], &[]));
|
||||
let text = crate::text_of(&doc::ending(
|
||||
Some(&v),
|
||||
"m",
|
||||
"/command?t=x",
|
||||
None,
|
||||
crate::doc::Account::of(&[]),
|
||||
&[],
|
||||
));
|
||||
|
||||
assert!(
|
||||
text.contains("problems solved"),
|
||||
|
|
@ -1549,7 +1675,14 @@ mod ending_page {
|
|||
fn a_ranked_mode_cites_the_games_own_tiebreak() {
|
||||
let mut v = crate::testfix::view(None);
|
||||
v.mode = games_ground::ScoringMode::BondedCoalitions;
|
||||
let text = crate::text_of(&doc::ending(Some(&v), "m", "/command?t=x", None, &[], &[]));
|
||||
let text = crate::text_of(&doc::ending(
|
||||
Some(&v),
|
||||
"m",
|
||||
"/command?t=x",
|
||||
None,
|
||||
crate::doc::Account::of(&[]),
|
||||
&[],
|
||||
));
|
||||
|
||||
assert!(
|
||||
text.contains("Lower combined Stress"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue