Skip to content

Commit e7a6e0d

Browse files
authored
Merge pull request juju#23020 from manadart/agent-instructions
juju#23020 Addresses: - Duplicated UUID generation guidance. - Correct guidance location (code structure is not architecture). - Excessive mandatory semantics for transaction result target consistency - this has been producing false review flags.
2 parents 5bf0c8d + 4657f84 commit e7a6e0d

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

AGENTS.architecture-rules.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,20 @@ Respect Juju layering. Never create new cross-layer dependencies.
6060
- SQL queries must use explicit aliases for tables, CTEs, and projected values;
6161
use `AS` rather than relying on implicit aliasing.
6262
- State method arguments should be simple types (`string`, `int`, etc.) or types local to that domain.
63-
- UUID should be created in the service layer and pushed to the state layer as a string.
63+
- Generate new UUIDs in the service layer, then pass them into state methods as
64+
strings. State should persist supplied UUIDs rather than creating them, so
65+
services can return created entity UUIDs directly when needed.
66+
- When wrapping errors across layers, add identifying context such as entity
67+
UUIDs once at the highest useful layer. Keep state-layer `Errorf` messages
68+
generic to avoid repeated identifiers in the final error chain.
6469
- Domain packages should generally avoid `github.com/juju/names`. Prefer
6570
converting Juju tags to primitive values at API, facade, worker, or command
6671
boundaries before calling domain services.
67-
- Variables and accumulators populated inside a `db.Txn` closure MUST be reset
68-
at the top of the closure to ensure correctness on transaction retry. The
69-
`db.Txn` runner may re-execute the closure on transient errors; stale or
70-
partial data from a previous attempt will corrupt results if not cleared.
72+
- Values populated inside a `db.Txn` closure MUST remain correct if the closure
73+
is retried. Reset mutable targets only when a previous attempt can leave
74+
partial data that would produce duplicate or inconsistent results. Do not add
75+
redundant resets for retry-consistent assignments or Sqlair `GetAll` targets,
76+
which Sqlair clears before populating.
7177

7278
## Worker Boundaries
7379

AGENTS.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,3 @@ timeframe.
8383

8484
- Place methods and functions below others that call them.
8585
- Limit comment line lengths to 80 characters.
86-
- Generate new UUIDs in the service layer, then pass them into state methods.
87-
State should persist supplied UUIDs rather than creating them, so services can
88-
return created entity UUIDs directly when needed.
89-
- When wrapping errors across layers, add identifying context such as
90-
entity UUIDs once at the highest useful layer. Keep state-layer
91-
`Errorf` messages generic to avoid repeated identifiers in the final
92-
error chain.

0 commit comments

Comments
 (0)