fix: harden rac ingest and outbox handling#1040
Conversation
| end; | ||
| ratchet_rule(_) -> strict. | ||
| parse_ratchet(false) -> {ok, strict}; | ||
| parse_ratchet(<<"false">>) -> {ok, strict}; |
There was a problem hiding this comment.
Can we just parse_ratchet(Atom) when is_atom(Atom) -> parse_ratchet(...) here if we are editing it anyway? Nasty clankerism made its way in.
| %% @doc Admit or reject one inbound message. Untagged traffic (no `rac-slot') | ||
| %% passes through unchanged. | ||
| ingest(Base, In, Opts) -> | ||
| ingest(Base, In, Opts) when is_map(In) -> |
There was a problem hiding this comment.
is_map or ?IS_LINK I think? Ideally 'link to message', too. On at least one branch/edge we have an IS_MESSAGE that covers this. Not sure if it has landed yet though.
| parse_slot(Value) -> | ||
| parse_nonneg_int(Value). | ||
|
|
||
| parse_nonneg_int(N) when is_integer(N), N >= 0 -> |
There was a problem hiding this comment.
We must have something for this already? It is the same logic as the scheduler and processes both need. Perhaps we should put it in lib_process_utils or similar?
| {ok, | ||
| hb_maps:fold( | ||
| fun(Key, Value, Acc) -> | ||
| NormKey = hb_util:to_lower(hb_ao:normalize_key(Key)), |
There was a problem hiding this comment.
I think there is something in hb_utils for this already. lower_case_map or similar.
There was a problem hiding this comment.
Then we would just need a hb_maps:with rather than the fold.
| 2. Stamp the outbound message with `rac-slot = Slot` and `target = recipient`, | ||
| plus `rac-channel`/`rac-ratchet` when they differ from their defaults. | ||
| 3. Append the stamped message to the outbox (`results/outbox`). | ||
| Existing top-level RAC control keys, `target`, and `from-*` provenance keys |
There was a problem hiding this comment.
Isn't that the responsibility of ~push@1.0, not ~rac@1.0? I can kind of see the logic for it being here, but if I am seeing it correctly it would blow the edges of the abstraction. For example, if push@2.0 wanted to utilize rac@1.0 (or some other device construct), we would end up breaking it in a super counter-intuitive way that would require the dev/us to hack around it in another ugly way, etc.
from-processfor tagged RAC inbound -- removed signer fallback (so only process-to-process)