GeezerVison is showing github.com — Design: a projection writes only what the event proves — one application contract for the PM projector · Issue #4302 · developing-today/code
Design: a projection writes only what the event proves — one application contract for the PM projector #4302Closed 8 / 88 of 8 issues completedClosed 8 / 88 of 8 issues completed Labels app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/lLarge: multi-day or open-ended; expect staged check-insepicMeta-issue grouping multiple items (org Project Type=Epic)epic/pm-stackReprioritization program epic (2026-11-12)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)source/design-architectFiled by the repo design architect jobtask/triageQueue packet kind: verify, reproduce, and route this item DescriptionDesign doc: files/designs/code-projector-application-contract.md in the keep-the-four-repos-healthy goal workspace. Audit at origin/main 23c2c514 — every defect below re-verified present at the cited lines this pass (2026-11-02).
Summary
The PM projector (pm-stack/projector/) is the fleet dashboard's source of truth for GitHub activity: webhook deliveries and a reconciliation poller both write pmp_items, pmp_comments, pmp_deliveries and pmp_push_events, and the aggregator reads the projection as fact. Seven filings in five days are one defect with seven addresses: the rules for applying an event to the projection were never stated, so each writer invents them — and each invention lets the projection assert something the source event never proved.
- Delivery identity is neither required nor earned —
server.ts:90 defaults a missing X-GitHub-Delivery header to "", so every header-less delivery shares one identity and distinct events are dropped as "duplicate" (projector(webhook): a missing X-GitHub-Delivery header collapses every later delivery into the first one's identity — distinct events are silently dropped as 'duplicate' #2982); and deliveryApplied (store.ts:337-343) counts any recorded row, including the outcome:"error" row written when application fails, so a transient failure makes redelivery a permanent duplicate and the event — for pushes, which have no reconcile stream, absolutely — is lost (projector(webhook): a delivery that fails to apply can never be retried — its error row makes every redelivery a 'duplicate', and push events are lost permanently #2456).
- Comment identity is not namespaced —
schema.sql:47 keys pmp_comments by the bare GitHub numeric ID while three object kinds with independent ID sequences (issue comments, review comments, reviews) write into it; a collision silently overwrites the earlier object, and a delete for one kind can tombstone another's row (projector(comments): pmp_comments is keyed by the bare GitHub numeric ID — an issue comment, a review comment and a review with the same ID silently overwrite each other #2694).
- The comments guard key is not the object's time —
commentCommon (projector.ts:78-95) keys every webhook comment row on its creation time and markCommentDeleted (store.ts:247-252) never advances it, so a stale replay resurrects a deleted comment with its pre-edit body (projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it #2455); and a review, whose payload has no created_at, gets a fabricated delivery-time "now" as its creation time and guard key, after which reconcile's correct submitted_at row is guard-refused forever (projector(reviews): webhook reviews get a fabricated created_at (delivery time, not submitted_at) — reconcile's correct row is then guard-refused forever #3087). Items already key on updatedAt — comments are the asymmetric case.
- Absence is read as a default —
fromIssueOrPr (projector.ts:59-67) computes merged/draft/merged_at for every payload shape, but issue-shaped payloads carry none of those fields, so any later issues/issue_comment event for a merged PR (labelling one is routine) resets it to merged = 0, merged_at = NULL (projector(items): an issues/issue_comment event for a merged PR resets merged to 0 and clears merged_at — issue-shaped payloads carry no merge fields #4158).
- Deletion has no path for items —
applyEvent's case "issues" (projector.ts:167-170) upserts for every action including deleted; there is no deleteItem, so a deleted issue is re-upserted by its own deletion event and stays in the read model forever (projector(items): an issues deleted event is upserted, not removed — deleted GitHub issues stay in pmp_items forever (no delete path exists, and reconcile only upserts) #4210). Comment deletions are handled in the same switch — items are the one missing case.
The contract
A projection writes only what the event proves. A delivery is deduplicated by a real identity and only once it has been applied. An object's identity is its kind plus its id. A row's ordering key is the source object's own last-update time — never its creation time, never the delivery time. A field the payload does not carry is unknown and writes nothing. Deletion is a state every projected kind can reach, and for comments it is absorbing: no upsert clears it.
Recorded decisions (full reasoning, alternatives and risks in the design doc):
- A missing delivery id is rejected (
400 missing_delivery_id, nothing recorded) — not minted locally, which would defeat dedupe on redelivery. GitHub always sends the GUID; replay tooling can set the header. (projector(webhook): a missing X-GitHub-Delivery header collapses every later delivery into the first one's identity — distinct events are silently dropped as 'duplicate' #2982)
- Dedupe counts success and permanent failure only —
applied/ignored outcomes, plus invalid_json error rows (that payload can never change); a transient apply-error row is audit only, redelivery re-applies, and recordDelivery upserts the row retaining the prior error in detail. (projector(webhook): a delivery that fails to apply can never be retried — its error row makes every redelivery a 'duplicate', and push events are lost permanently #2456)
- Comment identity is
kind:id, built by one commentKey(kind, numericId) helper at every writer and delete path; the store DB is documented disposable/rebuildable, so migration is a rebuild. (projector(comments): pmp_comments is keyed by the bare GitHub numeric ID — an issue comment, a review comment and a review with the same ID silently overwrite each other #2694)
- The comments guard key is last-update time (
updated_at ?? created_at; reviews: submitted_at for both created_at and the guard key — converging the webhook path onto reconcile's existing correct construction); the new Date() timestamp fallback is removed — a payload with none of its kind's timestamps writes no row. Webhook and reconcile share the row constructors after this phase. (projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it #2455, projector(reviews): webhook reviews get a fabricated created_at (delivery time, not submitted_at) — reconcile's correct row is then guard-refused forever #3087)
- Comment deletion is absorbing — the conflict clause sets
deleted = MAX(deleted, excluded.deleted). GitHub has no un-delete, which answers projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it #2455's open post-delete-write question: none exists. (projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it #2455)
- Item deletion removes the item, its links and its comments in one
deleteItem(ref) — an issue deleted because its content should no longer be shown must not leave its comment bodies rendering under a missing item. (projector(items): an issues deleted event is upserted, not removed — deleted GitHub issues stay in pmp_items forever (no delete path exists, and reconcile only upserts) #4210)
- Items' absence mechanism — PR-only fields (
merged/draft/merged_at) are decided by key presence in the source object, null for absent, and upsertItem applies COALESCE(excluded.x, pmp_items.x) for those three columns only, so a PR-shaped payload's genuine merged = 0 still updates the row. (projector(items): an issues/issue_comment event for a merged PR resets merged to 0 and clears merged_at — issue-shaped payloads carry no merge fields #4158)
Phased breakdown
Phases adopt the seven origin issues as sub-issues (no parallels); Phase 4 is a new closing-audit issue, gated on Phases 1–3.
- Phase 1 — delivery identity & success-only dedupe (adopted: projector(webhook): a delivery that fails to apply can never be retried — its error row makes every redelivery a 'duplicate', and push events are lost permanently #2456 + projector(webhook): a missing X-GitHub-Delivery header collapses every later delivery into the first one's identity — distinct events are silently dropped as 'duplicate' #2982). Lands first: it stops loss at the door. Independent in code from Phases 2–3.
- Phase 2 — comment identity, guard key & absorbing delete (adopted: projector(comments): pmp_comments is keyed by the bare GitHub numeric ID — an issue comment, a review comment and a review with the same ID silently overwrite each other #2694 + projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it #2455 + projector(reviews): webhook reviews get a fabricated created_at (delivery time, not submitted_at) — reconcile's correct row is then guard-refused forever #3087).
- Phase 3 — items: absence writes nothing, deletion removes (adopted: projector(items): an issues/issue_comment event for a merged PR resets merged to 0 and clears merged_at — issue-shaped payloads carry no merge fields #4158 + projector(items): an issues deleted event is upserted, not removed — deleted GitHub issues stay in pmp_items forever (no delete path exists, and reconcile only upserts) #4210).
- Phase 4 — closing writer inventory + contract statement (new issue, gated on Phases 1–3): the contract written into the
schema.sql header / projector README; an inventory of every writer of the four tables with a per-writer disposition; required dispositions — transferred issues (projector(items): an issues deleted event is upserted, not removed — deleted GitHub issues stay in pmp_items forever (no delete path exists, and reconcile only upserts) #4210's explicit out-of-scope), the item row's own new Date() fallback (projector.ts:43), recordPush dedupe under Phase 1, secondary comment fields under the absence rule.
Open questions (in the design doc, not filed)
Transferred issues' source-row disposition; pmp_deliveries retention; push identity beyond the delivery id.
Related
Design doc (full problem/evidence/alternatives/risks): files/designs/code-projector-application-contract.md (goal workspace). Origins: #2456, #2982, #2694, #2455, #3087, #4158, #4210. Neighbours, not this design: #3068 (parsed-shape validation — input shape, not event application), #2747 (projector read-path decode), #2576 (aggregator document ingest).
Filed by the design architect (pass 37, 2026-11-02): design issue for the projector application contract. The seven origin issues are adopted as its phases — triage of each origin should record the phase structure and the decisions above rather than re-filing or re-scoping. Phase 4's closing audit is filed separately and gated on Phases 1–3.
Acceptance criteria
- Each of the seven cited defects is either fixed under the contract or explicitly dispositioned as not-a-defect with evidence: delivery identity required and earned (no shared empty-string identity), dedupe only after successful application, comment identity namespaced by object kind, comment guard keyed on the object's own update time, absence of a field never read as a default, and a deletion path for items.
- New or updated projector tests cover: header-less deliveries not collapsing into one identity, a failed application not counting as applied for redelivery, cross-kind comment ID collisions not overwriting, stale comment replays not resurrecting deleted comments, issue-shaped events not resetting a merged PR's merged/merged_at fields, and an issue deletion removing the item from the read model.
- The aggregator's read model shows no regression on the existing projector test suite.
Sub-issuesCollapse Sub-issuesSub-issues8 of 88 of 8 Issues completedLoading 8 sub-issues Activityadded epicMeta-issue grouping multiple items (org Project Type=Epic) kind/designA design proposal (design-architect): multi-step, phased, decision-bearing on Nov 2, 2026dezren39 commented on Nov 2, 2026
Design architect, pass 37 (2026-11-02): this issue is the design of record for the projector application contract. The seven origin issues are adopted as its phases and linked as sub-issues: Phase 1 = #2456 + #2982 (delivery identity & success-only dedupe), Phase 2 = #2694 + #2455 + #3087 (comment identity, guard key & absorbing delete), Phase 3 = #4158 + #4210 (items: absence writes nothing, deletion removes), Phase 4 = #4303 (closing writer inventory + contract statement, gated on Phases 1–3, status/blocked).
The seven recorded decisions are in the issue body and the design doc (files/designs/code-projector-application-contract.md, goal workspace). Triage of any origin should record the phase structure and those decisions rather than re-filing, re-scoping or splitting the origin. Register entry added to files/potential-projects.md (status: proposed). No user/review: every origin carries explicit acceptance with verified probes, and the open rulings (reject-vs-mint, dedupe outcomes, comment-key form, absorbing delete, item-delete cascade) are the architect's recorded decisions in the doc. dezren39 commented on Nov 2, 2026 Intake review
Related: the seven filings named in the body — issue #2982, issue #2456, issue #2694, issue #2455, issue #3087, issue #4158, issue #4210 — are the defect instances this design contract covers; each should link back here.
Notes: Design epic filed 2026-11-02 by the design-architect source with an audit re-verified at origin/main 23c2c514. It already carried kind/design, source/design-architect, app/pm-stack, status/needs-triage and the epic marker; this pass adds priority/effort and the acceptance-criteria section only — the design itself is Drew's/architect's, not the monitor's to rewrite.
Risks: the contract touches the projector's dedupe and guard semantics — the same code paths whose current behavior the seven filings document; a partial adoption (some writers converted, others not) would recreate the asymmetry the contract exists to remove.
Suggested approach: adopt the contract as one projector change-set with the per-defect tests above, then close or re-point the seven instance filings against it.
— fleet monitor intake enrichment, 2026-11-02. dezren39 commented on Nov 8, 2026 🤖 Agent note · handed off
dezren39 commented on Nov 14, 2026 Released to the queue under Drew's 2026-11-13 unblock-all order (main chat, 23:53 CT). Task(s) 15224 moved from blocked/parked to queued in the fleet unblock-all pass (worker main-unblock-all-2026-11-13). Dependency gates still recorded on a task remain recorded — the dependency checker will re-block it if a gate is genuinely unmet. dezren39 commented on Nov 14, 2026
agent-note:v1
state: triaged — already done; closing
Triage verdict (fresh, 2026-11-14): the contract's Phases 1–3 have landed; this design's acceptance is met. Closing #4302 with evidence.
- All seven origin defects are CLOSED as fixed under the contract: Phase 1 = projector(webhook): a delivery that fails to apply can never be retried — its error row makes every redelivery a 'duplicate', and push events are lost permanently #2456 + projector(webhook): a missing X-GitHub-Delivery header collapses every later delivery into the first one's identity — distinct events are silently dropped as 'duplicate' #2982, Phase 2 = projector(comments): pmp_comments is keyed by the bare GitHub numeric ID — an issue comment, a review comment and a review with the same ID silently overwrite each other #2694 + projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it #2455 + projector(reviews): webhook reviews get a fabricated created_at (delivery time, not submitted_at) — reconcile's correct row is then guard-refused forever #3087, Phase 3 = projector(items): an issues/issue_comment event for a merged PR resets merged to 0 and clears merged_at — issue-shaped payloads carry no merge fields #4158 + projector(items): an issues deleted event is upserted, not removed — deleted GitHub issues stay in pmp_items forever (no delete path exists, and reconcile only upserts) #4210 (e.g. projector(items): an issues deleted event is upserted, not removed — deleted GitHub issues stay in pmp_items forever (no delete path exists, and reconcile only upserts) #4210 fixed and merged via PR fix(projector): remove items on issues deleted events (#4210) #6775, merge 1d3ac35, closed by that PR).
- Contract markers verified at origin/main 0f95933: commentKey / missing_delivery_id / deleteItem present across pm-stack/projector/src/{projector,server,store}.ts; contract test coverage landed with the phases (e.g. pm-stack/projector/test/webhook-delivery-id.test.ts for the header-less delivery identity criterion).
- Phase 4 (closing writer inventory + contract statement) was filed separately, as the design specifies, as issue Phase 4 (audit) of #4302 — closing writer inventory + contract statement for the PM projector #4303. Its gate — Phases 1–3 landing — has now cleared; a gate-cleared note is posted there for its next claimer (its queue task's labels still say blocked until that claim, per the accepted label-lag mode).
- The design doc stands at files/designs/code-projector-application-contract.md in the keep-the-four-repos-healthy goal workspace; open questions recorded there (transferred-issue source rows, pmp_deliveries retention, push identity) belong to Phase 4 (audit) of #4302 — closing writer inventory + contract statement for the PM projector #4303's audit dispositions, not to this design's acceptance.
Task 15224 completes as already_done.
dezren39 commented on Nov 14, 2026 🤖 Agent note · duplicate packet — #4302 already triaged and closed by task 15224
- Agent: repo queue worker, lane any-c (repo-worker-code)
- Session / ID: cron repo-queue-worker-shift-any-c run 2026-11-14; task 16763
Task 16763 duplicates task 15224 (lane code-c), whose triage today (2026-11-14T11:45:36Z, note on this issue) closed #4302 as already done. Independently re-verified in this claim: all seven origin issues adopted by the contract's phases are CLOSED — #2456, #2982 (Phase 1), #2694, #2455, #3087 (Phase 2), #4158, #4210 (Phase 3). Task 16763 completes as already_done; no changes made.
dezren39 commented on Nov 16, 2026
Agent note — Phase 4 audit dispositions + closing evidence (task 6179 for issue #4303, lane any-c)
The Phase 4 audit is complete. The contract statement and the full writer inventory are landed in the projector PR for #4303 (schema.sql header + README "Projection contract (#4302, audited in #4303)"), replacing the stale "applied at most once" wording. Every writer of pmp_items, pmp_comments, pmp_deliveries, and pmp_push_events — every applyEvent branch, every reconcile stream, recordPush, and the /links writers — is inventoried and dispositioned there.
The four required dispositions:
- Transferred-issues source-repo row — DECIDED: delete the source-repo row. A
transferred event proves the issue left the source repo; a live row renders an issue that no longer exists there. Implementation is follow-up [projector] transferred issues: delete the source-repo row (Phase 4 disposition D-1, #4303) #10673, not done blind in the audit: the repo holds no captured transferred payload, and whether payload.issue.number in the source repo's delivery is the source or the new number is unverified — deleting on an unverified key risks removing the wrong row. [projector] transferred issues: delete the source-repo row (Phase 4 disposition D-1, #4303) #10673 captures a real payload as a fixture first, then wires the branch to store.deleteItem.
- Item row's
new Date() created-at fallback — deliberately local, kept with reason. GitHub issue/PR objects always carry created_at and updated_at in both webhook and API shapes (every fixture in the repo does), so the fallback is unreachable from the only two sources; removing it would require a skip-row redesign across the reconcile streams for no production effect. The same reasoning covers commentCommon's fallback for comment kinds. The one kind whose real payload lacks those fields — reviews — was a live defect and is fixed (below).
- recordPush dedupe under Phase 1 — verified, not assumed. Intake rejects a missing delivery id (400
missing_delivery_id) before applyEvent; recordPush inserts ON CONFLICT(delivery_id) DO NOTHING; the e2e duplicate-delivery test proves a redelivered push GUID yields exactly one pmp_push_events row and a 200 duplicate.
- Secondary comment fields (
review_state, path/line, diff_hunk) — checked, no change. The comment upsert overwrites all fields on a guard-passing write (no COALESCE), and that is sound under the absence rule: each kind's events re-send the kind's full field set, the guard admits only the newest version, and reconcile writes the same full-row shape — a null in a newer full payload is the payload's truth (field cleared), not an absence.
One slip found and fixed in the audit: the webhook pull_request_review writer fabricated created_at and the guard key from delivery-time "now" (the review object carries no created_at/updated_at) — a live violation of decision 4 and of Phase 2's webhook/reconcile identity acceptance. Both now derive from submitted_at, matching reconcile's row; a review carrying neither timestamp writes no row. Regression assertions added; probe-verified before/after. The invalid_json handling is recorded in the README as a deliberate deviation from decision 2's pin: it stays a retryable-class error so a redelivery is rejected 400 again rather than acked as a duplicate (a malformed body can never become valid under the same GUID), pinned by the existing e2e test.
Closing evidence — all seven origins closed/verified this audit: #2456 (dedupe), #2982 (deletion), #2694 (comment identity), #2455 (guard key), #3087 (review timestamps), #4158 (merge-field absence), #4210 (item absence) — all CLOSED on fresh check. Contract statement landed; inventory complete; the one in-scope slip fixed with tests (projector suite 158/158).
MetadataMetadataapp/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/lLarge: multi-day or open-ended; expect staged check-insepicMeta-issue grouping multiple items (org Project Type=Epic)epic/pm-stackReprioritization program epic (2026-11-12)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)source/design-architectFiled by the repo design architect jobtask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|