fix(anatomy): R5.4 authored backticks refused, underscores paired across code spans refused; sweep cites probe_ref and probe_ref_
This commit is contained in:
1 parent
aff3a96d55
commit
bc5d0ad038
7 files changed
+91
-29
No files matched your search
@@ -280,7 +280,7 @@ faunosteo/
|
||||
├─ packages/README.md ← shared packages index
|
||||
├─ packages/core-wasm/ ← @faunosteo/core-wasm: CoreRuntime (lazy, poison, recovery) + CoreExportSession (R4.6) + Node source, pkg/ shipped and pkg-proofs/ (built, git-ignored, BUILD_STAMP), ts-rs types (committed), frozen N-1 reader (tests/n-1), tests
|
||||
├─ crates/ ← Rust workspace (Cargo.toml, rust-toolchain.toml, deny.toml, clippy.toml, .cargo/config.toml at the root)
|
||||
│ ├─ core/ ← faunosteo-core: domain/{js,sheet,report,archive,editor,session} (contracts and rules), anatomy/{svg/{prescan,tree,sanitize,refs,number,serialize},layer,compose} (R3: the one SVG reader, the layer, canvas + highlight composition), pdf/{read,json_js,import,write,compare} (R4: reader, writer and session, the archive check tool behind feature `cli`), ops.rs + facade.rs (`call`, `call_with_sheet`), json (JS number printing), curation/{text,ids,prettier_json,markdown,legacy/*,draft/*} (R5, feature `curation`: Prettier layout, the legacy importer, the changeset applier, migration map, stats, seed SQL, CHANGELOG, REVIEW-REPORT, review drawings), bin/report_compare.rs (`pnpm report:compare`) + bin/import_equine.rs (`pnpm r5:import-equine`, the two files allowed std::fs); tests/{oracles,conformance,fixtures,pdf/LEDGER.tsv} frozen from the TypeScript (oracles/r3, oracles/r4, fixtures/svg/hostile); no I/O, no clock (lint-enforced)
|
||||
│ ├─ core/ ← faunosteo-core: domain/{js,sheet,report,archive,editor,session} (contracts and rules), anatomy/{svg/{prescan,tree,sanitize,refs,number,serialize},layer,compose} (R3: the one SVG reader, the layer, canvas + highlight composition), pdf/{read,json_js,import,write,compare} (R4: reader, writer and session, the archive check tool behind feature `cli`), ops.rs + facade.rs (`call`, `call_with_sheet`), json (JS number printing), curation/{text,ids,prettier_json,markdown,report_guard,legacy/*,draft/*} (R5, feature `curation`: Prettier layout, the legacy importer, the changeset applier, migration map, stats, seed SQL, CHANGELOG, REVIEW-REPORT, review drawings), bin/report_compare.rs (`pnpm report:compare`) + bin/import_equine.rs (`pnpm r5:import-equine`, the two files allowed std::fs); tests/{oracles,conformance,fixtures,pdf/LEDGER.tsv} frozen from the TypeScript (oracles/r3, oracles/r4, fixtures/svg/hostile); no I/O, no clock (lint-enforced)
|
||||
│ ├─ wasm/ ← faunosteo-wasm: wasm-bindgen facade (core_version, call, SheetHandle; trap exports in the proofs build only)
|
||||
│ └─ worker/ ← faunosteo-worker: plain main; `decode` sandboxed child (rlimits, seccomp allowlist, image → libwebp), parent Spawner + RIFF check; R1 `run` loop: config, log (JSON lines, allowlist), keys, backend trait + http (ureq, PostgREST rpc + Storage objects), job, sweep, watchdog; Dockerfile, scripts/derive-seccomp.sh
|
||||
├─ scripts/{rust-env,rust-check,wasm-build,check-all,avatar-e2e,report-compare,import-equine}.sh, wasm-stamp.mjs ← native Rust gate, wasm build (pkg + pkg-proofs + stamp), the pre-merge gate (`pnpm check:all`), the real-stack avatar e2e, the archive check tool (`pnpm report:compare`), the Rust pipeline (`pnpm r5:import-equine`)
|
||||
|
||||
@@ -13,6 +13,7 @@ use super::stats::{DocumentStats, stat_rows};
|
||||
use super::targets::fail;
|
||||
use crate::curation::PipelineError;
|
||||
use crate::curation::markdown::{Cell, code, table};
|
||||
use crate::curation::report_guard::assert_authored;
|
||||
use crate::json::to_js_compact;
|
||||
|
||||
/// The longest value text a table cell shows, in UTF-16 units (`text.length`).
|
||||
@@ -51,6 +52,11 @@ pub fn compact_value(value: &Value) -> Result<String, PipelineError> {
|
||||
))
|
||||
}
|
||||
|
||||
fn authored(text: String) -> Result<String, PipelineError> {
|
||||
assert_authored(&text)?;
|
||||
Ok(text)
|
||||
}
|
||||
|
||||
/// `recordSubject`: the target, with its field when there is one.
|
||||
pub fn record_subject(record: &ChangeRecord) -> String {
|
||||
match &record.field {
|
||||
@@ -60,6 +66,9 @@ pub fn record_subject(record: &ChangeRecord) -> String {
|
||||
}
|
||||
|
||||
fn record_row(record: &ChangeRecord) -> Result<Vec<Cell>, PipelineError> {
|
||||
// Authored texts reach the cells raw: no backtick (code spans are the generator's).
|
||||
assert_authored(&record.change.title.fr)?;
|
||||
assert_authored(&record.change.rationale)?;
|
||||
let change = &record.change;
|
||||
let references: Vec<String> = change
|
||||
.reference_ids
|
||||
@@ -79,8 +88,8 @@ fn record_row(record: &ChangeRecord) -> Result<Vec<Cell>, PipelineError> {
|
||||
Ok(vec![
|
||||
Cell::from(format!("{} {}", code(Some(&change.id)), change.title.fr)),
|
||||
Cell::from(code(Some(&record_subject(record)))),
|
||||
Cell::from(compact_value(&record.before)?),
|
||||
Cell::from(compact_value(&record.after)?),
|
||||
Cell::from(authored(compact_value(&record.before)?)?),
|
||||
Cell::from(authored(compact_value(&record.after)?)?),
|
||||
Cell::from(kind_label(change.kind)),
|
||||
Cell::from(change.rationale.as_str()),
|
||||
Cell::from(references),
|
||||
|
||||
@@ -18,6 +18,7 @@ use super::targets::{Step, TargetKind, all_findings, at, top_collection_path, zo
|
||||
use crate::curation::PipelineError;
|
||||
use crate::curation::legacy::types::Anomaly;
|
||||
use crate::curation::markdown::{Cell, code, table};
|
||||
use crate::curation::report_guard::assert_authored;
|
||||
use crate::curation::text::utf16_cmp;
|
||||
|
||||
pub struct ReviewReportInput<'a> {
|
||||
@@ -361,7 +362,7 @@ fn assert_single_line(text: &str) -> Result<(), PipelineError> {
|
||||
if text.chars().any(char::is_control) {
|
||||
return Err(PipelineError::UnsupportedMarkdown(text.to_owned()));
|
||||
}
|
||||
Ok(())
|
||||
assert_authored(text)
|
||||
}
|
||||
|
||||
fn assert_list_items_single_line(input: &ReviewReportInput<'_>) -> Result<(), PipelineError> {
|
||||
|
||||
@@ -3,15 +3,18 @@
|
||||
//! rewrites Markdown in authored text (escapes, emphasis, whitespace, links). Rather than
|
||||
//! chase every such rewrite, the guard admits an allowlist proven identical by the TypeScript
|
||||
//! sweep (`oracles/r5/markdown-sweep.json`, hand-picked and seeded random probes) and by the
|
||||
//! equine reports, and refuses everything else with `UnsupportedMarkdown`: a report is either
|
||||
//! byte for byte the TypeScript's or not written.
|
||||
//! equine reports, and refuses everything else with `UnsupportedMarkdown`. Within what the probes
|
||||
//! cover, a report is either byte for byte the TypeScript's or not written; a combination of
|
||||
//! admitted characters no rule names and no probe covers could still differ (RUST.md §11.15).
|
||||
//!
|
||||
//! Admitted outside code spans: letters and digits, single spaces (none at a line end), the
|
||||
//! punctuation of `PUNCTUATION`, an underscore between two ASCII letters or digits and not
|
||||
//! glued to a URL, a backslash before `"` or `|` (a JSON quote, the cell escape), `**word**`
|
||||
//! (one run of letters between spaces or line edges, the import report's form), no inline
|
||||
//! construct (`rewritten_construct`). Inside code spans (the generated ids and targets):
|
||||
//! anything but a carriage return or a tab, never empty, no outer space.
|
||||
//! anything but a carriage return or a tab, never empty, no outer space; an authored text holds
|
||||
//! no backtick (`assert_authored`), and a plain underscore is never followed by another one on its
|
||||
//! line.
|
||||
|
||||
use super::PipelineError;
|
||||
use super::markdown::{format_markdown, split_row};
|
||||
@@ -171,15 +174,47 @@ fn guard_text(text: &str) -> bool {
|
||||
if parts.len().is_multiple_of(2) || text.contains(['\r', '\t']) || text.ends_with(' ') {
|
||||
return false;
|
||||
}
|
||||
parts.iter().enumerate().all(|(index, part)| {
|
||||
let admitted = parts.iter().enumerate().all(|(index, part)| {
|
||||
if index % 2 == 1 {
|
||||
!part.is_empty() && !part.starts_with(' ') && !part.ends_with(' ')
|
||||
} else {
|
||||
admitted_plain(part)
|
||||
}
|
||||
});
|
||||
admitted && !underscore_pairs_later(&parts)
|
||||
}
|
||||
|
||||
/// Prettier's parser pairs a plain-text underscore with a later underscore that can close an
|
||||
/// emphasis: one inside a later code span followed by anything but an ASCII letter or digit,
|
||||
/// the span's closing backtick included (`to_do … \`ref_\`` became `to*do … \`ref*\``). A
|
||||
/// plain underscore is always between ASCII letters or digits here, so it never closes; the
|
||||
/// equine `{"min_x":60,"min_y":100,…}` stays admitted.
|
||||
fn underscore_pairs_later(parts: &[&str]) -> bool {
|
||||
let closes = |code: &str| {
|
||||
let chars: Vec<char> = code.chars().collect();
|
||||
(0..chars.len())
|
||||
.any(|i| chars[i] == '_' && chars.get(i + 1).is_none_or(|c| !c.is_ascii_alphanumeric()))
|
||||
};
|
||||
parts.iter().enumerate().any(|(index, part)| {
|
||||
index % 2 == 0
|
||||
&& part.contains('_')
|
||||
&& parts[index + 1..]
|
||||
.iter()
|
||||
.enumerate()
|
||||
.any(|(offset, later)| (index + 1 + offset) % 2 == 1 && closes(later))
|
||||
})
|
||||
}
|
||||
|
||||
/// An authored text the reports write must carry no backtick: code spans come from the
|
||||
/// generator alone (ids, targets, field names), never from an author (a backtick there let a
|
||||
/// link or a URL run into a code span, Prettier rewriting both).
|
||||
pub fn assert_authored(text: &str) -> Result<(), PipelineError> {
|
||||
if text.contains('`') {
|
||||
return Err(refuse(text));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Refuses a raw report line outside the allowlist, cell by cell in a table row.
|
||||
fn guard_line(line: &str) -> Result<(), PipelineError> {
|
||||
let admitted = if line.starts_with('|') {
|
||||
|
||||
@@ -28,7 +28,10 @@ fn oracle() -> Value {
|
||||
}
|
||||
|
||||
/// The raw CHANGELOG and REVIEW-REPORT of a probe, as the port writes them.
|
||||
fn raw_reports(frozen: &Value, case: &Value) -> (String, Result<String, PipelineError>) {
|
||||
fn raw_reports(
|
||||
frozen: &Value,
|
||||
case: &Value,
|
||||
) -> (Result<String, PipelineError>, Result<String, PipelineError>) {
|
||||
let baseline = &frozen["baseline"];
|
||||
let references =
|
||||
parse_references(&to_js_compact(&json!({ "references": frozen["references"] })).unwrap())
|
||||
@@ -52,7 +55,7 @@ fn raw_reports(frozen: &Value, case: &Value) -> (String, Result<String, Pipeline
|
||||
})
|
||||
.unwrap();
|
||||
let changes: Vec<_> = changeset.changes.iter().map(|c| c.summary()).collect();
|
||||
let changelog = render_changelog(&result.records, &before, &after, &stats).unwrap();
|
||||
let changelog = render_changelog(&result.records, &before, &after, &stats);
|
||||
let review = render_review_report(&ReviewReportInput {
|
||||
changes: &changes,
|
||||
records: &result.records,
|
||||
@@ -70,12 +73,11 @@ const EQUINE_SAFE: &str = "[]&#{}=<>\"':;()/%?-.,«»…≠°—+";
|
||||
fn equine_safe(probe: &str) -> bool {
|
||||
// A leading or trailing space becomes two spaces once the probe sits in its sentence; the
|
||||
// inline constructs (links, wiki links, autolinks, character references) are probed apart.
|
||||
let tag = probe
|
||||
.split('<')
|
||||
.skip(1)
|
||||
.any(|after| after.starts_with(|c: char| c.is_ascii_alphabetic() || "/!?".contains(c)));
|
||||
let tag = probe.match_indices('<').any(|(at, _)| {
|
||||
probe[at + 1..].starts_with(|c: char| c.is_ascii_alphabetic() || "/!?".contains(c))
|
||||
});
|
||||
let construct = tag
|
||||
|| ["](", "][", "![", "[[ ", " ]]", "&"]
|
||||
|| ["](", "][", "![", "[[ ", " ]]", "&", "`"]
|
||||
.iter()
|
||||
.any(|m| probe.contains(m));
|
||||
!construct
|
||||
@@ -95,16 +97,21 @@ fn every_probe_is_formatted_as_the_typescript_or_refused() {
|
||||
let probe = case["probe"].as_str().unwrap();
|
||||
let (changelog, review) = raw_reports(&frozen, case);
|
||||
let digest = |text: &str| sha256_hex(text.as_bytes());
|
||||
assert_eq!(
|
||||
digest(&changelog),
|
||||
case["changelog_raw_sha256"],
|
||||
"{probe:?} raw"
|
||||
);
|
||||
if let Ok(changelog) = &changelog {
|
||||
assert_eq!(
|
||||
digest(changelog),
|
||||
case["changelog_raw_sha256"],
|
||||
"{probe:?} raw"
|
||||
);
|
||||
}
|
||||
if let Ok(review) = &review {
|
||||
assert_eq!(digest(review), case["review_raw_sha256"], "{probe:?} raw");
|
||||
}
|
||||
let outcomes = [
|
||||
(format_report(&changelog), &case["changelog_sha256"]),
|
||||
(
|
||||
changelog.and_then(|text| format_report(&text)),
|
||||
&case["changelog_sha256"],
|
||||
),
|
||||
(
|
||||
review.and_then(|text| format_report(&text)),
|
||||
&case["review_sha256"],
|
||||
@@ -121,8 +128,9 @@ fn every_probe_is_formatted_as_the_typescript_or_refused() {
|
||||
Err(other) => panic!("{probe:?}: {other}"),
|
||||
}
|
||||
}
|
||||
let closer = case["reference_id"] == "probe_ref_";
|
||||
assert!(
|
||||
!(case_refused && equine_safe(probe)),
|
||||
!(case_refused && equine_safe(probe) && !closer),
|
||||
"{probe:?}: refused, yet made of what the equine reports use"
|
||||
);
|
||||
if case_refused {
|
||||
@@ -137,6 +145,6 @@ fn every_probe_is_formatted_as_the_typescript_or_refused() {
|
||||
"silent differences for {} probes: {silent:?}",
|
||||
silent.len()
|
||||
);
|
||||
assert_eq!(same + refused, 782);
|
||||
assert_eq!(same + refused, 790);
|
||||
println!("{same} identical, {refused} refused");
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
{"baseline":{"schema_version":2,"species_id":"equine","name":{"fr":"Mini","en":"Mini"},"description":{},"scope_disclaimer":{},"attribution":{"authors":[],"license":null,"notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18}]},"references":[],"categories":[{"id":"joints","name":{"fr":"Articulations","en":"Joints"},"color":null},{"id":"bones","name":{"fr":"Os","en":"Bones"},"color":null}],"views":[{"id":"main","kind":"main","name":{"fr":"Vue","en":"View"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null},{"id":"head","kind":"detail","parent_view_id":"main","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":0,"min_y":0,"width":10,"height":10}}],"annotations":[{"id":"hip","kind":"point","view_id":"main","category_id":"joints","laterality":"bilateral","geometry":{"type":"circle","cx":1,"cy":2,"r":3},"name":{"fr":"Hanche","en":"Hip"},"finding_zone_id":"hip","vertebral_region_code":null},{"id":"neck","kind":"zone","view_id":"main","category_id":"bones","laterality":"unpaired","geometry":null,"name":{"fr":"Cou","en":"Neck"},"finding_zone_id":"neck","vertebral_region_code":"C"},{"id":"head-trigger","kind":"detail_trigger","view_id":"main","category_id":"bones","laterality":"unpaired","geometry":null,"name":null,"opens_view_id":"head"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche","en":"Hip"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions","en":"Dysfunctions"},"children":[{"id":"mobility","name":{"fr":"mobility fr","en":"mobility en"},"children":[{"id":"flexion","name":{"fr":"flexion fr","en":"flexion en"}},{"id":"extension","name":{"fr":"extension fr","en":"extension en"}}]},{"id":"pain","name":{"fr":"pain fr","en":"pain en"}}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse","en":"Anamnesis"},"children":[{"id":"trauma","name":{"fr":"trauma fr","en":"trauma en"}}]}]},{"id":"neck","name":{"fr":"Cou","en":"Neck"},"categories":[{"id":"neck-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions","en":"Dysfunctions"},"children":[{"id":"stiffness","name":{"fr":"stiffness fr","en":"stiffness en"}},{"id":"vet","name":{"fr":"vet fr","en":"vet en"},"requires_vet_referral":true}]}]}]},"references":[{"id":"atlas","type":"book","citation":"Atlas of anatomy","url":null,"doi":null},{"id":"paper","type":"journal","citation":"A paper","url":null,"doi":"10.1/x"}],"legacy_id_map":{"views":{"head":"head"},"annotations":{"legacy-hip":"hip","legacy-neck":"neck"},"categories":{},"finding_nodes":{},"assets":{}},"cases":[{"probe":"*","changes_file":{"changes":[{"id":"CHG-001","level":"C","kind":"correction","title":{"fr":"Titre *","en":"Title"},"rationale":"Raison * fin.","reference_ids":[],"question":"Question * ?","ops":[{"op":"add","target":"document","field":"references","value":{"id":"probe-ref","type":"web","citation":"Citation *","url":null,"doi":null}},{"op":"cite","target":"finding:hip/hip-dysfunctions/mobility","reference_ids":["probe-ref"]},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility","field":"name.en","value":"Label *"},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility/flexion","field":"name.fr","value":"*"}]}]},"changelog_raw_sha256":"55b992587e03e05c2b98e81e7c644aa852713084183a89cd2651b61f0e922cbb","changelog_sha256":"1e21c6e4509109bba34c869cf8df77f838e69cfdc85df203a71917b1cd25cca7","review_raw_sha256":"3f289d6d2f18fef8f99ea375703603f2b0f1076063f7440a7554ed081b1f63aa","review_sha256":"2fef9ccf08ff9e38ff59e7ca7b6fa4966e8f4ddea9188c666276adb0c59f41db"},{"probe":"*x","changes_file":{"changes":[{"id":"CHG-001","level":"C","kind":"correction","title":{"fr":"Titre *x","en":"Title"},"rationale":"Raison *x fin.","reference_ids":[],"question":"Question *x ?","ops":[{"op":"add","target":"document","field":"references","value":{"id":"probe-ref","type":"web","citation":"Citation *x","url":null,"doi":null}},{"op":"cite","target":"finding:hip/hip-dysfunctions/mobility","reference_ids":["probe-ref"]},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility","field":"name.en","value":"Label *x"},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility/flexion","field":"name.fr","value":"*x"}]}]},"changelog_raw_sha256":"bcb9602df19f1a01322e79fb099fd4031f40c3863ecf904daf6e107ceec9f8a6","changelog_sha256":"23d0c545ce56bc949d88d6ad5d99104aba582f851fc8f8689901cc57d9400399","review_raw_sha256":"cff4115989dd4c411d94893c5b1a19333169b53fd0a6c4dd668ba771f7e97332","review_sha256":"382d3968e4d03960e4cca33109a06b6af0db8cc53b8aec01cf940004ab91755e"},{"probe":"x*","changes_file":{"changes":[{"id":"CHG-001","level":"C","kind":"correction","title":{"fr":"Titre x*","en":"Title"},"rationale":"Raison x* fin.","reference_ids":[],"question":"Question x* ?","ops":[{"op":"add","target":"document","field":"references","value":{"id":"probe-ref","type":"web","citation":"Citation x*","url":null,"doi":null}}Line truncated
|
||||
{"baseline":{"schema_version":2,"species_id":"equine","name":{"fr":"Mini","en":"Mini"},"description":{},"scope_disclaimer":{},"attribution":{"authors":[],"license":null,"notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18}]},"references":[],"categories":[{"id":"joints","name":{"fr":"Articulations","en":"Joints"},"color":null},{"id":"bones","name":{"fr":"Os","en":"Bones"},"color":null}],"views":[{"id":"main","kind":"main","name":{"fr":"Vue","en":"View"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null},{"id":"head","kind":"detail","parent_view_id":"main","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":0,"min_y":0,"width":10,"height":10}}],"annotations":[{"id":"hip","kind":"point","view_id":"main","category_id":"joints","laterality":"bilateral","geometry":{"type":"circle","cx":1,"cy":2,"r":3},"name":{"fr":"Hanche","en":"Hip"},"finding_zone_id":"hip","vertebral_region_code":null},{"id":"neck","kind":"zone","view_id":"main","category_id":"bones","laterality":"unpaired","geometry":null,"name":{"fr":"Cou","en":"Neck"},"finding_zone_id":"neck","vertebral_region_code":"C"},{"id":"head-trigger","kind":"detail_trigger","view_id":"main","category_id":"bones","laterality":"unpaired","geometry":null,"name":null,"opens_view_id":"head"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche","en":"Hip"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions","en":"Dysfunctions"},"children":[{"id":"mobility","name":{"fr":"mobility fr","en":"mobility en"},"children":[{"id":"flexion","name":{"fr":"flexion fr","en":"flexion en"}},{"id":"extension","name":{"fr":"extension fr","en":"extension en"}}]},{"id":"pain","name":{"fr":"pain fr","en":"pain en"}}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse","en":"Anamnesis"},"children":[{"id":"trauma","name":{"fr":"trauma fr","en":"trauma en"}}]}]},{"id":"neck","name":{"fr":"Cou","en":"Neck"},"categories":[{"id":"neck-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions","en":"Dysfunctions"},"children":[{"id":"stiffness","name":{"fr":"stiffness fr","en":"stiffness en"}},{"id":"vet","name":{"fr":"vet fr","en":"vet en"},"requires_vet_referral":true}]}]}]},"references":[{"id":"atlas","type":"book","citation":"Atlas of anatomy","url":null,"doi":null},{"id":"paper","type":"journal","citation":"A paper","url":null,"doi":"10.1/x"}],"legacy_id_map":{"views":{"head":"head"},"annotations":{"legacy-hip":"hip","legacy-neck":"neck"},"categories":{},"finding_nodes":{},"assets":{}},"cases":[{"probe":"*","reference_id":"probe_ref","changes_file":{"changes":[{"id":"CHG-001","level":"C","kind":"correction","title":{"fr":"Titre *","en":"Title"},"rationale":"Raison * fin.","reference_ids":[],"question":"Question * ?","ops":[{"op":"add","target":"document","field":"references","value":{"id":"probe_ref","type":"web","citation":"Citation *","url":null,"doi":null}},{"op":"cite","target":"finding:hip/hip-dysfunctions/mobility","reference_ids":["probe_ref"]},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility","field":"name.en","value":"Label *"},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility/flexion","field":"name.fr","value":"*"}]}]},"changelog_raw_sha256":"77926ee5c69c45be2f9576e04a7e3430b45c203bc667c5f1b51ac3a21e7ae4d9","changelog_sha256":"a84644e09477bf50e413ebe1e8240ccc04657488381b093755d349a35e494843","review_raw_sha256":"a3fc194f01e61c8ae010271894c962b40b8ef4b23987adb9d7712190839734df","review_sha256":"6b2208027f21d2b663a202a8d39accb640f9cae26bbceaa701b2754bdd6f8342"},{"probe":"*x","reference_id":"probe_ref","changes_file":{"changes":[{"id":"CHG-001","level":"C","kind":"correction","title":{"fr":"Titre *x","en":"Title"},"rationale":"Raison *x fin.","reference_ids":[],"question":"Question *x ?","ops":[{"op":"add","target":"document","field":"references","value":{"id":"probe_ref","type":"web","citation":"Citation *x","url":null,"doi":null}},{"op":"cite","target":"finding:hip/hip-dysfunctions/mobility","reference_ids":["probe_ref"]},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility","field":"name.en","value":"Label *x"},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility/flexion","field":"name.fr","value":"*x"}]}]},"changelog_raw_sha256":"a29af5d1b46d52b0de4a334e31e16aa4765c976865fee8ed0b2e00b7f60af4f4","changelog_sha256":"b150e9617d14894c9c33a2c95feab51b4b59245b74a78d48015569ffc300dec3","review_raw_sha256":"0e6605a31ba79a30d66e8ab8fe3858b4c305a816ea7b1e130201e8300611e218","review_sha256":"8693621d140233c9c7708c943621e61586289d0f8a72b93ca2e071eb58a5d45f"},{"probe":"x*","reference_id":"probe_ref","changes_file":{"changes":[{"id":"CHG-001","level":"C","kind":"correction","title":{"fr":"Titre x*","en":"Title"},"rationale":"Raison x* fin.","reference_ids":[],"question":"Question x* ?","ops":[{"op":"add","target":"document","field":"references","valueLine truncated
|
||||
@@ -113,6 +113,11 @@ const PATTERNS = [
|
||||
'中文',
|
||||
'مرحبا',
|
||||
'e\u0301',
|
||||
'Mesure a_b `c_`',
|
||||
'Champ snake_case, voir x_y fin',
|
||||
'to_do',
|
||||
'voir [a `](b)` c',
|
||||
'voir https://x.org/`<a`',
|
||||
'a * b',
|
||||
'*',
|
||||
'_',
|
||||
@@ -180,7 +185,7 @@ function probes(): string[] {
|
||||
return [...CHARACTERS.flatMap(positions), ...PATTERNS, ...randomProbes(400)]
|
||||
}
|
||||
|
||||
function changesFile(probe: string) {
|
||||
function changesFile(probe: string, referenceId: string) {
|
||||
return {
|
||||
changes: [
|
||||
{
|
||||
@@ -197,7 +202,7 @@ function changesFile(probe: string) {
|
||||
target: 'document',
|
||||
field: 'references',
|
||||
value: {
|
||||
id: 'probe-ref',
|
||||
id: referenceId,
|
||||
type: 'web',
|
||||
citation: `Citation ${probe}`,
|
||||
url: null,
|
||||
@@ -207,7 +212,7 @@ function changesFile(probe: string) {
|
||||
{
|
||||
op: 'cite',
|
||||
target: 'finding:hip/hip-dysfunctions/mobility',
|
||||
reference_ids: ['probe-ref'],
|
||||
reference_ids: [referenceId],
|
||||
},
|
||||
{
|
||||
op: 'set',
|
||||
@@ -227,8 +232,8 @@ function changesFile(probe: string) {
|
||||
}
|
||||
}
|
||||
|
||||
async function run(probe: string) {
|
||||
const file = changesFile(probe)
|
||||
async function run(probe: string, referenceId = 'probe_ref') {
|
||||
const file = changesFile(probe, referenceId)
|
||||
const changeset = ChangesetSchema.parse(file)
|
||||
const baseline = miniSheet()
|
||||
const result = applyChangeset(baseline, MINI_REFERENCES, changeset)
|
||||
@@ -252,6 +257,7 @@ async function run(probe: string) {
|
||||
})
|
||||
return {
|
||||
probe,
|
||||
reference_id: referenceId,
|
||||
changes_file: file,
|
||||
changelog_raw_sha256: sha256(changelogRaw),
|
||||
changelog_sha256: sha256(await formatMarkdown(changelogRaw)),
|
||||
@@ -264,6 +270,9 @@ describe('R5.4 Markdown sweep oracle', () => {
|
||||
it('markdown-sweep.json', async () => {
|
||||
const rows = []
|
||||
for (const probe of probes()) rows.push(await run(probe))
|
||||
// A cited id ending with `_` puts a closing underscore in a generated code span.
|
||||
for (const probe of ['to_do', 'a_b c', 'x'])
|
||||
rows.push(await run(probe, 'probe_ref_'))
|
||||
const oracle = {
|
||||
baseline: miniSheet(),
|
||||
references: MINI_REFERENCES,
|
||||
|
||||
Reference in new issue
Block a user