Conversation
b272fc8 to
7f10a1a
Compare
pjdotson
left a comment
There was a problem hiding this comment.
The biggest thing to note here is that I don't think we should have separate function signatures (arguments and returns) for WASM and Flow. This is going to confuse users because something with the same name (status.set or status.delete) will have two different ways of calling it and return two different things.
|
|
||
| **Backward compatibility**: The existing `status_key` Flow config field is preserved. | ||
| Programs using `status.set{status_key="...", ...}` continue to work unchanged. The | ||
| `name` config field is a new alternative for Flow form, not a replacement. WASM form |
There was a problem hiding this comment.
I don't understand this: your signature above does not have a name argument
There was a problem hiding this comment.
I got myself confused when working on the ranges rfc in parallel. My aim/suggestion is to have a unified "identifer" field that accepts the key or name streing for the status. I'm still exploring this idea.
I think it would make sense to have a `status.create(name="") function, where the behavior would be:
- create if
not_found - If one is found, throw a notification and return.
- If multiple are found, throw a warning and return the first.
- Or we could decide to throw an error and return
None.
- Or we could decide to throw an error and return
We just need a clean way for operators to initialize/define the statuses and make sure they are in the system before their sequences run and they call the standard status.set(id, variant, msg) with low friction.
98cfbc1 to
1c0cf75
Compare
vs. One gets called like this |
emilbon99
left a comment
There was a problem hiding this comment.
See my long comment attached to the RFC
|
|
||
| var stat status.Status[any] | ||
| if _, err := uuid.Parse(identifier); err == nil { | ||
| err := statusSvc.NewRetrieve().WhereKeys(identifier).Entry(&stat).Exec(ctx, nil) |
There was a problem hiding this comment.
We already have built-in update capabilities in gorp. There is no need to invent your own retrieve/write mechanisms here. If you need an update mechanism, then you should update the status service to support it.
There was a problem hiding this comment.
Do you want me to leave syntax correction comments like this in an RFC?
There was a problem hiding this comment.
Updated the RFC to add a Writer.Update method on the status service that wraps gorp.NewUpdate, and reworked the host function to compose service methods instead of opening retrieve/write directly.
|
@emilbon99 , replying to this top-level comment
|
| return | ||
| } | ||
| var results []status.Status[any] | ||
| if err := statusSvc.NewRetrieve(). | ||
| WhereNames(identifier).Entries(&results).Exec(ctx, nil); err != nil { | ||
| reportError(ctx, err) | ||
| return |
There was a problem hiding this comment.
gorp.ErrNotFound vs query.ErrNotFound inconsistency
The set host function (Section 5.2.1, line ~511) checks errors.Is(err, query.ErrNotFound) when the Update method returns a not-found error (as specified in Section 5.5). The delete host function here checks errors.Is(err, gorp.ErrNotFound) against the return from Writer.Delete. If these are different sentinel values, one of the two checks is silently a no-op: for delete, a by-key miss would fall through to reportError instead of the intended reportWarning path. Both call sites should use the same sentinel type, and Section 6.0's change table should document which package owns the canonical not-found error.
Pull Request
SY-4122
Greptile Summary
This PR introduces RFC 0037, specifying an Arc
statusmodule with twoExecBothfunctions —status.set(name/key upsert with preserve-on-omit semantics) andstatus.delete(by key or name) — plus a companion trade study evaluating design alternatives. The RFC is detailed and addresses several edge cases (concurrency viaUpsertByNametransaction, WASM positional constraints, empty-string truthiness prerequisite), but has one implementation-level inconsistency that could silently mis-route errors:deletehost-function pseudocode checksgorp.ErrNotFoundwhile thesetpseudocode and the specifiedUpdatemethod both usequery.ErrNotFound; if these are distinct sentinel values, thedeleteby-key-miss branch will never match, routing not-found toreportErrorinstead of the specifiedreportWarning.Confidence Score: 4/5
Safe to merge after resolving the ErrNotFound inconsistency between set and delete pseudocode.
One P1 finding: the delete host-function pseudocode uses
gorp.ErrNotFoundwhile the set pseudocode andUpdatespec usequery.ErrNotFound. If these differ, the delete by-key-miss warning branch is silently dead. No other blocking issues; the concurrent-create race is addressed viaUpsertByName, the multi-match contradiction was resolved, and WASM positional limitations are now documented and acknowledged.docs/tech/rfc/0037-260427-arc-status-updates.md — specifically Sections 5.2.2 and 5.5 regarding error sentinel consistency and the undocumented Writer struct additions.
Important Files Changed
statusmodule (set/delete). Contains a P1 inconsistency: the delete pseudocode usesgorp.ErrNotFoundwhile the set pseudocode andUpdatespec usequery.ErrNotFound; also references aw.dbfield andWriter.NewRetrieve()method that are not listed in the change table.status.set. Self-contained and well-reasoned; minor issue is the opening header says "Not committed" despite being committed.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Arc call site] -->|WASM positional| B[status.set host fn] A -->|Flow named config| C[setStatus Flow node] B --> D{uuid.Parse identifier} C --> D D -->|parseable - key path| E[Writer.Update] D -->|not parseable - name path| F[Writer.UpsertByName tx] E -->|query.ErrNotFound| G[reportError / return 0] E -->|other error| G E -->|success| H[return key handle] F --> I{WhereNames results} I -->|0 matches| J[create new status] I -->|1 match| K[apply overlay + persist] I -->|>1 matches| L[errMultipleMatches → reportError / return 0] I -->|query error| L J --> M[return new key] K --> N[return existing key] O[status.delete host fn] --> P{uuid.Parse identifier} P -->|parseable| Q[Writer.Delete by key] P -->|not parseable| R[Retrieve WhereNames] Q -->|gorp.ErrNotFound| S[reportWarning] Q -->|other error| T[reportError] R -->|0 matches| S R -->|1 match| U[Delete single row] R -->|N matches| V[Delete all rows + reportInfo count]Reviews (8): Last reviewed commit: "SY-4122: update" | Re-trigger Greptile