[front] Move agent archive/restore/hard-delete into AgentResource - #32927
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
ab63b14 to
3c14a20
Compare
| if (this.status !== "archived") { | ||
| return new Err( | ||
| new DustError("internal_error", "Agent configuration is not archived") | ||
| ); | ||
| } |
There was a problem hiding this comment.
should this just be a return with restored: false ?
There was a problem hiding this comment.
same api as before, i think it's ok to return an error when archiving something already archived
There was a problem hiding this comment.
I think restore/archive should behave the same, if restoring an active agent errors, then archiving an archived agent should error as well
3c14a20 to
5bebef7
Compare
b7d9088 to
ea175a9
Compare
|
r? @sfriquet updated, ptal |
ea175a9 to
c7a42cd
Compare
There was a problem hiding this comment.
cc-verify: violations found!
- agent-verbs: Lifecycle mutations bypass write permission
- no-catching-own-errors: Expected failure is thrown
- functional-endpoint-tests: Restore authorization lacks endpoint coverage
- resource-identifier-naming: Numeric IDs use string-ID names
29a26d9 to
9dc9f43
Compare
Turn archiveAgentConfiguration and restoreAgentConfiguration into AgentResource.archive/restore instance methods, and replace unsafeHardDeleteAgentConfiguration with AgentResource.delete, which purges all versions, their satellites (tools, tags, skills, suggestions), scoped resources (triggers, wake-ups, favorites), grants/groups and the agents identity row, then invalidates the cache and removes the agent from the search index. Callers fetch the resource and call the method; scrub_agent now delegates the full teardown to delete(). Row-level helpers (destroyAgentConfigurationRow, ...) are kept for the per-version scripts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9dc9f43 to
1287365
Compare
| continue; | ||
| } | ||
|
|
||
| const editorAuth = await Authenticator.fromUserIdAndWorkspaceId( |
There was a problem hiding this comment.
React Doctor · react-doctor/async-await-in-loop (warning)
This makes the for…of loop slow because each await runs one after another, so collect the independent calls & run them together with await Promise.all(items.map(...))
Fix → Collect the items, then use await Promise.all(items.map(...)) so independent work runs at the same time
| auth, | ||
| this.sId | ||
| ); | ||
| const remainingWakeUps = await WakeUpResource.listByAgentConfigurationId( |
There was a problem hiding this comment.
React Doctor · react-doctor/server-sequential-independent-await (warning)
This await doesn't use the previous result, so your users wait twice as long for nothing.
Fix → These two awaits don't depend on each other. Wrap them in Promise.all([...]) so they run at the same time.
| ); | ||
| for (const agentConfiguration of agentConfigurationsToArchive) { | ||
| await archiveAgentConfiguration(auth, agentConfiguration.sId); | ||
| const agentToArchive = await AgentResource.fetchById( |
There was a problem hiding this comment.
React Doctor · react-doctor/async-await-in-loop (warning)
This makes the for…of loop slow because each await runs one after another, so collect the independent calls & run them together with await Promise.all(items.map(...))
Fix → Collect the items, then use await Promise.all(items.map(...)) so independent work runs at the same time
Description
Continues centralizing agent mutations in
AgentResource.archiveAgentConfiguration/restoreAgentConfiguration→AgentResource.archive(auth)/AgentResource.restore(auth)instance methods (same behavior: trigger disable/re-enable, wake-up cancel, audit, cache invalidation, reindex).unsafeHardDeleteAgentConfiguration→AgentResource.delete(auth), which now purges all versions, their satellites (tools + data-source/table/child-agent links, tags, skills, suggestions), the scoped resources (triggers, wake-ups, favorites, with the Temporal-cleanup completeness guard), the grants/groups and theagentsidentity row, then invalidates the cache and removes the agent from the search index.Callers fetch the resource and call the method;
scrub_agentdelegates the whole teardown todelete(). The per-version row helpers (destroyAgentConfigurationRow,syncAgentSearchAfterRowDestroyed,batchHardDeletePendingAgentConfigurations) are kept for their script/temporal callers.Tests
front + front-api typecheck clean; all affected suites pass (
agent,agent_resource, indexation, grants, conversation, views, tool servers, and the front-api route tests).Risk
Low–medium. Archive/restore behavior is unchanged.
delete()is only reachable from the internalscrub_agentscript and now removes every version in one transaction instead of looping per version.Deploy Plan
Standard.
🤖 Generated with Claude Code