Repository navigation
fix: address application architecture review findings - #562
Conversation
|
Size Change: 0 B 🆕 Total Size: 0 B |
|
I’d address the Standard Agent wiring and the cache invalidation before merging. I found five issues on
The committed-fact milestone regression test, MCP log-and-list test, focused |
|
Two additional P2 cache issues remain in the assignment rule, including with the local follow-up that invalidates priority options:
|
|
Addressed all five in
Tests run against this branch: full One note on test placement: I could not add the MCP |
|
Re-reviewed
Verification: all 65 tests in the three affected frontend store suites passed, as did the focused Standard Agent and worklog tests and both architecture guards. The post-commit case above was checked separately in a temporary test; no production or companion test files were changed. |
|
Addressed all three in
Verification: full |
|
Re-reviewed
Please keep regression coverage at those two boundaries: fail a detail read after a real commit and assert the tool returns the stored ID; settle an old refresh last and assert the new catalogs remain. All 69 committed frontend tests in the four affected suites and the three focused Go regressions passed; the two additional cases above failed. Separately, the Go Vulnerability Check flagged |
2d6dfbc to
438138c
Compare
|
Revised both designs in
Verification: full |
|
Re-reviewed
The asset-action panic was reproduced in an isolated test; the other affected callers and the masking issue were verified by source tracing. The committed agent-create and Standard Agent regression tests passed. |
|
Finished the contract at the source in
Verification: full |
|
Re-reviewed P2 — A successful v1 create can return a fabricated item key. With only the post-commit detail read forced to fail, the stored item was Carry the workspace key into the shared creation snapshot. The existing workspace validation already reads the workspace, so it can return the key instead of just checking existence. That keeps one source of identity for the response and notification without a second post-commit lookup or per-caller fallbacks. Extend the detail-read-failure regression to assert the exact display key as well as the numeric ID. |
|
Fixed in |
AddMilestoneWithContext passed the action context to the post-commit emitter but not into the transactional update, so the committed item fact fell back to source "application" with no chain, depth, or source application. Build the metadata once from the command context and pass it into AddMilestone, matching normal updates. Downstream automation derives the action from the committed fact, so it could not identify the originating chain or depth for SCM attachments.
MCP and chat tools implemented part of the operation they invoked: create_item and update_item called the low-level create/update services, and log_time wrote the repository directly. Agent writes therefore skipped description-mention processing, hierarchy cache invalidation, the created/updated event pipeline, and the worklog description policy, so the result depended on how the write entered the system. Inject the shared ItemApplicationService and TimeWorklogService into the tool environment and call them. Tool scopes, key resolution, and output formatting stay in the adapter; agent actor/source/run provenance is passed through explicitly so it is not replaced by the human-only "application" default. Embedders that do not wire the shared services fall back to a local pipeline, matching the previous behavior.
The assignment client writes /workspaces/{id}/configuration-set, but the
invalidation table only matched plural configuration-sets or an exact
workspace URL. Neither matched, so the effective-screen cache could keep
serving the previous configuration without a request after a successful
assignment.
Match the singular endpoint and drop only that workspace's cached
effective configurations, discarding in-flight pre-change reads so a slow
response cannot repopulate the cache.
The handler DB guard scanned legacy handlers and v1 only, so new direct DB access in v2 would pass unnoticed; include internal/restapi/v2 and allowlist the three existing database/sql imports. The layering guard matched an import path with a closing quote, so the cacheutil leaf rule against windshift/internal missed subpackage imports. Match the forbidden package exactly or any subpackage of it.
The catch-all error branch returned a payload with a nil Go error, so a failed insert looked like a successful MCP call. Map known input errors to the payload and return nil, err for unexpected service failures. Also forward the worklog service's sanitization warnings in the success response, matching the HTTP worklog responses, so a caller learns when its description was shortened.
Standard Agent tool writes skipped the mention processor, event emitter, and hierarchy cache because the dispatcher's aitools.Env omitted ItemApplication. Pass the shared item and worklog pipelines through Options and install them before Resume can start a queued run by moving the dispatcher construction after the item application service exists.
Per-workspace screen-config invalidation bumped the global epoch, which discarded valid in-flight reads for other workspaces. Track a per-workspace epoch so only the assigned workspace's pre-change response is dropped. The assignment endpoint also left the collection priority picker stale because it loads from collectionEditorOptions with a five-minute TTL. Invalidate the workspace's priorities and bump a per-key generation so a pending old load cannot restore them.
ItemApplicationService.Create enriched the response after the create transaction committed and returned a nil item on failure, so create_item reported a retryable error for an item that already existed. A retry could duplicate it. Return the committed item alongside the enrichment error, and have the tool audit and report the stored row instead of a create failure.
The assignment rule only cleared screen configs and priorities, leaving the active workspace's bootstrapped statuses and item types stale; a create dialog could read the previous item types for its parent picker. Re-fetch the assigned workspace's bootstrap catalogs, invalidate its status options, and apply the same per-workspace invalidation from the migration assistant, whose POST reassigns the workspace without the assignment PUT.
Create now returns the transaction's ID as the success result; the detail read only decorates the response, so a post-commit read failure no longer turns a committed create into a retryable error. Configuration changes reload the active workspace through the existing reset/initialization lifecycle, which supersedes in-flight reads, instead of assignment-specific field rules and per-workspace cache counters.
…mand The create transaction already builds the created row, so return it as the create result instead of leaving callers with a nil item when the joined read fails. ID-only consumers use result.ID; callers that need a row or an event use the snapshot, and the created event still fires. Also return the caller-facing copy from ItemApplicationService.Create on enrichment failure, so project-name and related-item masking applied before a later read failure is not discarded.
The snapshot had the item number but not the workspace key, so the v1 response mapper and the created notification formatted a key like "-1". ValidateItemCreation already reads the workspace, so return its key and carry it into ItemCreationParams; the snapshot then has the same display key as a joined read.
28ab415 to
3da1237
Compare
Summary
Addresses the highest-value findings from the application architecture review (
docs/application-architecture-review.md), following its suggested sequence: fix the SCM event metadata and the agent tool write paths first, then the workspace cache invalidation and the architecture guards.1. SCM milestone attachment keeps its automation chain
ItemUpdateApplicationService.AddMilestoneWithContextforwarded the action context to the post-commit emitter but passed only item/user IDs into the transactional update. The committed item fact therefore fell back to sourceapplicationwith no chain, depth, or source application, so downstream automation could not identify the originating chain.The metadata is now built once from the command context and passed into
AddMilestone, matching normal updates. A regression test asserts the committed fact (not just the emitter event) carries the chain, depth, and source.2. Agent tools write through the shared application services
create_item,update_item, andlog_timeimplemented part of the operation they invoked: the first two called the low-level create/update services, andlog_timewrote the repository directly. Agent writes skipped description-mention processing, hierarchy cache invalidation, the created/updated event pipeline, and the worklog description policy, so the result depended on how the write entered the system.ItemApplicationServiceandTimeWorklogServiceare now injected into the tool environment and used by those tools. Tool scopes, key resolution, and output formatting stay in the adapter. Agent actor/source/run provenance is passed through explicitly (UpdateWithMetadata) so it is not replaced by the human-onlyapplicationdefault. Embedders that do not wire the shared services fall back to a local pipeline, matching the previous behavior.3. Frontend invalidates the assigned workspace's effective configuration
The assignment client writes
/workspaces/{id}/configuration-set, but the invalidation table only matched pluralconfiguration-setsor an exact workspace URL. Neither matched, so the independent effective-screen cache could keep serving the previous configuration without a request after a successful assignment.The singular endpoint now matches and drops only that workspace's cached effective configurations, discarding in-flight pre-change reads so a slow response cannot repopulate the cache.
4. Architecture guards
internal/restapi/v2and allowlists the three existingdatabase/sqlimports.cacheutilleaf rule againstwindshift/internalmissed subpackage imports. It now matches the forbidden package exactly or any subpackage of it.Not addressed in this change
Tests
internal/services: full package (includes the new committed-fact regression test).internal/aitools,internal/scm,internal/mcp,internal/handlers: full packages.frontend:referenceDataInvalidation.test.js(new per-workspace invalidation case), plusbiome check/lintandsvelte-checkon the changed files.scripts/check-layering.shandscripts/check-handler-db-access.shpass; the layering prefix match was verified with a temporary subpackage import.Test changes live in the companion
core-tests-internalbranchfix/architecture-review-findings.