Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions openadapt/simplex_transducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3826,11 +3826,54 @@ def _route_action_inner(
action = self._v3.egress_gate(state, action, observation, task, history)

if self._is_commit_boundary(action):
unscoped = self._v3.unscoped_resume_duplicate(state, task, action)
if unscoped is not None:
return self._abstain_action(
state,
trap_code="RESUME_DUPLICATE_UNCERTAIN",
reason=(
f"These values were saved before the restart (commit "
f"#{unscoped}) and no record identity is pinned, so it "
"cannot be told whether saving again would duplicate the "
"record. Handing the item to a person instead of saving."
),
commit_index=unscoped,
)
dup = self._v3.duplicate_of(state, task, action)
if dup is not None:
ep = self._v3.ep(state)
if dup in ep.duplicate_warned:
return self._abstain_action(
state,
trap_code="DUPLICATE_SAVE",
reason=(
f"The same values were saved before (commit #{dup}); "
"saving them again could duplicate the record."
),
commit_index=dup,
)
ep.duplicate_warned.add(dup)
self._deliver_intervention(
state,
kind="DUPLICATE_SAVE",
hint=(
f"DUPLICATE_SAVE: these exact values were already sent in "
f"commit #{dup} and may already be stored. Do not save them "
"again. Open the record and check whether it is there; if it "
"is, finish or continue with what is left."
),
delta_note=f"duplicate_of={dup}",
fast_forward_obs=observation,
)
return self._reenter(state, observation, task, history)
self._v3.note_commit(state, action)
fp = _commit_fingerprint(action, observation=observation)
safe_summary = {
"type": _action_type_str(action),
"raw_action": self.vault.redact(_action_raw_dict(action)),
"field_writes": self.vault.redact(
self._v3.field_writes_for(state, commit_index)
),
}
existing_rec = self.wal.get(run_id, task_id, commit_index)
if existing_rec is None:
Expand Down
3 changes: 3 additions & 0 deletions openadapt/transducer_fact_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,9 @@ def latch_gate(
raw = _get(action, "raw_action")
if isinstance(raw, Mapping) and raw.get("allow_duplicate") is True:
return action
v3 = getattr(owner, "_v3", None)
if v3 is not None and v3.repeat_allowed(state, task, action):
return action # the task names this content again: not a re-submit
key = submit_control_key(action)
text = " ".join([submit_text(action), *state.form_latch.typed()])
hit = state.form_latch.match(key, text)
Expand Down
Loading
Loading