@dsmm/dsmm 0.3.32 → 0.3.34

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.
Files changed (44) hide show
  1. package/README.md +6 -4
  2. package/agent-presets/dsmm-oracle/agent.cordis.yml +2 -0
  3. package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +2 -0
  4. package/agent-presets/dsmm-plan-critic/agent.cordis.yml +2 -0
  5. package/agent-presets/dsmm-planner/agent.cordis.yml +1 -0
  6. package/agent-presets/dsmm-reviewer/agent.cordis.yml +2 -0
  7. package/cordis.patch.yml +3 -0
  8. package/docs/compatibility.md +1 -1
  9. package/docs/lsp.md +6 -6
  10. package/docs/maintenance.md +2 -0
  11. package/docs/roadmap.md +14 -11
  12. package/docs/settings-status.md +1 -1
  13. package/docs/testing.md +3 -4
  14. package/dsh-plugin.json +1 -1
  15. package/lib/client/NativeToolView-data.js +2 -2
  16. package/lib/client/NativeToolView.d.ts +5 -9
  17. package/lib/client/NativeToolView.js +23 -14
  18. package/lib/client/RoleToolView-locales.d.ts +1 -1
  19. package/lib/client/RoleToolView-locales.js +2 -2
  20. package/lib/client/RoleToolView.d.ts +3 -12
  21. package/lib/client/RoleToolView.js +18 -13
  22. package/lib/client/child-conversation.d.ts +24 -0
  23. package/lib/client/child-conversation.js +39 -0
  24. package/lib/client.js +89 -30
  25. package/lib/index.js +2 -3
  26. package/lib/lsp-entry.d.ts +5 -0
  27. package/lib/lsp-entry.js +6 -0
  28. package/lib/lsp.d.ts +6 -3
  29. package/lib/lsp.js +125 -57
  30. package/lib/native-admission.js +16 -8
  31. package/lib/prompts.js +1 -1
  32. package/lib/resident-root.d.ts +1 -1
  33. package/lib/resident-root.js +39 -6
  34. package/lib/role-subagents.js +22 -3
  35. package/package.json +5 -1
  36. package/prompts/source/agents/plan-critic.md +2 -0
  37. package/prompts/source/agents/planner.md +1 -0
  38. package/prompts/source/agents/reviewer.md +2 -0
  39. package/prompts/source/deepwork/gpt.md +3 -1
  40. package/skills/avoid-ai-slop/SKILL.md +2 -0
  41. package/skills/brainstorming/SKILL.md +2 -0
  42. package/skills/receiving-code-review/SKILL.md +2 -0
  43. package/skills/requesting-code-review/SKILL.md +1 -1
  44. package/skills/writing-plans/SKILL.md +1 -1
@@ -198,6 +198,9 @@ export class NativeAdmission {
198
198
  }, { global: true, prepend: true });
199
199
  ctx.on("tools/pre-execute", async (exec, next) => {
200
200
  if (exec.agent) {
201
+ const publication = !this.live.has(exec.agent) && this.awaitingPublication.get(exec.agent);
202
+ if (publication)
203
+ await publication.promise;
201
204
  captureResidentTool(exec.agent, this, exec.token);
202
205
  this.trackExecution(exec);
203
206
  await this.guardExecution(exec.agent);
@@ -616,8 +619,10 @@ export class NativeAdmission {
616
619
  /** Exact process-local capture, retained after retirement so stale objects never become native. */
617
620
  owns(agent) { return this.agentLifetimes.has(agent); }
618
621
  async guardExecution(agent) {
622
+ const publication = this.awaitingPublication.get(agent);
623
+ if (publication)
624
+ await publication.promise;
619
625
  assertResidentRootCurrent(agent, this);
620
- await this.awaitingPublication.get(agent)?.promise;
621
626
  if (!this.owns(agent)) {
622
627
  const registry = agent.ctx.get("agents");
623
628
  if (registry && original(registry) === original(this.ctx.agents) && scopeOf(agent.ctx) === agent && registry.get(agent.id) !== agent
@@ -1091,7 +1096,7 @@ export class NativeAdmission {
1091
1096
  if (restoring)
1092
1097
  guardResidentRealm(agent);
1093
1098
  else
1094
- markResidentAgent(agent, this, isRoot);
1099
+ markResidentAgent(agent, this, isRoot, this.awaitingPublication.get(agent)?.promise);
1095
1100
  const scope = agent.ctx.plugin(function dsmmAgentGeneration() { }).ctx;
1096
1101
  this.scopes.set(agent, scope);
1097
1102
  this.agentLifetimes.set(agent, new AbortController());
@@ -1253,15 +1258,12 @@ export class NativeAdmission {
1253
1258
  }
1254
1259
  await this.install(agent, this.getter(agent), scope);
1255
1260
  check();
1256
- await this.profiles.revalidateActivation(admission);
1257
- check();
1258
- if (pending)
1259
- this.check(pending);
1260
- if (continuationProvider && this.ctx.get("subagents").getProvider(continuationProvider.name) !== continuationProvider)
1261
- throw new SubagentError("Role provider changed", "UNAUTHORIZED");
1262
1261
  // Occupancy precedes the installed guards' async policy and approval work.
1263
1262
  scope.on("tools/pre-execute", async (exec, next) => {
1264
1263
  if (exec.agent === agent) {
1264
+ const publication = !this.live.has(agent) && this.awaitingPublication.get(agent);
1265
+ if (publication)
1266
+ await publication.promise;
1265
1267
  captureResidentTool(agent, this, exec.token);
1266
1268
  this.trackExecution(exec);
1267
1269
  await this.ensure(agent);
@@ -1271,6 +1273,12 @@ export class NativeAdmission {
1271
1273
  }
1272
1274
  return next();
1273
1275
  }, { prepend: true });
1276
+ await this.profiles.revalidateActivation(admission);
1277
+ check();
1278
+ if (pending)
1279
+ this.check(pending);
1280
+ if (continuationProvider && this.ctx.get("subagents").getProvider(continuationProvider.name) !== continuationProvider)
1281
+ throw new SubagentError("Role provider changed", "UNAUTHORIZED");
1274
1282
  const routeCandidate = await this.admissionModelSelection?.(agent, {
1275
1283
  settings: admission.settings, epoch: admission.epoch, admission, signal, assertCurrent: check,
1276
1284
  });
package/lib/prompts.js CHANGED
@@ -19,7 +19,7 @@ function generalModelCalibration(model) {
19
19
  switch (recognized?.identifier) {
20
20
  case "gpt":
21
21
  case "codex":
22
- return "Lead with the result and its supporting evidence. Reuse checks that still cover the claim; qualify only what remains uncertain.";
22
+ return "Lead with the result and its supporting evidence. Reuse checks that still cover the claim; qualify only what remains uncertain. Do not write defensive code or design for imaginary failures. Never penalize the 90% normal path for a case the contract makes impossible. Trust internal guarantees; enforce required checks at real boundaries.";
23
23
  case "gemini":
24
24
  return recognized.gemini4OrLater
25
25
  ? "Ground claims about files and runtime behavior in what you observed. Distinguish a proposed change from an applied one, and a successful build from evidence that the requested behavior works."
@@ -2,7 +2,7 @@ import type { Agent } from "@deepseek-ai/dsh-agent";
2
2
  import type { ToolExecution } from "@deepseek-ai/dsh-tools";
3
3
  import type { NativeAdmission } from "./native-admission.js";
4
4
  export declare function assertResidentRootCurrent(agent: Agent, owner: NativeAdmission | undefined): void;
5
- export declare function markResidentAgent(agent: Agent, owner: NativeAdmission, root: boolean): void;
5
+ export declare function markResidentAgent(agent: Agent, owner: NativeAdmission, root: boolean, publication?: Promise<void>): void;
6
6
  export declare function captureResidentTool(agent: Agent, owner: NativeAdmission, token: ToolExecution["token"]): void;
7
7
  export declare function guardResidentRealm(agent: Agent): void;
8
8
  export declare function publishResidentAgent(agent: Agent, owner: NativeAdmission): void;
@@ -32,7 +32,7 @@ function claim(record, owner) {
32
32
  owner.lifetime.signal.addEventListener("abort", revoke, { once: true });
33
33
  record.detachOwner = () => owner.lifetime.signal.removeEventListener("abort", revoke);
34
34
  }
35
- export function markResidentAgent(agent, owner, root) {
35
+ export function markResidentAgent(agent, owner, root, publication) {
36
36
  if (records.has(agent))
37
37
  deny();
38
38
  const deployment = owner.ctx.get("dsmmDeploymentConfig");
@@ -50,12 +50,26 @@ export function markResidentAgent(agent, owner, root) {
50
50
  record.owner = undefined;
51
51
  record.afterDrain = undefined;
52
52
  });
53
- agent.ctx.on("agent/pre-step", async (frame, next) => { if (frame.agent === agent)
54
- await current(record).ensure(agent); return next(); }, { prepend: true });
55
- agent.ctx.on("agent/request", async (frame, next) => { if (frame.agent === agent)
56
- await current(record).ensure(agent); return next(); }, { prepend: true });
53
+ agent.ctx.on("agent/pre-step", async (frame, next) => {
54
+ if (frame.agent === agent) {
55
+ if (!record.published && publication)
56
+ await publication;
57
+ await current(record).ensure(agent);
58
+ }
59
+ return next();
60
+ }, { prepend: true });
61
+ agent.ctx.on("agent/request", async (frame, next) => {
62
+ if (frame.agent === agent) {
63
+ if (!record.published && publication)
64
+ await publication;
65
+ await current(record).ensure(agent);
66
+ }
67
+ return next();
68
+ }, { prepend: true });
57
69
  agent.ctx.on("tools/pre-execute", async (exec, next) => {
58
70
  if (exec.agent === agent) {
71
+ if (!record.published && publication)
72
+ await publication;
59
73
  const owner = current(record);
60
74
  record.tokens.add(exec.token);
61
75
  await owner.ensure(agent);
@@ -101,10 +115,29 @@ export function guardResidentRealm(agent) {
101
115
  });
102
116
  record.tools.add(realm);
103
117
  }
118
+ function loaderEntry(owner) {
119
+ const entry = owner.ctx.fiber.entry, profileDir = owner.ctx.get("profileContext")?.dir;
120
+ return entry && profileDir ? { name: entry.options.name, profileDir } : null;
121
+ }
122
+ function sameDeployment(record, owner) {
123
+ const deployment = owner.ctx.get("dsmmDeploymentConfig");
124
+ if (!deployment || record.home !== deployment.home)
125
+ return false;
126
+ const entry = loaderEntry(owner);
127
+ if (record.loaderEntry && entry) {
128
+ // Reinstalling a plugin mints a new Loader entry ID within the same physical profile.
129
+ return record.loaderEntry.name === entry.name && record.loaderEntry.profileDir === entry.profileDir;
130
+ }
131
+ if (record.loaderEntry === undefined && record.profile && entry)
132
+ return true;
133
+ return record.deploymentKey === deployment.hostProfileKey && (record.loaderEntry === undefined || record.loaderEntry === entry);
134
+ }
104
135
  export function publishResidentAgent(agent, owner) {
105
136
  const record = records.get(agent);
106
137
  if (record.disposed || original(record.owner) !== original(owner) || !owner.isReady)
107
138
  deny();
139
+ record.loaderEntry = loaderEntry(owner);
140
+ record.deploymentKey = owner.ctx.get("dsmmDeploymentConfig")?.hostProfileKey;
108
141
  record.scopeParent = scopeParentOf(agent);
109
142
  record.preset = agent.ctx.get("agentPresets")?.composedPreset(agent.ctx);
110
143
  record.published = record.active = true;
@@ -114,7 +147,7 @@ export function restoreResidentRoot(agent, owner, install) {
114
147
  if (!record || record.version !== 1 || !record.root || record.disposed || !record.published || record.owner)
115
148
  return;
116
149
  const valid = () => record.profile === original(owner.ctx.get("profileContext")) && record.registry === original(owner.ctx.agents) && record.registry === original(agent.ctx.get("agents"))
117
- && record.deploymentKey === owner.ctx.get("dsmmDeploymentConfig")?.hostProfileKey && record.home === owner.ctx.get("dsmmDeploymentConfig")?.home
150
+ && sameDeployment(record, owner)
118
151
  && record.sessions === original(owner.ctx.get("sessions")) && record.session === agent.session && owner.ctx.get("sessions")?.get(agent.id) === record.session
119
152
  && record.presets === original(agent.ctx.get("agentPresets")) && record.preset === agent.ctx.get("agentPresets")?.composedPreset(agent.ctx)
120
153
  && record.scopeParent === scopeParentOf(agent) && scopeOf(agent.ctx) === agent && owner.ctx.agents.get(agent.id) === agent;
@@ -300,8 +300,7 @@ export function registerHeadlessRoleTools(ctx, controller, getSettings, policy,
300
300
  }
301
301
  const subagents = ctx.get("subagents");
302
302
  const host = ctx.get("tools");
303
- const names = [...hostControls, ...host?.schemas().map((row) => row.name).filter((name) => name.startsWith(`mcp__${settings.lsp.serverName}__`)) ?? []];
304
- const definitions = names.map((name) => host?.get(name));
303
+ const definitions = hostControls.map(name => host?.get(name));
305
304
  const providers = targets.map(role => {
306
305
  const provider = subagents?.getProvider(roleProviderName(role));
307
306
  return provider === undefined ? undefined : Reflect.get(provider, symbols.original) ?? provider;
@@ -314,6 +313,7 @@ export function registerHeadlessRoleTools(ctx, controller, getSettings, policy,
314
313
  if (sameRealm && sameParent && sameProviders && signature === state.signature && definitions.length === state.hostDefinitions.length && definitions.every((definition, i) => definition === state.hostDefinitions[i]))
315
314
  return;
316
315
  state.signature = undefined;
316
+ state.stopLsp?.();
317
317
  for (const dispose of state.owned.splice(0))
318
318
  dispose();
319
319
  state.restriction?.();
@@ -335,7 +335,25 @@ export function registerHeadlessRoleTools(ctx, controller, getSettings, policy,
335
335
  const inventory = callableRoleInventory(settings, targets.filter(role => subagents?.getProvider(roleProviderName(role))?.capabilities.depthLimit === true));
336
336
  for (const entry of inventory)
337
337
  state.owned.push(registerRoleTool(agent, ctx, tools, entry, getSettings, policy, admission));
338
- policy.captureTools(agent, tools, [...inventory.map(entry => entry.name), ...names], !sameRealm || !sameParent);
338
+ policy.captureTools(agent, tools, [...inventory.map(entry => entry.name), ...hostControls], !sameRealm || !sameParent);
339
+ const hostRealm = host && (Reflect.get(host, symbols.original) ?? host) === (Reflect.get(tools, symbols.original) ?? tools);
340
+ state.stopLsp = ctx.get("dsmmProjectLsp")?.(definition => {
341
+ if (!getSettings(agent).modules.deepwork.enabled)
342
+ return;
343
+ const { name } = definition, visible = tools.get(name, agent);
344
+ if (visible && visible !== definition)
345
+ return;
346
+ if (policy.toolDenial(agent, name) !== undefined) {
347
+ return visible && tools.get(name, parentScope) === visible ? tools.restrict({ deny: [name] }) : undefined;
348
+ }
349
+ // A masked inherited registration stays masked. Only a missing tool in an
350
+ // independent registry needs an Agent-layer copy.
351
+ if (!visible && (hostRealm || tools.get(name, parentScope)))
352
+ return;
353
+ const dispose = visible ? undefined : tools.register(definition);
354
+ policy.captureTools(agent, tools, [name]);
355
+ return dispose;
356
+ });
339
357
  state.signature = signature;
340
358
  state.providers = providers;
341
359
  state.hostDefinitions = definitions;
@@ -346,6 +364,7 @@ export function registerHeadlessRoleTools(ctx, controller, getSettings, policy,
346
364
  reconcile(); });
347
365
  const retire = ctx.effect(() => () => {
348
366
  stopIdentity();
367
+ state.stopLsp?.();
349
368
  state.restriction?.();
350
369
  state.guard?.();
351
370
  state.guidance?.();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsmm/dsmm",
3
- "version": "0.3.32",
3
+ "version": "0.3.34",
4
4
  "description": "Native Deepwork roles, routing, profiles, and permission controls for DeepSeek Harness.",
5
5
  "author": "Hugefiver",
6
6
  "license": "LicenseRef-AAAPL",
@@ -26,6 +26,10 @@
26
26
  "main": "./lib/index.js",
27
27
  "types": "./lib/index.d.ts",
28
28
  "exports": {
29
+ "./lsp": {
30
+ "types": "./lib/lsp-entry.d.ts",
31
+ "default": "./lib/lsp-entry.js"
32
+ },
29
33
  "./managed-settings": {
30
34
  "types": "./lib/managed-settings.d.ts",
31
35
  "default": "./lib/managed-settings.js"
@@ -22,6 +22,8 @@ Treat as blockers only issues that contradict an explicit requirement or constra
22
22
 
23
23
  For a missing required safeguard, cite the governing requirement and the gap. For an additional safeguard, treat its absence as a blocker only when a concrete failure path escapes existing controls. If the plan makes valid work wait for redundant validation or approval, recommend removing that gate while retaining the actual boundary check. Hypothetical future uses and optional hardening do not hold up implementation.
24
24
 
25
+ Do not invent changes to internal, external, or database state. Before demanding a concurrency safeguard, identify the writer, the interval in which it can act, and the requirement it would break. Reject plans that hold database, table, or row locks through long-running application work. Keep transactions short; do not demand a pre-write reread of confirmed state or a costly database integrity scan to cover an imagined change.
26
+
25
27
  Everything else is a non-blocking note and does not delay implementation. Give current findings and supporting evidence as clear prose rather than protocol fields or approval tokens. Every substantive blocker must be corrected, rebutted with concrete evidence, or escalated for clarification; it cannot be relabeled advisory and ignored. Critique informs judgment and does not authorize implementation or delivery.
26
28
 
27
29
  Do not require another review merely because the plan changed. Revisit only affected claims and dependent risks when a blocker is newly identified or resolved, or relevant new evidence or another substantive input could change the prior conclusion. Wording changes, repeated concerns, and unchanged uncertainty are not progress; stop and return an unresolved blocker rather than continuing a no-progress loop. Do not require hashes, a fixed receipt or verdict format, a fixed iteration count, or an open-ended loop. Do not object to preference, optional polish, or a merely better approach.
@@ -10,6 +10,7 @@ You are the plan-only agent. From the agreed goal and direct evidence, produce a
10
10
  - Reserve `docs/superpowers/specs/` and `docs/superpowers/plans/` for final product requirements to be delivered. Each artifact describes one final deliverable, not development decisions, rejected alternatives, assumption rationale/cost, or change history. Changed requirements use separate plans. Non-product tasks, regardless of complexity, use conversation coordination or a task-owned temporary plan outside those directories.
11
11
  - Plan around the ideal end state, dependencies, interfaces, material risks, wave goals, and useful outcome evidence. Record decisions an implementer cannot safely infer: necessary paths and names, interface signatures and types, requirement-fixed values, and decisive test assertions or observable results. Do not transcribe implementation bodies already determined by those decisions. Treat steps and ordering as informed guidance that execution may adjust as evidence changes, not as a hard script.
12
12
  - Choose the simplest design that delivers the approved behavior and preserves contracts outside the authorized change. Validate at trust boundaries and reuse an established guarantee for as long as it holds. Add an abstraction, retry, fallback, lock, or approval step only when a current requirement or concrete failure path needs it; keep independent work moving.
13
+ - Do not assume internal, external, or database state changed without evidence. Once the workflow confirms a state, use it for the write; do not plan another read or a database integrity scan just in case. Keep transactions short: never hold database, table, or row locks across long-running application work or external waits. If a known concurrent writer can invalidate a required invariant, protect that write with the narrowest atomic condition.
13
14
  - Plan verification around valid requirements, functionality, and external interfaces, including material input classes and failure conditions implied by the approved behavior and local contracts. Attach plausible regression coverage to the owning task; when an important behavior remains unjudged, state why and what evidence is missing without imposing a fixed review-focus heading, list, or quota. Do not expand scope from speculation or add descriptive-text locks. Requirement changes update tests; removed components lose their dedicated tests rather than gaining absence tests. Git commits bound compatibility: interim uncommitted behavior need not be preserved, but existing committed contracts and API/security/data/permission/irreversible-action authorization remain binding.
14
15
  - Return unresolved software design choices that affect implementation to the orchestrator for `brainstorming`; use `writing-plans` techniques proportionally rather than imposing ceremony.
15
16
  - Use direct tools first. A leaf read-only `code-search`, `doc-search`, or equivalent lookup is allowed only to resolve a named fact. If evidence leaves a genuinely difficult decision, report the blocker to the orchestrator for optional `hard-reasoning`; strict or high-risk conditions alone do not qualify.
@@ -18,6 +18,8 @@ Evaluate existing evidence by material relevance; request missing or affected co
18
18
 
19
19
  Trace a local defect far enough to establish its impact and the smallest correction. Prefer a local fix when it restores the contract. Extend the investigation only as far as the changed behavior or a concrete risk warrants; assess independent defects in the diff on their own impact. Look for unnecessary complexity in the diff, such as an abstraction with no current consumer or a check that repeats an upstream guarantee. When complexity is the only issue, suggest a simpler alternative as non-blocking advice. Process rules about stopping your own unnecessary work do not require cleanup of the reviewed diff. If the change violates a requirement or creates a concrete safety risk, report that finding separately at its actual severity.
20
20
 
21
+ Do not report that internal, external, or database state may have changed without evidence of a reachable writer or transition. Flag database, table, or row locks held during long-running application work; keep the transaction to the database operation. Once the workflow has confirmed the state, do not ask for another read before writeback or an expensive integrity scan. Where a documented concurrent write matters, check the atomic write condition rather than proposing a separate read that can race.
22
+
21
23
  Report material findings first with severity when useful, file path, concrete evidence, likely impact, and the smallest valid correction. Judge whether useful functionality is complete, interfaces are clear, and meaningful regression and real-surface evidence support the result. Review informs engineering judgment; it is not delivery authorization or a protocol gate. Repeat only the affected review for a newly identified or resolved blocker, a substantive correction, or relevant new evidence; repeated concerns or unchanged uncertainty do not justify another pass. Apply strict review only when the user explicitly requests it or a scoped, concrete high-risk condition warrants it.
22
24
 
23
25
  Use direct read/search tools first; a leaf read-only lookup may verify one finding but returns evidence, not delegated judgment. Never dispatch planner, reviewer, any Oracle profile, plan-critic, clarifier, coordinator, or an implementation agent.
@@ -24,7 +24,9 @@ Follow the authoritative role and triggered skills for the detailed method inste
24
24
 
25
25
  Use direct tools for bounded known targets; delegate only when permitted and a distinct child result materially improves completion — multiple steps or a second opinion alone are insufficient. Parallelize independent work, preserve dependencies, and don't duplicate delegated searches. Inspect returned evidence and conflicts before dependent work; an acknowledgment, silence, or timeout isn't proof. Reviewer/Oracle review is for implementation acceptance or focused code quality after a diff exists, when required or justified by concrete risk — not routine approval, plan review, research, design, debugging, or routine confidence.
26
26
 
27
- Match local patterns. Avoid speculative abstractions, pass-through wrappers, redundant defensive checks around guaranteed values, restating comments, dead/debug code, and needless copies or repeated work. Split by responsibility, not arbitrary line counts. Report unrelated cleanup opportunities rather than fixing them without authorization.
27
+ **Do not write defensive code or design for imaginary failures.** Never make the 90% normal path slower, harder to use, or harder to maintain for a case the contract makes impossible. Trust established invariants. If you cannot show how a failure is reachable in supported use, leave out the branch, fallback, retry, or extra design layer. Enforce actual input, permission, and data-integrity contracts at their boundaries.
28
+
29
+ Match local patterns. Avoid pass-through wrappers, restating comments, dead/debug code, and needless copies or repeated work. Split by responsibility, not arbitrary line counts. Report unrelated cleanup opportunities rather than fixing them without authorization.
28
30
 
29
31
  Implement exactly and only what was requested: no bonus features, opportunistic refactors, style embellishments, or speculative cleanup; a fix needs no surrounding cleanup, and a one-shot operation needs no helper, abstraction, flag, shim, or future-proofing. Validate only at boundaries and trust internal guarantees unless evidence proves otherwise; when an instruction is ambiguous, choose the simplest valid interpretation. Never suppress type errors with `as any`, `@ts-ignore`, or `@ts-expect-error`.
30
32
 
@@ -18,6 +18,8 @@ Future flexibility alone is not a requirement. Do not add configuration switches
18
18
 
19
19
  For a proposed validation, retry, fallback, exception handler, or recovery layer, identify what it detects and how it changes rejection, recovery, or diagnosis. Validate at genuine trust boundaries; use established internal guarantees instead of repeatedly defending against impossible states.
20
20
 
21
+ Do not assume internal, external, or database state changed without evidence. If the workflow already confirmed a row's state, write the result without a precautionary reread or integrity scan. Keep transactions short: never hold database, table, or row locks while application code does long-running work or waits for a service. A real concurrent-write contract belongs in a targeted atomic write.
22
+
21
23
  Keep the safeguards the feature relies on, such as authorization at a protected operation or validation at a public input. For ordinary failures, prefer the project's standard error path. Add a fallback only when it gives the user a correct, useful result.
22
24
 
23
25
  Do not turn a failed read into a successful empty result, swallow an error behind a plausible default, or retry a side effect without the required safety guarantees. Propagate failures or handle them according to the existing contract. Fix incorrect types rather than suppressing them with `as any`, `@ts-ignore`, or `@ts-expect-error`.
@@ -82,6 +82,8 @@ Present alternatives only when there is a real decision with meaningful trade-of
82
82
 
83
83
  Start with what the user needs to accomplish in normal use. Choose a familiar design that delivers that outcome. Where the business contract tolerates temporary inconsistency, allow independent operations to proceed and reconcile their results instead of serializing the whole workflow. Match safeguards to the system's actual exposure and the consequences of failure; reserve high-assurance designs for an explicit requirement or a credible risk that ordinary controls do not cover.
84
84
 
85
+ Do not assume an internal, external, or database state change without evidence of what can change it. Design database work as short transactions, with slow computation and external waits outside locks. Carry a confirmed business decision through to writeback without a precautionary reread or database-wide integrity check.
86
+
85
87
  ## Outcome-Oriented Design
86
88
 
87
89
  Scale the design artifact to the work within the product-spec and temporary-plan boundaries above. A useful design makes the following discoverable without requiring fixed sections or order:
@@ -41,6 +41,8 @@ Code review requires technical evaluation, not emotional performance.
41
41
 
42
42
  A reviewer status, verdict label, acknowledgement, or receipt-shaped response is informational. The cited code, reasoning, and evidence determine whether action is required. Reviewer approval is not a substitute for verification.
43
43
 
44
+ When feedback says state might have changed, look for the actual internal transition, external actor, or database writer. Without such evidence, do not add a pre-write reread of confirmed state or a costly integrity scan. Keep transactions short; do not hold database, table, or row locks through long-running application work to satisfy a speculative review finding.
45
+
44
46
  ## Clarification and Escalation
45
47
 
46
48
  Clarify an item before implementing it when ambiguity would materially change the correction. Independent clear items may proceed while clarification is pending if doing so cannot create rework or violate shared assumptions.
@@ -51,7 +51,7 @@ Provide the reviewer, in whatever order is clearest:
51
51
  - the current working-tree diff or committed range, including newly created files;
52
52
  - relevant verification evidence and any intentionally unverified item;
53
53
  - current global constraints and permissions;
54
- - focused dependency/interface or risk context needed to evaluate the change.
54
+ - focused dependency/interface or risk context needed to evaluate the change. For a state race, name the actual writer and conflicting operation. Do not ask reviewers to assume internal, external, or database changes, to re-read confirmed state before writeback, or to require a broad integrity scan. Check that long-running application work sits outside database locks.
55
55
 
56
56
  Use the actual current diff or range rather than a prose-only summary. If output is large or sensitive, provide a safe reviewable artifact or focused slices plus a complete file manifest, without omitting changes material to the criteria.
57
57
 
@@ -46,7 +46,7 @@ Before decomposing work:
46
46
 
47
47
  - Read the approved design or requirements and the relevant repository evidence.
48
48
  - Describe how the user reaches the requested outcome on the normal path. Plan recovery where it lets the task finish correctly; when an operation cannot recover, report its failure and let independent operations continue.
49
- - Identify dependencies, interfaces, ownership boundaries, and ordering constraints.
49
+ - Identify dependencies, interfaces, ownership boundaries, and ordering constraints. Do not assume internal, external, or database state changed without evidence. Keep transactions short; put long-running application work outside database, table, and row locks. Reuse confirmed state at writeback without a second read or broad integrity scan. If an identified writer can break a required invariant, specify the atomic write that protects it.
50
50
  - Surface material risks: security, data loss, compatibility, protocols/APIs, irreversible operations, and difficult rollback.
51
51
  - Check external constraints such as budget, mandated/prohibited stack, scale, privacy, compliance, accessibility, and platform requirements. Do not invent constraints.
52
52