fix(mcp,store,core): four refusals are decided before the call's first line (P15 T1, D-88)
A refusal is decided before anything is written; a failed call on the record is for a call that failed part way. Four tools wrote a line and then refused, so under T1 each left a begun line, its lines and a failed closing line in the journal for a plain "no": - books.attach_receipt and books.file_document: bytes already filed are one file, so filing them again links the existing attachment; a link it already holds was refused after the earlier links were written. The store now asks first (Store::check_filing_links). - books.draft_entry and books.draft_from_template: a no_party_reason that names a full tax id was refused by the mark, after the draft was made. Ledger::check_no_party_reason is asked first. - books.dispose_asset: a receipt named twice was refused at its second link, after the disposal was posted. The ids are checked for repeats first. Each has a test that the journal is byte for byte as it was. No journal format or frame shape changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
bc55a10101
commit
38612ab553
11 files changed
+192
-2
No files matched your search
@@ -4765,6 +4765,25 @@ impl Store {
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether filing `bytes` and linking them to `link_to` would be
|
||||
/// refused for a link the file already has: bytes already filed are one
|
||||
/// file, so a link the existing attachment holds is refused
|
||||
/// (`AlreadyLinked`). Asked before the filing writes its first line, so
|
||||
/// a call that is refused for it has written nothing (a refusal is
|
||||
/// decided before anything is written, D-88).
|
||||
pub fn check_filing_links(&self, bytes: &[u8], link_to: &[Subject]) -> Result<(), StoreError> {
|
||||
let Some(existing) = self.live_attachment_with_sha(&sha256_hex(bytes))? else {
|
||||
return Ok(());
|
||||
};
|
||||
let held = self.attachment_links(existing.id)?;
|
||||
for sub in link_to {
|
||||
if held.contains(sub) {
|
||||
return Err(StoreError::AlreadyLinked(existing.id, sub.describe()));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// File a document under a category (`formation`, `legal`, `tax`,
|
||||
/// `accounting`, `other`).
|
||||
pub fn file_document(
|
||||
|
||||
Reference in new issue
Block a user