Use the codec audit and repair in place of OCS's corruption guard

Opening a drawing no longer drops entities with its own sanity checks or
rewrites knotless splines; recovery runs the codec's repair and records
its actions and unresolved issues in the drawing's notifications. Xref
merges keep every entity. The dropped-entity counts, their command-line
warnings, recovery report rows and the automation "purged" field go with
the guard.

AUDIT now reports the codec's audit (counts plus the first 50 issues) and
asks whether to fix; Yes applies the codec repair as one undo step.

Cargo: codec 325fa98, kernel dfca391, graph 5d4e713.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-16 12:02:39 +03:00
1 parent 3c9404510f
commit 04b2c07a38
43 files changed
+192 -763

No files matched your search

+1 -2
View File
@@ -1009,10 +1009,9 @@ impl OpenCADStudio {
"new" => {
if let Some(template) = req["template"].as_str() {
match self.apply_template(template) {
Ok(purged) => {
Ok(()) => {
self.set_control_result(json!({
"template": template,
"purged": purged,
"total": self.tabs[i].scene.document.entities().count(),
}));
Task::none()
+4 -4
View File
@@ -434,7 +434,7 @@ impl OpenCADStudio {
/// `new` with `"template"` — the web build reads no files from a path, so
/// a template is refused there rather than silently ignored.
#[cfg(target_arch = "wasm32")]
pub(in crate::app) fn apply_template(&mut self, _template: &str) -> Result<usize, Value> {
pub(in crate::app) fn apply_template(&mut self, _template: &str) -> Result<(), Value> {
Err(failure(
"invalid_request",
"starting from a template needs the desktop build",
@@ -445,7 +445,7 @@ impl OpenCADStudio {
/// file. Tables and styles come from the template; the document keeps no
/// source path.
#[cfg(not(target_arch = "wasm32"))]
pub(in crate::app) fn apply_template(&mut self, template: &str) -> Result<usize, Value> {
pub(in crate::app) fn apply_template(&mut self, template: &str) -> Result<(), Value> {
let path = std::path::PathBuf::from(template);
let bytes = self
.read_drawing(&path)
@@ -461,7 +461,7 @@ impl OpenCADStudio {
} else {
path.clone()
};
let (mut document, purged) = crate::io::load_bytes_finalized(&load_path, bytes)
let mut document = crate::io::load_bytes_finalized(&load_path, bytes)
.map_err(|e| failure("template_failed", e))?;
document.source_path = Some(path.to_string_lossy().into_owned());
let i = self.active_tab;
@@ -482,7 +482,7 @@ impl OpenCADStudio {
// A whole document just became resident in the tab (API v9): the
// boundary announces `DocumentOpened` once.
self.tabs[i].note_document_loaded();
Ok(purged)
Ok(())
}
/// `file_identity` — stable per-document GUID (the drawing's SPMDOCUNIQUE value,