ocs_doc_api: Phase 5-ii — typed Table create

- CreateTable(TableSpec{insertion_point, data[row][col]}) op (append-only).
- backend add_table via Table::new(insertion_point, rows, cols) + set_cell_text
  (Table::default() pre-creates 3x3, so use Table::new for exact dims).
- executor validates non-empty rectangular grid; facade create_table.
- spec Table constructor; api_reference + binding_schema regenerated; mocks + baseline.
- Test phase5ii_create_table_from_grid (3x2 grid, non-rectangular rejected)
  -> 615 host lib + 3 consistency green. Phase 5 complete.
This commit is contained in:
Sebastian committed 2026-09-06 13:02:21 +02:00
1 parent f8ae54a351
commit 240831edcd
12 files changed
+117 -7

No files matched your search

+7
View File
@@ -146,6 +146,13 @@ impl DocApiBackend for MockBackend {
}
Ok(self.alloc("AttributeDefinition"))
}
fn add_table(&mut self, spec: &ocs_doc_api::ops::TableSpec) -> ApiResult<ObjectId> {
let cols = spec.data.first().map(|r| r.len()).unwrap_or(0);
if spec.data.is_empty() || cols == 0 || spec.data.iter().any(|r| r.len() != cols) {
return Err(ApiError::validation("CreateTable", "table needs a non-empty rectangular grid"));
}
Ok(self.alloc("Table"))
}
fn set_attribute(&mut self, id: ObjectId, tag: &str, value: &str) -> ApiResult<()> {
if !self.entity_exists(id) {
return Err(ApiError::UnknownId(id));
@@ -70,6 +70,7 @@ fn operation_variants() -> Vec<String> {
Operation::CreateAttributeDefinition(ocs_doc_api::ops::AttributeDefinitionSpec {
tag: String::new(), prompt: String::new(), default_value: String::new(), insertion_point: [0.0; 3], height: 0.0, rotation: 0.0,
}),
Operation::CreateTable(ocs_doc_api::ops::TableSpec { insertion_point: [0.0; 3], data: vec![] }),
];
// Derive the variant names by serializing a probe of each and reading the
// bincode variant index -> name map is not available; instead match by
@@ -163,6 +164,7 @@ const OPERATION_BASELINE: &[&str] = &[
"CreateDimensionDiameter",
"CreateDimensionAngular",
"CreateAttributeDefinition",
"CreateTable",
];
/// Recorded baseline of the `Query` variant order.