Repository navigation
Description
English version below.
Oi @VictorTaelin! Sou o @tbytefrontier do X. Como te falei, depois de integrar o Bend 2 no JevGate eu ia abrir issues com o que ele encontrasse aqui no repositório, pra você ver se os achados são bons. O suporte a Bend 2 saiu hoje, na versão 0.22.0, com uma regra feita só pro Bend: ela compara o comentário de cada law com o que a lei realmente afirma.
Estes são os achados mais valiosos que encontramos rodando o JevGate no Bend durante a integração. Conferimos cada um no código, e todos continuam valendo no main atual (af569d4).
Como aparece no terminal
$ jevgate check demos/io_http_fetch bend2/base.bend
JevGate: consider · gate passed · 4 files · 16 API requests · 27497 input tokens · ~$0.0012
Consider (4):
bend2/base.bend:2492 [maintainability/hardcoded-values] `Map.diff.fin` likely uses a value whose meaning a reader must guess (0.88). The value is 33n.
→ Give the value a descriptive constant name
demos/io_http_fetch/LAWS.bend:8 [tests/laws] The comment above law `body_after_blank` promises more than the law states (0.81). A definition could break that promise while every proof passes.
→ State the comment's promise in the law, or narrow the comment to what the law states
bend2/base.bend:2479 [maintainability/hardcoded-values] `Map.diff.chr` likely uses a value whose meaning a reader must guess (0.89). The value is 33n.
→ Give the value a descriptive constant name
bend2/base.bend:2457 [maintainability/hardcoded-values] `Map.bit` uses a value whose meaning a reader must guess (0.88). The value is 33n.
→ Give the value a descriptive constant name
35 optional notes on code that reads well as it is; --verbose shows them.
1. demos/io_http_fetch: as leis não fixam o http_body numa resposta com cabeçalhos
O LAWS.bend diz que as leis fixam "the cut that strips the status line and the headers off a response", e o comentário de body_after_blank diz "the text after a blank line is the body, whatever follows it". Mas a lei só cobre textos que começam pela linha em branco:
# LAW: the text after a blank line is the body, whatever follows it.
law body_after_blank:
for b: String
{Fetch.http_body("\r\n\r\n" ++ b) == b : String}
# LAW: the body is a suffix of the text: some prefix, then the body,
# is the text itself.
law body_suffix:
for +s: String
exs p: String
{p ++ Fetch.http_body(s) == s : String}E body_suffix também vale para http_body(s) = s. Então um http_body que só remove um \r\n\r\n do começo e devolve qualquer outro texto sem mudar satisfaz as duas leis, e mesmo assim devolveria a linha de status e os cabeçalhos de toda resposta real. O http_body.go atual corta certo uma resposta real; as leis é que não o seguram nisso, e uma mudança futura poderia quebrá-lo com o PROOF.bend ainda passando.
Sugestão: fixar o corte numa resposta com cabeçalhos. Por exemplo, uma lei que diga que http_body(s) é o texto depois do primeiro \r\n\r\n, ou "" quando não há nenhum, contra uma definição de referência.
Conferindo essa lei, apareceu um detalhe: o http_body.go atual só a satisfaz quando todo caractere de s está abaixo de 256, como os bytes de uma resposta. Ele junta os quatro últimos caracteres num U32, e ഊ (U+0D0A) seguido de \r\n dá o mesmo número que \r\n\r\n, então http_body("ഊ\r\nhello") devolve "hello" sem haver linha em branco no texto. A lei pode exigir essa condição, ou a janela pode comparar os caracteres um a um.
2. bend2/base.bend: o 33n das chaves crit-bit do Map não tem nome
Map.bit (Nat.divmod(pos, 33n)), Map.diff.chr (Nat.sub(33n, Map.msb.u(32n, x))) e Map.diff.fin (Nat.add(33n, Map.diff(xt, yt))) escrevem o mesmo 33n solto. Cada caractere de uma chave ocupa 33 posições de bit: a posição 0 diz que há um caractere, e as posições 1 a 32 guardam o código, do bit mais alto pro mais baixo (é o que o Map.bit.chr lê).
Nada no base.bend diz isso. Quem lê precisa deduzir do Map.bit.chr, e os três 33n, com o 32n e o 31n ao lado, precisam mudar juntos se a codificação mudar. Um def sem argumentos com um comentário sobre o layout (algo como Map.stride()) diria isso num lugar só.
JevGate no CI do Bend
Se você gostar dos achados e quiser rodar o JevGate no CI do Bend, tem uma GitHub Action pronta, a Tech-Byte-Frontier/jevgate-action. Eu te passo uma chave de API do Jev e os custos ficam por minha conta.
E se não gostar dos achados, por favor me diz o que ficou ruim. É esse feedback que eu uso pra melhorar as regras.
Valeu!
English
The same findings in English, for anyone on the team who doesn't read Portuguese.
We added Bend 2 support to JevGate, a code review CLI. It shipped today in 0.22.0, with a rule made just for Bend: it compares the comment on each law with what the law actually states. These are the most valuable findings from running JevGate on this repository during the integration. We checked each against the code, and both still hold on the current main (af569d4). The terminal output above is how JevGate reports them.
1. demos/io_http_fetch: the laws don't pin http_body on a response with headers
LAWS.bend says its laws pin "the cut that strips the status line and the headers off a response", and the comment on body_after_blank says "the text after a blank line is the body, whatever follows it". But the law only covers texts that start with the blank line:
# LAW: the text after a blank line is the body, whatever follows it.
law body_after_blank:
for b: String
{Fetch.http_body("\r\n\r\n" ++ b) == b : String}
# LAW: the body is a suffix of the text: some prefix, then the body,
# is the text itself.
law body_suffix:
for +s: String
exs p: String
{p ++ Fetch.http_body(s) == s : String}body_suffix also holds for http_body(s) = s. So an http_body that only removes a leading \r\n\r\n and returns any other text unchanged satisfies both laws, yet would return the status line and headers of every real response. The current http_body.go cuts a real response correctly; the laws just don't hold it to that, so a later change could break it while PROOF.bend still passes.
Suggestion: pin the cut on a response with headers. For example, a law saying that http_body(s) is the text after the first \r\n\r\n, or "" when there is none, against a reference definition.
Checking that law turned up a detail: the current http_body.go only satisfies it when every character of s is below 256, as the bytes of a response are. It packs the last four characters into a U32, and ഊ (U+0D0A) followed by \r\n gives the same number as \r\n\r\n, so http_body("ഊ\r\nhello") returns "hello" though the text has no blank line. The law can require that condition, or the window can compare the characters one by one.
2. bend2/base.bend: the 33n in Map's crit-bit keys has no name
Map.bit (Nat.divmod(pos, 33n)), Map.diff.chr (Nat.sub(33n, Map.msb.u(32n, x))) and Map.diff.fin (Nat.add(33n, Map.diff(xt, yt))) each write the same bare 33n. Each character of a key takes 33 bit positions: position 0 says a character is there, and positions 1 to 32 hold its code, from the highest bit to the lowest (that's what Map.bit.chr reads).
Nothing in base.bend says this. A reader has to work it out from Map.bit.chr, and the three 33n, with the 32n and 31n next to them, have to change together if the encoding changes. A def with no arguments and a comment on the layout (something like Map.stride()) would say it in one place.
JevGate in Bend's CI
If you like these findings and want to run JevGate in Bend's CI, there's a ready GitHub Action, Tech-Byte-Frontier/jevgate-action. I'll provide a Jev API key and cover the costs.
And if you don't like the findings, please tell me what was off. That feedback is what I use to improve the rules.
Thanks!
Activity
Bend 2.0.32: the issue triage, root fixes, one verdict everywhere
VictorTaelin commentedon Sep 27, 2026
Fixed in Bend 2.0.32 (573002f): LAWS files hold only laws, and io_http_fetch's LAWS comments claim only what the laws state.
tauanbinato commentedon Sep 27, 2026
Valeu, @VictorTaelin! Rodei o JevGate de novo no
main(2.0.32) e as duas leis doio_http_fetchagora saem limpas: o comentário afirma só o que as leis afirmam.Hoje lancei o JevGate 0.23.0. A oferta continua de pé: se quiser rodar no CI do Bend, eu passo uma chave da Jev e cubro os custos. E se algum achado for ruído, me avisa que eu corrijo do meu lado.