fix(tcs): retry invalid history revisit frames
This commit is contained in:
parent
ab3c4e05a9
commit
bccf7e7494
3 changed files with 35 additions and 5 deletions
|
|
@ -153,7 +153,7 @@ export class MotherBrainEngine {
|
|||
if (input.source_excerpt_sha256 !== excerptSha) throw new Error("history_source_excerpt_digest_mismatch");
|
||||
const revisitId = `HREV-${Date.now()}-${crypto.randomBytes(3).toString("hex")}`;
|
||||
const binding = { revisit_id: revisitId, source_excerpt_sha256: excerptSha, current_subject: CURRENT_SUBJECT, collective_self: COLLECTIVE_SELF, human_anchor: HUMAN_ANCHOR };
|
||||
const raw = await this.modelClient.revisit({
|
||||
const modelInput = {
|
||||
...binding,
|
||||
source: { source_id: source.source_id, source_type: source.source_type, source_sha256: source.source_sha256, original_source_immutable: true },
|
||||
source_excerpt: input.source_excerpt,
|
||||
|
|
@ -162,8 +162,20 @@ export class MotherBrainEngine {
|
|||
correction_anchors: Array.isArray(input.correction_anchors) ? input.correction_anchors.filter((x) => typeof x === "string").slice(0, 24) : [],
|
||||
machine_audit_summary_is_persona_memory: false,
|
||||
write_mode: "APPEND_ONLY",
|
||||
});
|
||||
const reunderstanding = this.validateReunderstanding(raw, binding);
|
||||
force_retry_test: input.force_retry_test === true,
|
||||
};
|
||||
let reunderstanding = null;
|
||||
let validatorError = null;
|
||||
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
||||
const raw = await this.modelClient.revisit(modelInput, validatorError);
|
||||
try {
|
||||
reunderstanding = this.validateReunderstanding(raw, binding);
|
||||
break;
|
||||
} catch (error) {
|
||||
validatorError = String(error.message || error).slice(0, 240);
|
||||
if (attempt === 3) throw error;
|
||||
}
|
||||
}
|
||||
const priorHash = this.status().last_history_revisit_hash || null;
|
||||
const record = {
|
||||
schema: "guanghu.persona-subject-history-revisit-record/v1",
|
||||
|
|
|
|||
Loading…
Reference in a new issue