制定多人并发编辑冲突处理规范
针对多人、自动化与离线编辑场景,制定字段冲突策略、保存规则和界面提示文案。
完整提示词
<context>
Most products have no stated rule for simultaneous edits, so they get the accidental one: last write wins, silently. Two support agents update the same ticket and one reply vanishes; a planner changes a shift while a sync job overwrites it from the HR system; a mobile user edits offline and their save replaces a week of colleagues' changes. The fix is a product decision before it is a technical one, and it differs by data. Free text often tolerates last-write-wins with a warning; money, stock levels, status changes and anything with approval or audit meaning usually needs detection (the save is rejected if the record changed since it was opened) plus a clear choice for the user; long documents edited together may need live co-editing or section locks. Hard locks feel safe but cause stale locks when someone walks away. A good spec states the strategy per record type and per field, what counts as a conflict, what each person sees, and how automations, imports and offline clients are treated, because they are the writers people forget.
</context>
<task>
<feature>
{{feature_description}}
</feature>
{{#context}}
<context_from_user>
{{context}}
</context_from_user>
{{/context}}
1. List realistic collision scenarios: two people, a person and an automation or integration, a person on two devices, an offline client returning, and a bulk import, with how often each is likely and the harm if a change is lost.
2. Choose a strategy per record type and, where they differ, per field group: last write wins with notice, detect and ask, automatic field-level merge when fields do not overlap, append-only (comments, history), pessimistic lock with timeout, or live co-editing. Justify each by the cost of a lost change.
3. Specify detection and saving rules: what "changed since you opened it" means, whether non-overlapping field edits merge silently, how counters and quantities are adjusted rather than overwritten, how locks are taken, shown, expire and are broken, and who may break them.
4. Specify what the user sees: presence indicators if any, the conflict message, a side-by-side of their change and the current value, the choices offered (keep mine, take theirs, merge, copy my text), and that unsaved text is never discarded without a way to recover it.
5. Cover edge cases: status transitions that are no longer valid, deleted or permission-changed records, automations that should yield to people or vice versa, notifications and audit history for overwritten values.
6. List open questions with a recommended default marked as a proposal.
</task>
<constraints>
- Do not prescribe the implementation (version columns, CRDTs, specific libraries); state the behaviour and the requirement.
- Never accept silent loss of a user's typed text as a default; if the user wants last-write-wins, still require a way to recover the overwritten value.
- Treat money, stock, status and approval fields separately from free text; do not apply one rule to everything.
- If the product's saving model (manual save, autosave, offline) is unknown, state the assumption or ask, since the rules depend on it.
- Do not invent usage numbers; give likelihood as a judgement and mark it as one.
</constraints>
<output_format>
## Collision scenarios
Table: scenario, writers, likelihood (judgement), harm if a change is lost.
## Strategy per record and field
Table: record or field group, strategy, reason.
## Detection and saving rules
Numbered rules, including locks and merges.
## What the user sees
Bullets, with draft message copy for the conflict and lock states.
## Edge cases
Table: case, expected behaviour.
## Open questions
Numbered: question, recommended default (proposal).
</output_format>可替换内容
- {{feature_description}}
- {{#context}}
- {{context}}
- {{/context}}
分类与标签
编程开发、产品需求、协同编辑、冲突处理、离线同步、数据恢复