Skip to content

basou: Observe the response to an HTTP GET on a board, and move boards and records to version 3 - #361

Merged
takashi-matsuyama merged 2 commits into
board/shape-v3from
board/observe-http
Oct 17, 2026
Merged

takashi-matsuyama merged 2 commits into
board/shape-v3from
board/observe-http

Conversation

@takashi-matsuyama

Copy link
Copy Markdown
Member

This is the first of the changes that move basou board (experimental) to a new shape of its declaration and its records. They land on the integration branch board/shape-v3, not on main, and go to main and out in one release once all of them are in, so the shape changes once.

What changes

  • board_version: 3 and record_version: 3. basou board init prints version 3. Boards of version 1 and 2 are read as before; every record is now written as version 3, whatever the version of its board; records of version 1 and 2 are still read, compared with and drawn.

  • The observation kind http (from board_version: 3): an https:// URL, held to the shape of a page_version's, and optionally:

    • words: whether the body holds each word, as written (no HTML entity decoded);
    • count_pattern: how many times it matches the whole body (flags gu; one that matches the empty string is refused);
    • capture_pattern: what its first group holds in the first match (flag u; it needs a capturing group).

    GET only, with no method to declare. A word or a pattern that is empty, holds a control character or a ', or starts with - is refused, as is a word given twice.

  • basou board guide gives the commands for it; basou still sends nothing:

    • curl -sS -L --max-redirs 10 --max-time 20 -o "$W/http-<key>.body" -w '%{http_code} %{num_redirects} %{url_effective}\n' '<url>', without -f, so a 404 prints 404 0 <url> and exits 0 (more than 10 redirects exits 47);
    • when the board reads the body, a node -e line that reads the body whole with readFileSync(0, "utf8") (so a character is never cut where a 64 KiB chunk ends), takes off a leading BOM, is given the patterns and the words after -- (so a word is never read as an option of node's), and stops at an empty match rather than count positions.

    The value is { status, redirects, final_url }, with words (true or false in the order declared), count and capture as declared. A 4xx or 5xx is a value, not an observation not made; when the status is not 2xx, what the body would give is null ("words": null, not a list of nulls).

  • basou board record takes the keys of an http value (status, redirects, final_url, words, count, capture) as words of the input's shape: its check for the names of other registered workspaces no longer refuses a value written as the guide says when a workspace is named like one of them, and still looks at what they hold.

  • A board of version 1 or 2 that uses what a later version reads is told so on a line of its own, for a kind or a value as for a key (observe[0].kind: 'http' is read from board_version 3 on; this file is board_version 2). Until now only a key was. Each problem is put down to the first version that reads that part of the file as written. A key no version reads so is put down to the first version that takes the key, or to a later one when what is wrong inside it is what that version reads (an http observation under the observe of a version 1 board is told version 3, not 2). Problems no version would take are reported as before.

Tests

  • Declaration: what http takes and refuses (words, both patterns, the URL, a method or any other key), and which version a problem of a version 1 or 2 board is put down to.
  • Guide: the commands as printed, and run: the node line over bodies (the words in order, the count, the capture, a BOM, a word starting one byte before 64 KiB, an empty match), and the curl line against a local server (a redirect, a 404 with exit 0, exit 47 past 10 redirects).
  • Records of version 3 hold an http observation as declared and its value as given; the page draws one; board record takes a value whose keys are named like a registered workspace.
  • Mutation checks in a copy: each of 34 mutations of the new code fails a test, but one that changes nothing observable (a version that is not a number sent down the path for older versions).
  • pnpm -r build, pnpm typecheck, pnpm -r test:coverage, pnpm test:scripts, pnpm lint, pnpm lint:lang and pnpm lint:paths pass locally.

…s and records to version 3

- board.yaml: board_version 3 adds the observation kind http: an https://
  URL (held to the shape of a page_version's), and optionally words, a
  count_pattern (flags gu, matched against the whole body; one that matches
  the empty string is refused) and a capture_pattern (flag u, with at least
  one capturing group). GET only. A word or a pattern that is empty, holds
  a control character or a quote, or starts with '-' is refused, as is a
  word given twice.
- A board of version 1 or 2 that uses what a later version reads is told
  so on a line of its own for a kind or a value as for a key: each problem
  is put down to the first version that reads that part as written, and a
  key, when none does, to the first version that takes it.
- board guide: a curl without -f that prints the status, the redirects and
  the URL it ended at, and a node line that reads the body whole as UTF-8
  (without a leading BOM), is given the patterns and words after --, and
  stops at an empty match. The value is { status, redirects, final_url }
  with words, count and capture as declared, null when the status is not
  2xx.
- board init prints board_version 3, and its comment names http.
- Records are written as record_version 3, whatever the version of the
  board; versions 1 and 2 are still read and drawn.
…lls off 2xx, a kind under an older key, and the guide's code spans

- board record: the keys of an http observation's value (status,
  redirects, final_url, words, count, capture) are words of the input's
  shape, so the check for other workspaces' names no longer refuses a
  value written as the guide says when a registered workspace is named
  like one of them. What they hold is still looked at.
- board guide: off 2xx, say "words": null and not a list of nulls, naming
  only what the board declares; capture is null also when its first group
  takes no part in the match; words and patterns are written as Markdown
  code that shows backquotes and spaces as they are.
- A board of version 1 whose observe holds an http observation with a
  problem inside it is told version 3, not 2: a key is put down to a later
  version when what is wrong inside it is what that version reads.
- Only an empty word or pattern is empty: one of spaces is taken.
- The record version's comment says a record of version 3 may hold a
  declaration of version 3.
- Tests for the u flag in the guide's line, case, a word at the body's
  start, a BOM inside the body, an http key that is not an id, a word given
  twice outside http, a file with no version, empty matches only under u
  or only in the empty text, and the guide's text with nothing observed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant