Chapter 1 · Session 20
The path from the press to the platform, and who does what
Until now every reading in the platform was typed by a person or made up for testing. This session lets the machines report for themselves, without anyone outside the plant ever being able to reach a machine. Most of the work is done with your IT and OT people, not by Claude Code; this chapter says who does which part, and writes the design down before anyone changes a firewall.
30 min2 stepsAbout 3 hours hands-on in all, plus two meetings with IT and OT
By the end of this chapter you can
- Name each layer between a press controller and the platform: OPC UA, the Ignition gateway, MQTT with Sparkplug B, the DMZ connector.
- Place each piece on the Purdue model and explain why every connection starts inside the plant and goes out.
- Say which parts IT, OT, you and Claude Code each do.
- Have Claude Code draft docs/connectivity.md, and fill in what only IT and OT know.
Six layers, each with one job
A press's peak tonnage lives in its controller's memory. To reach a screen on a supervisor's phone it passes through six layers. Each layer does one job and can be replaced without disturbing the others, and only the bottom one can ever touch a machine.
| Layer | Its job | In the stamping plant |
|---|---|---|
| Controllers | Run the press. Their memory holds the values. | Six press PLCs and the in-die sensors |
| Drivers and OPC UA | Read values and give them names and types | OPC UA servers on the newer PLCs, the gateway's drivers on the older ones [1] |
| Gateway | Tags, history, alarms and local screens; keeps running if everything above it is down | Ignition, at Level 3 [2] |
| MQTT with Sparkplug B | Publish changes, not polls, to a broker | Ignition's MQTT Transmission module publishing to a broker in the DMZ [3] |
| DMZ connector | Takes the readings the platform needs and sends them out | A small program Claude Code writes in this session |
| Your platform | Stores, secures and shows the data | Supabase and Vercel, on the company's accounts (Session 1) |
OPC UA, Sparkplug B and CESMII in one paragraph each
OPC UA (IEC 62541) lets a client browse named, typed values with a time and a quality flag instead of register numbers, and builds security into the connection: each side has a certificate, and the mode is None, Sign, or Sign and Encrypt [1]. Ask OT for Sign and Encrypt and a read-only account; mode None is for laboratories.
MQTT sends a value only when it changes (report by exception), to a broker that passes it on to whoever subscribed. Sparkplug B, an Eclipse specification published as ISO/IEC 20237, fixes the topic shape and payload and adds birth certificates (a device announces every value it has when it connects) and death certificates (the broker announces when a device drops off, so a frozen value is never mistaken for a steady one) [3].
CESMII, the US Smart Manufacturing Institute, publishes Smart Manufacturing Profiles: open definitions of a type of equipment and its values, and runs the Smart Manufacturing Innovation Platform (SM-IP) where members model and share data with them [4]. Before you name a press's values, look for a profile or an OPC UA companion specification and reuse its names in your naming standard (Session 4).
Where each piece sits, and which way it connects
IT sorts the plant into Purdue levels: machines and controllers at 0 and 1, supervisory screens at 2, site operations (the gateway, the historian) at 3, the business network and the internet at 4 and 5. Between 3 and 4 is the industrial DMZ, Level 3.5, where traffic from either side ends [5] [6]. Your platform is in the cloud. That is fine as long as it never reaches down.
The DMZ connector pattern is one rule: every connection starts inside and goes out. The gateway publishes out to the DMZ broker on port 8883 (MQTT with TLS). The connector, also in the DMZ, subscribes to that broker and sends readings out to Supabase on port 443 (HTTPS), signed in as its own account that may only add readings. Nothing in the cloud or the office has an address to call into the plant, so even a stolen platform key cannot touch a press.
Who does what
Be honest with yourself about this table. Claude Code cannot configure Ignition, open a firewall or install a server in the DMZ, and should not try. What it does well is write the design, the account and its tests, the connector and its tests, and the exact requests IT and OT need, so each meeting ends with a decision instead of a list of questions.
| Task | Who does it | Claude Code's part |
|---|---|---|
| Reading the presses into Ignition, OPC UA security | OT (controls engineer) | None. It gives OT the list of tags the platform needs |
| Publishing Sparkplug B to the DMZ broker over TLS | OT, in Ignition's MQTT Transmission module | Writes the exact group, node, device and metric names |
| The DMZ host, the broker, firewall rules, the company proxy | IT (network or OT security) | Writes the request: one row per rule, with the reason |
| The design: docs/connectivity.md | You, with Claude Code | Drafts it; you correct it with IT and OT |
| The connector's matrix row, access rules and tests | You, with Claude Code | Writes them in one pull request |
| Creating the connector's account and its password | You, in the Supabase dashboard | None. It never sees a password |
| The connector program, simulated and real | Claude Code writes it; you run it; IT installs it | Writes it with its tests |
Have Claude Code draft the connector design, with the questions only IT and OT can answer
15 minutesWhy
IT and OT approve what they can read. A design written before the meetings turns each meeting into corrections to a page instead of an open discussion, which is the difference between one meeting and four. Writing it in the repository, next to the code, means it changes when the design changes, and Session 21's IT package is generated from it.
Do this
cd ~/code/acme-platform && git switch main && git pull && claudeRead docs/INTENT.md, docs/naming-standard.md, docs/SCHEMA-PLAN.md, docs/matrix.json and docs/KEYS.md first. Do not write any code in this task.
On a new branch connectivity/design, write docs/connectivity.md: how machine readings from Cleveland (cle) reach the platform, for an IT and OT reader who has never seen the platform. Use these headings:
1. What the platform needs from the machines: only the measures the intent's decision needs, each by its standard name from the naming standard, with unit and how often it changes. No recipes, PLC programs, drawings or personal data ever leave the plant.
2. The path: controllers, OPC UA or drivers, the Ignition gateway (Level 3), MQTT with Sparkplug B over TLS on port 8883 to a broker in the industrial DMZ (Level 3.5), a connector in the DMZ that sends readings over HTTPS on port 443 to https://abcdefghijklmnopqrst.supabase.co. Draw it as a Mermaid diagram with the Purdue levels.
3. The rule: every connection starts inside and goes out; nothing connects into Level 3 or below.
4. The connector's account: a machine account in the matrix, role plant_connector, site cle, that may insert readings and nothing else. It signs in with its own password, never with the Supabase secret (service role) key.
5. Data flows: one row per arrow, with source, destination, protocol, port, which side starts it, the data and the account.
6. Firewall request: one row per allowed flow, ending with "deny everything else, and log it".
7. When something fails: the internet link, the broker, the connector, the platform, the gateway. For each: what the plant does, what the platform shows, how it recovers. The connector stores readings while the link is down and sends them in order when it returns.
8. Questions for OT and Questions for IT: everything this design needs that the repository cannot know (tag names in Ignition, OPC UA security mode, whether the MQTT Transmission module is licensed, the DMZ host, the broker, the proxy, who installs and patches what). Mark every unknown in the text as TO CONFIRM.
Open a pull request titled "Connectivity design (draft)" and show me the link. Do not merge it.You will see recreated screen
- It reads the naming standard and the matrix first, so the measures and the account use names that already exist.
- Every arrow is a row. IT will check that the diagram and this table match exactly.
- The questions are the agenda for the two meetings in Step 2.
Check it worked
Pull request Connectivity design (draft) has one file, docs/connectivity.md, with a diagram, a data flow table in which no row starts outside the plant, a firewall request ending in deny-all, and a list of questions for OT and for IT.
Fastest path
Send the link to the pull request's file to the OT and IT people the same day, with the two question lists pasted into the email. They answer in their own time and the meetings get shorter.
If it goes wrong
Claude Code proposed that the platform connect to the gateway, or a VPN into the plant
Say: No connection may start outside the plant and end at Level 3 or below. Redraw it so the gateway publishes out to the DMZ and the connector sends out to Supabase. A vendor's cloud service that wants to reach the gateway gets the same answer: it reads from the DMZ.
The design lists every tag on the gateway
Say: Only the measures docs/INTENT.md's decision needs. Move the rest to a Not now list. Each extra measure is another row IT has to approve and another thing that can break.
It wants to use the Supabase secret (service role) key for the connector
Say: No. That key skips every access rule. The connector signs in as its own account, which the matrix limits to adding readings. On our own platform the most powerful login was the one that did the damage; the connector is the program most exposed to the outside, so it gets the weakest one.
Walk the gateway with OT and the firewall with IT, then record their answers
2 meetings, then 10 minutesWhy
Only OT knows which tag on press 3 really holds peak tonnage, and only IT knows whether outbound traffic goes through a proxy. A guess at either costs a failed install day in the plant. Recording their answers in the design, in their words, also gives Session 21 the evidence that IT and OT were consulted.
Do this
With the OT engineer, at the Ignition gateway's web page: look at the device connections together, then the tag browser, and write next to each measure in the design the exact tag path that holds it. Ask whether the PLCs' OPC UA connections use Sign and Encrypt, and whether the MQTT Transmission module is installed and licensed (it is a paid module from Cirrus Link; price it before you promise a date).
With the IT person: read the data flow table and the firewall request together. Ask the six questions. Agree who provides the DMZ host and the broker, who patches them, and whether outbound HTTPS goes through a proxy.
OT and IT answered the questions in docs/connectivity.md:
OT: <paste their answers, including the exact Ignition tag path for each measure>
IT: <paste their answers>
On the same branch:
1. Replace each TO CONFIRM they answered with their answer, and list anything still open under "Open items" with an owner and a date.
2. If docs/naming-standard.md or the repository already has an alias table, add these tags to it. Otherwise create docs/tag-aliases.csv with the columns legacy_tag, standard_name, unit, conversion, source: one row per Ignition tag, mapping it to the measure's standard name. Run node scripts/check-names.mjs and fix any name it refuses.
3. Add "Reviewed with <OT role> and <IT role> on <date>" at the top.
Push, wait for the checks, and tell me what is still open.You will see recreated screen
| Name | Driver | Status |
|---|---|---|
| press-1 | Allen-Bradley Logix | Connected |
| press-2 | Allen-Bradley Logix | Connected |
| press-3 | OPC UA (Sign and Encrypt) | Connected |
| press-4 | Siemens S7-1500 | Connected |
| press-5 | Siemens S7-1500 | Connected |
| press-6 | Modbus TCP | Connected |
- One connection per press. The driver column tells you which presses speak OPC UA and which use the gateway's own drivers: ask about security mode on every OPC UA line.
- The legacy tag path. It goes in the alias table next to the standard name; nothing in Ignition is renamed.
You will see recreated screen
- The alias table: the plant keeps its names, the platform uses the standard one, and any unit conversion is written down.
Check it worked
docs/connectivity.md says who reviewed it and when; every measure has its Ignition tag path; docs/tag-aliases.csv (or your existing alias table) maps each tag to a standard name that check-names accepts; open items have an owner and a date. Owner two approves and it merges.
Fastest path
Ask OT for an export of the tag list for the presses (Ignition can export tags as a file) and paste the relevant rows into the prompt. Typing tag paths by hand is where the mistakes come from.
If it goes wrong
OT says the PLCs' OPC UA connections use security mode None
Write it down as an open item for OT, not a blocker for this session: the connector never talks to the PLCs. But it is a real risk on the plant network, and Session 21's package will list it.
IT says nothing may leave the plant network at all
Ask which exit they do allow (many plants allow outbound HTTPS through a proxy from the DMZ only). If none, the connector cannot work yet; record it as the first open item and continue with the simulation in Chapter 3, which needs no plant network.
The same measure has different tag names on different presses
That is normal and exactly what the alias table is for: several legacy tags, one standard name per press.
Knowledge check
Which layer keeps the presses' screens, alarms and history running when the internet is down?
Knowledge check
A vendor asks for their cloud service to connect to the Ignition gateway to collect data. What does the pattern say?
References
- OPC Foundation: OPC Unified Architecture. https://opcfoundation.org/about/opc-technologies/opc-ua/
- Inductive Automation: Ignition user manual. https://docs.inductiveautomation.com/
- Eclipse Foundation: Sparkplug specification. https://sparkplug.eclipse.org/specification/
- CESMII, the Smart Manufacturing Institute. https://www.cesmii.org/
- NIST SP 800-82 Rev. 3, Guide to Operational Technology (OT) Security. https://csrc.nist.gov/pubs/sp/800/82/r3/final
- Cisco and Rockwell Automation: Converged Plantwide Ethernet, Industrial DMZ design (CPwE IDMZ). https://www.cisco.com/c/en/us/td/docs/solutions/Verticals/CPwE/3-5-1/IDMZ/DIG/CPwE_IDMZ_2_CVD/CPwE_IDMZ_2_Chap2.html
Chapter 2 · Session 20
The connector's account: one matrix row, insert-only, proven
The connector is the program most exposed to the outside world, so it gets the weakest account in the platform: it may add readings for its own site and do nothing else, not even read them back. One prompt adds that account to the role matrix, generates its access rules and the tests that prove them; then you create the account yourself in the development project.
35 min2 stepsThe machine account testing protocol
By the end of this chapter you can
- Explain why the connector is a machine account in the matrix and never uses the secret (service role) key.
- Have Claude Code add the readings table, the plant_connector row, its generated policies and its access tests in one pull request.
- Create the connector's account in the development project yourself, and record it in docs/KEYS.md by name only.
A machine account is a role like any other
Session 7's matrix lists jobs, not people: operator, supervisor, quality lead and the others. The connector is one more column with the same treatment: a role (plant_connector), a scope (one site) and rights per table. Because the access rules and their tests are generated from the matrix (Session 8), adding the row is enough to give the connector exactly its rights and to prove it has no others.
The tempting shortcut is the Supabase secret key, which already works and needs no account. It also skips every access rule and can change or delete anything [1]. If the DMZ host were ever compromised, whoever held that key would hold the whole platform. With its own account, the worst a thief can do is add readings for one site, which the database marks with the connector's name.
| Right | plant_connector | Why |
|---|---|---|
| Insert into machine_readings, own site | Yes | Its one job |
| Insert for another site | No | A connector at cle speaks for cle only |
| Read any table, including its own readings | No | It never needs to; a stolen password reads nothing |
| Update or delete anything | No | Readings are records: append-only, like inspections |
| Any page or route of the app | No | It has no screens; every route refuses it |
The machine account testing protocol
These tests join the access tests from Session 8 and run on a fresh database on every pull request. Each exists because a missing one has cost someone a record or an audit:
| Test | What it proves |
|---|---|
| Allowed: insert at own site | The connector can do its job |
| Refused: insert at another site | A connector, or a stolen password, cannot write as another plant (the cross-site test from Session 8) |
| Refused: select on every table | A stolen password reads nothing |
| Refused: update and delete on readings | History cannot be changed, by the connector or anyone |
| Refused: insert into any other table | It cannot create lots, holds or memberships |
| Refused: every route of the app | Signing in as the connector opens no page (the route tests from Session 9) |
| Refused: a measure that breaks the naming standard | A mis-mapped tag fails loudly instead of creating a new name |
| Refused: a duplicate reading | Replaying the buffer after an outage cannot double-count |
One prompt: the readings table, the matrix row, its access rules and its tests
20 minutesWhy
The table, the matrix row, the generated policies and the tests belong together: a right without a test is a right an agent can quietly widen later, and a table without its rules is readable through the website's key. One complete prompt, which also tells Claude Code to wait for GitHub's check, replaces the half-dozen rounds it takes to add each piece as you remember it.
Do this
Read docs/connectivity.md, docs/naming-standard.md, docs/SCHEMA-PLAN.md, docs/matrix.json, scripts/gen-policies.mjs and supabase/tests/access.test.sql first, and follow how roles, policies and tests are already done.
On a new branch connectivity/connector-account:
1. Run npx supabase migration new machine_readings and create public.machine_readings, an event table: one row is one value one machine reported. Columns: id, site_id, equipment_id (references equipment), measure (the standard name; a check that it follows the naming standard's pattern), value numeric, read_at timestamptz (the time at the machine), received_at timestamptz default now(), source_tag (the legacy tag it came from), reading_key text (unique per site, so a replayed reading is refused as a duplicate), synthetic boolean not null default false, recorded_by uuid default auth.uid(). Append-only with the existing append_only() trigger. Row-level security on.
2. Add the role plant_connector to docs/matrix.json as a machine account: scope one site; insert on machine_readings only; no select, update or delete anywhere; no screens. Add read rights on machine_readings for the human roles that need it for the decision, as docs/INTENT.md says, and show me which you chose.
3. Run node scripts/gen-policies.mjs so the policies migration, lib/access/routes.ts and the access tests are regenerated from the matrix. Do not write policies by hand.
4. Make sure the tests prove, signed in as plant_connector at cle: insert at own site allowed; insert at another site refused; select on every table returns nothing; update and delete on machine_readings refused; insert into every other table refused; a measure that breaks the naming standard refused; a duplicate reading_key refused; every route of the app refuses the connector.
5. In docs/connectivity.md, add a section "Creating the connector account" with the exact SQL a person runs in the Supabase SQL editor to give an existing account the plant_connector membership at site cle, using the account email connector.cle@acme.com.
6. Do not connect to or change any Supabase project.
Show me one of the refusal tests failing when its rule is removed, then put the rule back. Push, open a pull request titled "Connector account: insert-only machine role", wait for every check, and tell me the result in plain words. If a check fails, fix it and wait again before reporting.You will see recreated screen
- The only hand-written change: one role in the matrix. Policies, routes and tests are generated from it.
- Shown red first: the test fails when its rule is missing, so it can never pass by accident.
- Count the refusals. Almost everything this account tries must be refused.
Check it worked
Pull request Connector account: insert-only machine role is green on GitHub. Its Files changed tab shows one hand-edited role in docs/matrix.json, a new migration, regenerated policies and tests, and the SQL for the membership in docs/connectivity.md. Owner two approves; merge. The deploy workflow (Session 11) applies the migration to production on merge.
Fastest path
"Wait for every check and fix it before reporting" saves a round trip. "Show me a refusal test failing when its rule is removed" saves the worst kind of round trip: finding out months later that a test could never fail.
If it goes wrong
Claude Code wrote policies by hand instead of regenerating them
Say: Remove the hand-written policies. Change docs/matrix.json and run scripts/gen-policies.mjs. The matrix is the only source of rights. A hand-written policy is a right nobody reviewed.
It gave plant_connector select on machine_readings "so the insert works"
That is the read-back problem above. Say: Remove the select right. Insert without returning the row (no .select() after insert).
The route tests fail because the new role has no screens
Correct behaviour, wrong test. Say: The route tests must expect every route to refuse plant_connector. Fix the generator so a role with no screens is refused everywhere, then regenerate.
Claude Code says all tests pass, but the check on GitHub is red
Say: The check on the pull request is red. Read its log with gh run view --log-failed, fix the cause and wait for green before you report. A summary is a claim; the check on GitHub is the evidence.
Apply it to the development project, and create the connector's account yourself
15 minutesWhy
The account has a password, and passwords are handled by people, in the password manager, never by Claude Code. The simulation in Chapter 3 runs against the development project, so the new table and the account go there first; production gets its own account only when the real connector is installed, so made-up readings can never reach it.
Do this
In a terminal, not inside Claude Code. When asked, paste the development project's database password from the password manager (Supabase: acme-platform-dev database password):
cd ~/code/acme-platform && git switch main && git pull && npx supabase link --project-ref tsrqponmlkjihgfedcba && npx supabase db pushIn the password manager, create an entry Platform connector, acme-platform-dev with a generated password of at least 24 characters. Then create the account:
https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/auth/users
Choose Add user, then Create new user. Email: connector.cle@acme.com. Paste the password from the password manager. Tick Auto Confirm User. Create.
https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new
Paste the SQL from the section Creating the connector account in docs/connectivity.md, and press Run. It should look like the example below.
-- Give the connector account its one role, at one site.
insert into public.memberships (user_id, site_id, role)
select u.id, s.id, 'plant_connector'
from auth.users u, public.sites s
where u.email = 'connector.cle@acme.com' and s.code = 'cle';Last, the register. In Claude Code:
On a new branch docs/keys-connector, add to docs/KEYS.md, names and locations only, never values: "Platform connector password, development" (unlocks: adding readings at cle in acme-platform-dev; lives in the company password manager; held by pat@acme.com and sam@acme.com) and "Platform connector password, production" (not created yet: created in Session 20 step 8; will live in the password manager and in IT's credential store on the DMZ host). Add the account connector.cle@acme.com to the accounts list as a machine account. Open a pull request.You will see recreated screen
- Only the new files. If the list is long or includes files you do not recognise, the development project is behind main: answer n and ask Claude Code which versions differ before going on.
You will see recreated screen
| Provider | Created | Last sign in | |
|---|---|---|---|
| connector.cle@acme.com | 3 Nov 2026 | Never | |
| pat@acme.com | 14 Oct 2026 | 2 Nov 2026 |
- A company address that IT controls (a shared mailbox or alias), never a person's own. When people leave, the connector keeps working.
Check it worked
The SQL editor answers Success. 1 row to the membership insert. The users list shows connector.cle@acme.com. docs/KEYS.md lists both connector passwords by name, with no value anywhere in the pull request.
If it goes wrong
The membership insert says 0 rows
Either the email is typed differently in the users list, or the site code is not cle in the sites table. Check both, character by character; do not change the SQL's role name.
db push lists migrations you did not expect
The development project fell behind main. Answer n. In Claude Code: Compare npx supabase migration list for the development project with supabase/migrations on main and tell me in plain words what each missing version does, without changing anything. Apply them only once you understand them; it is the development project, but its seed data matters for Chapter 3.
You pasted the password somewhere other than the password manager and the Supabase form
Treat it as known to others. Create a new password, set it on the user in Supabase (the user's menu, then reset or change the password), and note the date in docs/KEYS.md.
| Key or secret | What it unlocks | Where it lives | Who holds it | Never |
|---|---|---|---|---|
| Platform connector password, development | Adding readings at cle in acme-platform-dev, and nothing else | Company password manager | pat@acme.com, sam@acme.com | Never in Claude Code, a chat, the repository or a file |
| Platform connector password, production | Adding real readings at cle, and nothing else | Password manager, and IT's credential store on the DMZ host | pat@acme.com, sam@acme.com, IT | Never on a laptop, never shared by email |
| Supabase publishable key | What the access rules allow a signed-in account to do | Typed into the connector when it starts; public by design | Anyone | Never relied on for protection |
| Supabase secret (service role) key | Everything, ignoring access rules | Vercel, server only | Nobody copies it | Never on the connector or the DMZ host |
Knowledge check
Why does the connector sign in as its own account instead of using the Supabase secret key?
Knowledge check
The connector's insert is refused with "new row violates row-level security policy", though it has the insert right. What is the likely cause?
References
- Supabase Docs: Understanding API keys. https://supabase.com/docs/guides/api/api-keys
- Supabase Docs: Row Level Security. https://supabase.com/docs/guides/database/postgres/row-level-security
- PostgreSQL Documentation: Row Security Policies. https://www.postgresql.org/docs/current/ddl-rowsecurity.html
- Supabase Docs: Testing your database (pgTAP). https://supabase.com/docs/guides/database/testing
Chapter 3 · Session 20
A simulated connector, then the real one with IT and OT
Claude Code writes the connector and runs it against the development project with made-up press readings, so you can see rows arrive, pull the network cable, and watch nothing get lost, all before anyone touches the plant. Then it writes the run sheet IT and OT follow to install the real one, and you witness the first real readings arrive in production.
40 min4 stepsEnds with a gate
By the end of this chapter you can
- Have Claude Code write the connector: alias table, store and forward, no default addresses, made-up data only to the development project.
- Prove the three things IT will ask: an outage loses nothing, nothing can reach back in, and the account can read nothing.
- Hand IT and OT a run sheet they can follow without you, and witness the first real readings in production.
What the connector does, and what it must never do
| It does | It never does |
|---|---|
| Receive press values (simulated, or Sparkplug B from the DMZ broker) | Open a port that anything can connect to |
| Map each legacy tag to its standard name through the alias table, refusing tags not in it | Invent a name for a tag it does not know |
| Keep readings on disk while Supabase cannot be reached, and send them in order when it can | Drop readings, or send them twice (the reading key makes a replay a harmless duplicate) |
| Sign in as connector.cle@acme.com and insert readings | Use the secret key, or read anything back |
| Send made-up readings only to acme-platform-dev, real ones only to acme-platform-prod | Have a default address: every address comes from configuration |
A simulated connector against the development project
25 minutesWhy
A simulation proves everything from the alias table to the database, on your laptop, with made-up data, before IT has to install anything. Every fault you find here costs a prompt; the same fault found on install day costs a second visit from IT and OT. Keeping made-up readings out of production is built into the program, not left to memory.
Do this
Read docs/connectivity.md, docs/tag-aliases.csv (or the alias table it names), docs/naming-standard.md and the machine_readings migration first.
On a new branch connectivity/connector, write the connector in connector/ as a small Node.js program with its tests (npm test):
1. Two sources: "sim", which makes up readings for the six presses using the legacy tag names in the alias table (peak tonnage per stroke around each press's normal value, stroke count, running state), and "mqtt", which subscribes to the DMZ broker over TLS on 8883 and decodes Sparkplug B, handling birth certificates (metric names and aliases) and death certificates (record the device's connection state as offline). Use established libraries for MQTT and Sparkplug B.
2. Map every tag through the alias table, applying the recorded unit conversion. A tag not in the table is refused and counted, never sent.
3. Sign in to Supabase as the connector account with the publishable key and the password, and insert into machine_readings without asking for rows back. Never use the secret key.
4. Store and forward: write every reading to a local queue on disk first; send in order; when Supabase cannot be reached, keep the readings and retry with back-off; treat a duplicate reading_key as already delivered. Keep the queue folder out of git.
5. Addresses: no default address anywhere. The target comes from --target. connector/targets.json allows https://tsrqponmlkjihgfedcba.supabase.co for source sim only and https://abcdefghijklmnopqrst.supabase.co for source mqtt only; refuse anything else. When a target cannot be reached, say "could not reach", not "failed". If HTTPS_PROXY is set, use it (Node needs NODE_USE_ENV_PROXY=1 for its built-in fetch); say so in connector/README.md.
6. Secrets: never read them from a file or the repository. If CONNECTOR_PASSWORD and SUPABASE_PUBLISHABLE_KEY are not set, ask for them in the terminal with the typing hidden. Never print them. Check their shape and say which is missing or malformed, by name.
7. Mark simulated readings synthetic = true and give their reading keys the prefix SYN_.
8. Opens no listening port. Add a test that fails if anything in connector/ listens.
9. Add an npm script "connector" and a script "connector:probe" that signs in as the connector and tries to select from every table, update and delete a reading, and insert for another site, and prints each result (all must be refused).
Tests must cover: unknown tag refused; unit conversion; replay after an outage keeps order and creates no duplicates; sim refuses the production address; mqtt refuses the development address; no default address; nothing listens. Show me one test failing with its rule removed. Push, open a pull request titled "Plant connector", wait for the checks, and tell me the result.When it is green and merged, run it yourself, in a terminal, not inside Claude Code. It asks for the development project's publishable key (Supabase, Project Settings, API Keys) and the connector password from the password manager; nothing shows as you paste.
cd ~/code/acme-platform && git switch main && git pull && npm install && npm run connector -- --source sim --target https://tsrqponmlkjihgfedcba.supabase.co --minutes 10https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/editor
Open machine_readings in the development project's Table Editor while it runs.
You will see recreated screen
- The plan, ticked off. Each line is a rule from the prompt and has a test.
You will see recreated screen
- Paste each value from the password manager or the dashboard. Nothing appears; that is intended.
- A tag the alias table does not know is refused and counted, never sent under a made-up name. The simulation includes one on purpose.
You will see recreated screen
| measure | value | read_at | source_tag | synthetic |
|---|---|---|---|---|
| acme/cle/stamping/press-3/peak_tonnage_kn | 2847.6 | 09:41:09 | [default]Press3/PLC/PeakTonnage | true |
| acme/cle/stamping/press-3/stroke_count | 18342 | 09:41:09 | [default]Press3/PLC/StrokeCount | true |
| acme/cle/stamping/press-1/running_state | 1 | 09:41:08 | [default]Press1/PLC/Running | true |
- Standard names in, legacy names kept next to them, synthetic marked.
- The connector itself cannot read this table. You can, because the dashboard uses the owner's rights.
Check it worked
After ten minutes the terminal says how many readings it sent, with the queue at 0, and the same number of synthetic rows for that period is in the development project's machine_readings. The refused tag is counted, not sent.
Fastest path
Leave the simulation running while you do Step 6: it is the outage test.
If it goes wrong
could not reach https://...supabase.co, or a 403 that looks like a wrong key, on the company network
Find out who refused it before changing any key. In Claude Code: The connector got a 403. Before changing any key: show me the full response body without any secret, tell me whether it came from Supabase, a proxy or a rate limit, and check whether HTTPS_PROXY is set. If it is, rerun with NODE_USE_ENV_PROXY=1. We hit exactly this behind a company proxy: Node's built-in fetch ignored the proxy until told to use it. The proxy setting goes into docs/connectivity.md and Session 21's package.
Invalid login credentials
The password was copied with a space, or the account is in the other project. Copy it again from the password manager entry for acme-platform-dev. The connector checks the shape of what you paste and names what is wrong, never printing it.
new row violates row-level security policy
The insert asked for the row back. Say: The connector's insert must not return the row: remove .select() after insert, and add a test. Do not give the connector a read right to make it go away.
The connector refuses the address
Correct, if you pointed the simulation at acme-platform-prod: made-up readings never enter production. Use the development address.
Rows arrive, but the dashboard's time is an hour out
read_at is stored with its time zone and shown in yours. Check the press's own clock with OT before changing anything: a gateway with the wrong time zone is common and is an open item for OT, not a code change.
Prove what IT will ask: nothing lost, nothing reaches in, nothing read
15 minutesWhy
IT's three questions about any connector are: what happens when the link drops, can anything outside use it to reach the plant, and what can a stolen password do. Answering each with a test you ran, with the output pasted into the design, ends the discussion. Saying "it is designed to" starts one.
Do this
1. Nothing lost. While the simulation from Step 5 runs, turn off your computer's Wi-Fi (or unplug the network) for about two minutes, then turn it back on. Watch the queue fill and empty.
2. Nothing reaches in. In a second terminal, while it runs, list what is listening on your computer for the connector's process:
lsof -nP -iTCP -sTCP:LISTEN | grep -i node || echo "no node process is listening"Get-NetTCPConnection -State Listen | Where-Object { (Get-Process -Id $_.OwningProcess).ProcessName -eq 'node' }3. Nothing read. Run the probe, which signs in as the connector and tries everything it must not do:
npm run connector:probe -- --target https://tsrqponmlkjihgfedcba.supabase.coThen record the evidence:
Add a section "Evidence" to docs/connectivity.md on a new branch connectivity/evidence, with today's date: the outage test (how long the link was down, readings queued, readings delivered, duplicates), the listening-port check (nothing listening), and the probe results, as I paste them below. Do not change anything else.
<paste the last lines of the connector's output, the port check and the probe output>You will see recreated screen
- "Could not reach", not "failed": the network is down, not the connector.
- Every queued reading delivered, in order, none twice.
- A stolen connector password reads nothing and changes nothing.
Check it worked
The number of synthetic rows in the development project for the run equals the number the connector generated (count them in the SQL editor if in doubt); the port check shows nothing listening; the probe says every attempt was refused; the evidence is in docs/connectivity.md on main.
If it goes wrong
After the outage there are fewer rows than readings generated
Readings were lost, which is the one thing the connector must not do. In Claude Code: The outage test lost readings: generated N, in the database M. Find where they were dropped, add a test that reproduces it, fix it, and show me the test failing before the fix.
After the outage there are more rows than readings
Duplicates got in, so the reading key is not unique per site. Say: Duplicates were stored after replay. Check the unique constraint on (site_id, reading_key) and the connector's handling of a duplicate, with a test.
The probe reads rows
Stop: the account has a read right it must not have. Say: The connector probe could read Another program (a development server) may be running. Stop the others and check again. If it is the connector, say: The connector is listening on a port. Remove whatever listens and make the no-listening test fail when it does. The real connector is the same program with Why An install day where someone has to phone you for a setting is an install day that slips. A run sheet in each person's own terms, with every name, port and host written out and a test at the end of each part, lets OT and IT work in parallel, on their own schedule, and tells you when each part is done. Do this You will see recreated screen You will see recreated screen Check it worked The run sheet is on main with three parts and a test at the end of each. OT and IT each have the link, and each has given you a date. Fastest path Send OT and IT the link to the section, not the whole file, and ask each for a date. The parts are independent: OT can publish to the broker before IT has installed the connector. If it goes wrong Supabase and Vercel addresses can change. Ask for host-name rules (abcdefghijklmnopqrst.supabase.co), which most current firewalls support. If theirs cannot, record it as an open item for Session 21: an IP rule that silently goes stale is worse than a known gap. Only the tags in the alias table. Each extra tag is data leaving the plant that nobody classified; adding one later is a one-line change to the alias table and a pull request. Why The production account is created only now, by a person, so no simulation could ever have written to production. Watching the first real readings arrive with OT and IT in the room, and pulling the plug once on purpose, turns the design into evidence the IT package can point to. Do this When OT and IT have each finished their part of the run sheet: create the production account exactly as in Step 4, in the production project, with a new password in a new password manager entry Platform connector, acme-platform-prod, and share that entry with the IT person who installs the connector. https://supabase.com/dashboard/project/abcdefghijklmnopqrst/auth/users Add user, Create new user: connector.cle@acme.com, the new password, Auto Confirm User. https://supabase.com/dashboard/project/abcdefghijklmnopqrst/sql/new Run the membership SQL from docs/connectivity.md, in the production project. IT starts the connector service with You will see recreated screen Check it worked Every measure in the alias table has readings in production from the last 15 minutes, none synthetic; the one-minute stop shows as an offline then online connection_state; the connector's log on the DMZ host says queue 0. Write the date and the witnesses' roles in docs/connectivity.md's Evidence section with a pull request. If it goes wrong The firewall or the proxy. IT compares the connector's outside-address list with the firewall rules and the proxy setting in the run sheet. Do not change the connector to try a different address: there is no other address. Production is behind main: the migration was merged but never applied. Check the deploy workflow's last run on GitHub (Session 11 applies migrations on merge) and the daily production-freshness check. We once found our live database nine migrations behind main. Compare the broker's birth certificates with the alias table. A device with no birth certificate is not publishing (OT); a refused-tag count in the connector's log is a tag missing from the alias table (you, with a pull request). Knowledge check The link to Supabase is down for two hours. With store and forward, what does the platform lose? Knowledge check The connector cannot reach Supabase from behind the company firewall. What should it report? Chapter 4 · 12 questions · 80% passes Twelve questions across the element. Score 80% (10 of 12) to pass. Your LMS records your score and each answer; you can review the chapters and try again. 15 min12 questions≈ 15 minutesRetake allowed Your result CivOps AI Academy Element F05B complete · Learner Your LMS records this completion. For the CivOps Foundation certificate, finish the Foundation Course at https://civops.io/learn.. Find which policy allows it, fix the matrix, regenerate, and add the refusal test that would have caught it. Do not install anything in the plant until this is fixed.
The port check shows a node process listening
The real connection
--source mqtt, installed by IT on the DMZ host, reading what OT publishes from Ignition. Claude Code cannot do any of that from your laptop, and should not try: it writes the run sheet, and the people who own each system follow it.Write the run sheet IT and OT follow without you
15 minutes, then their timeRead docs/connectivity.md, docs/tag-aliases.csv, connector/README.md and connector/targets.json.
On a new branch connectivity/run-sheet, add a section "Run sheet" to docs/connectivity.md with three parts, each ending in a test the person can do themselves:
For OT (Ignition): the Sparkplug B group id acme-cle, edge node id and device ids for the six presses; the exact Ignition tags to publish (from the alias table) and nothing else; the MQTT Transmission server settings: the DMZ broker's address on port 8883 with TLS and its certificate; that the gateway connects out and nothing connects in. Test: the broker shows a birth certificate for each press.
For IT: the DMZ host (operating system, Node.js version, disk for the queue); installing the connector from the tagged release as a service that restarts on failure, running as its own non-admin user; where the connector password and publishable key are stored (their credential store, never a file in the repository or on a laptop); the proxy setting if outbound HTTPS goes through one; the firewall rows from section 6 with host names, not IP addresses; logs and patching. Test: the service is running, nothing listens, and the connector's log says "signed in" and "queue 0".
For us: create the production connector account (same steps as development, in acme-platform-prod); share its password with IT through the password manager; watch the first readings arrive.
Also list every outside address the connector can call and where it is configured, so IT can check the list against the firewall. Open a pull request titled "Connectivity run sheet".Name URL TLS Status dmz-broker ssl://dmz-broker:8883 On Connected IT asks for the platform's IP addresses for the firewall
OT wants to publish every tag on the gateway "while we are at it"
First real readings in production, witnessed
30 minutes on the day--source mqtt --target https://abcdefghijklmnopqrst.supabase.co. With everyone watching, check the readings and then ask OT to stop the MQTT Transmission for one minute and start it again:-- Real readings in the last 15 minutes, per press and measure. Must not be synthetic.
select measure, count(*) as readings, max(read_at) as latest, bool_or(synthetic) as any_synthetic
from public.machine_readings
where read_at > now() - interval '15 minutes'
group by measure order by measure;measure readings latest any_synthetic acme/cle/stamping/press-1/peak_tonnage_kn 214 10:31:58 false acme/cle/stamping/press-1/running_state 3 10:31:02 false acme/cle/stamping/press-3/connection_state 2 10:28:40 false Nothing arrives, and the connector's log says could not reach
The connector signs in but every insert fails with relation "machine_readings" does not exist
Readings arrive for some presses only
References
Final assessment
Enterprise Connectivity: Ignition, OPC UA, Sparkplug B and the DMZ Connector