titan-agent 5.5.7 → 5.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -716,31 +716,13 @@ function coalesceKey(opts) {
716
716
  return `${opts.type}|${opts.requestedBy}|${kind}|${identity}`;
717
717
  }
718
718
  function createApproval(opts) {
719
+ let autoApproveDeferred = false;
719
720
  try {
720
721
  const auto = config?.autoApprove;
721
722
  if (auto?.enabled) {
722
723
  const rules = auto.rules || [];
723
724
  if (shouldAutoApprove({ type: opts.type, payload: opts.payload }, { enabled: true, rules })) {
724
- const approved = {
725
- id: uuid().slice(0, 8),
726
- type: opts.type,
727
- status: "approved",
728
- requestedBy: opts.requestedBy,
729
- payload: opts.payload,
730
- decidedBy: "auto:path-classifier",
731
- decidedAt: (/* @__PURE__ */ new Date()).toISOString(),
732
- decisionNote: "Auto-approved by path-scoped classifier",
733
- linkedIssueIds: opts.linkedIssueIds || [],
734
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
735
- };
736
- approvals.set(approved.id, approved);
737
- saveState();
738
- addActivity({
739
- type: "goal_created",
740
- message: `Approval auto-approved: ${approved.type} (${opts.payload.kind ?? "-"}) from ${opts.requestedBy}`,
741
- metadata: { approvalId: approved.id, auto: true, path: opts.payload.path ?? null }
742
- });
743
- return approved;
725
+ autoApproveDeferred = true;
744
726
  }
745
727
  }
746
728
  } catch (err) {
@@ -776,6 +758,14 @@ function createApproval(opts) {
776
758
  }
777
759
  saveState();
778
760
  addActivity({ type: "goal_created", message: `Approval requested: ${approval.type} by ${approval.requestedBy}`, metadata: { approvalId: approval.id } });
761
+ if (autoApproveDeferred) {
762
+ approveApproval(approval.id, "auto:path-classifier", "Auto-approved by path-scoped classifier").catch((err) => {
763
+ logger.error(
764
+ COMPONENT,
765
+ `Auto-approve dispatch failed for ${approval.id}: ${err.message}`
766
+ );
767
+ });
768
+ }
779
769
  return approval;
780
770
  }
781
771
  async function approveApproval(id, decidedBy, note) {