Showing posts with label CI. Show all posts
Showing posts with label CI. Show all posts

Sunday, September 27, 2026

The shell script passed. The cluster test could not deploy the intercept.

The shell script passed because a person was holding the CLI. The automated test had no CLI to hold. That is the bug in tekton-dag that was found while moving pull-request intercepts off the laptop and into the cluster.

It turned up inside a larger experiment. I am running eight or more projects at once, and Obsidian is the shared record between the Cursor sessions doing that work. Most of the time the record is there so a session can take the next bounded item, finish it, and leave the queue understandable. This one was the other use. A problem popped up on one project, and the same notes had to carry a deep fix without losing the rest.

A pull request builds the changed app and deploys it as a PR pod next to the live stack. Traffic that carries x-dev-session: pr-N must be served by that pod. Traffic that does not carry the header must stay on the baseline, untouched. The pipeline is supposed to install that split itself and then prove it. For a long time the install step was a Telepresence intercept, and the proof was a script that exited zero.

Two ways of running the same test

From a laptop, the path is a handful of commands. Install the traffic manager, run telepresence intercept, name the deployment, set the header, and point the intercepted traffic at a local process. The person running the script has an admin kubeconfig. The CLI is on their PATH. Those runs intercepted. That is what the session notes remembered as "E2E with Telepresence intercepts passing."

The refactor put the same job inside Tekton. A task pod in the cluster was supposed to deploy the intercept with nobody at a keyboard. The sidecar we gave it was ghcr.io/telepresenceio/tel2:2.20.0. That image is the traffic agent. It contains one binary, traffic. telepresence is not in it. telepresence helm install failed with not found, the container exited, and kubectl wait still succeeded because the pod was briefly Ready during a ten-second sleep.

You cannot deploy this intercept without the CLI commands. Connect, create the intercept, set the header filter, and aim it at the PR workload are all telepresence subcommands. The in-cluster image cannot run them. The automated test was not a stricter version of the shell script. It was a different program, missing the only tool that does the work.

The check on top of that was warn-only. It printed NOT CONFIRMED and exited 0. Automated runs on main stayed green through the middle of September. On 26 September the check was changed to fail when a hop was not confirmed. The next run on main went red. Telepresence had not changed. The test had stopped agreeing with a log line.

Why copying the CLI into the pod was not the fix

We did try to put a real Telepresence CLI in the cluster. A client pod with the CLI, its own service account, a tun device, and a privileged namespace still could not hold the intercept the way a laptop does.

  • A newer CLI could not create intercepts against the traffic manager already in the cluster. The client and the manager have to match closely.
  • Once a matching CLI did create an intercept, header-matched requests hung. The client image had no iptables, so the session that carries stolen traffic back to the handler never started.
  • A whole-port intercept, which does not need the header filter, stole baseline traffic too. That breaks the contract.
  • Injecting the traffic agent restarts the live deployment. The laptop workflow does not do that to the running stack in the same way, because the intercepted process is on the laptop.

The net finding is to take Telepresence out of the in-cluster tests. It remains a fine laptop tool: install it on a workstation, run the CLI, debug against the cluster. It does not belong in a pipeline that has to deploy the intercept from a pod. Pull request 109 removes the in-cluster task, the traffic-manager install from the runner, and the Telepresence leg of the test matrix.

What the two paths actually were

Shell script, from a laptop. This one intercepted.
Laptop
telepresence CLI
admin kubeconfig
header filter set by a command
→ Traffic manager
in the cluster
takes the CLI's intercept
→ Split
header → local process
no header → baseline
Automated job, inside the cluster. This one could not deploy.
Tekton task pod
image tel2:2.20.0
binary: traffic
no telepresence CLI
→ No command to run
cannot connect
cannot create the intercept
cannot set the header
→ Nothing served
PR pod was a sleep loop
check printed NOT CONFIRMED
exit code 0

Why the manual run did not become the CI run

The manual test and the CI job shared a name. They did not share a procedure. A person at a laptop was doing five things the pipeline never did, and each one was load-bearing. Drop any of them and the intercept is a different test.

What the person supplied What the CI job had instead
The telepresence CLI on a laptop PATH, and the commands that create the intercept. A pod image whose only binary is traffic. The commands the script ran were not in the container.
An admin kubeconfig. The CLI could install, connect, and edit the live workload. A namespace service account. The same binary, run as that account, is forbidden from the calls the laptop made.
A real process on the laptop, which answered the stolen request. A PR pod whose command was while true; do echo "PR build"; sleep 30; done. It could not answer HTTP.
Eyes on the full terminal. A failed connect was the next line of output. An artifact collector that ran kubectl logs without asking for the whole log. The default is ten lines per container, so the error a person would have read was cut off.
A pass the person could see: the request landed on their process, and a request without the header did not. A pass the script could exit: print NOT CONFIRMED, then exit 0. Green meant the task ended, not that the pod served the request.

That is why months of green CI did not contradict a passing shell script, and did not confirm one either. The script was evidence about a laptop session. CI was evidence that a different program returned zero. Wiring the script into GitHub Actions would not have closed the gap, because the script's success still depended on the person: their binary, their credentials, and their reading of the log.

The same split showed up again after the pipeline moved to mirrord, which can run its CLI in a pod. A hand test in the cluster routed correctly. The pipeline run of that same idea did not. Two details that a person fills in without noticing:

  • The account. The hand test used an admin user. The proxy pod used the namespace default service account, which is not allowed to create the agent or to open the port-forward the agent connection needs. The deploy step only waited for Ready. A container with no readiness probe is Ready the instant it starts, including one that exits a second later on Forbidden. The hand test never hit that account, so it never hit that failure.
  • The header string. mirrord matches the header as name: value, colon then a space. The hand test used that form. The task passed x-dev-session:pr-N with no space. The filter could not match, every request stayed on the baseline, and a check that only looked for the header echoed back in the response still printed pass. Both pods echo the header. Echo is not identity.
A manual pass proves the tool in the hands of the person who ran it. It does not prove the job. CI has to run the same command, as the same kind of account, against a process that can answer, and fail when the PR pod's own log does not show the matched request and only the matched request.

How MetalBear fixed the in-cluster path

MetalBear ships mirrord as a CLI whose job is to run a process in the context of the cluster. The CLI does not have to live on a laptop. The tool image for the pipeline contains it. The task starts a proxy pod, and that pod runs mirrord exec.

mirrord creates an agent pod beside the live deployment. The agent is what steals traffic. Steal mode with an HTTP header filter takes only the requests whose header matches x-dev-session: pr-N and hands them to the process mirrord is wrapping. In the pipeline that process is a small relay to the PR pod, which is running the built image as the real app. Requests that do not match stay on the baseline pods. The live deployment is not restarted to install a sidecar, and the client pod does not need a tun device or iptables.

In-cluster intercept with mirrord. The CLI runs in the pod. The agent does the split.
1. Tekton task starts a proxy pod as its own service account, not as the namespace default. The pod's image includes the mirrord CLI.
2. mirrord exec in that pod creates the agent next to the target deployment and connects to it through the Kubernetes API. The filter is (?i)^x-dev-session: pr-N$. mirrord matches the header as name: value, colon then space. A filter written without the space never matches.
3. Agent, steal + header filter. Matching request → relay → PR pod (the built app). Any other request → baseline pods, unchanged.
4. Proof, from the PR pod's access log. A marked URL with the header must show up there. The same mark without the header must not. Remove the intercept and the first check goes red. Steal every request and the second check goes red.
                incoming request
                       │
                       ▼
              mirrord agent (in cluster)
              header filter on the Service
                    │            │
         x-dev-session          no match
           : pr-N                  │
              │                    ▼
              ▼              baseline pods
         proxy pod            (live stack)
         mirrord CLI
              │
              ▼  relay
           PR pod
     (built image, real app)
              │
              ▼
     access log must contain
     the matched probe only

The first honest pass of that proof is what the shell scripts never had to show. A response that echoes pr-N is not evidence: the baseline echoes the same header. Pod Ready is not evidence either: a container with no readiness probe is Ready the instant it starts, including a process that crashed a second later. The access log is the pod admitting it saw the request. The unmatched probe is the control that says it did not see the other one.

mirrord is in the test matrix because the pipeline can deploy it. The CLI is in the image, the agent is a pod the task is allowed to create, and the filter lives in config the task writes. Telepresence's in-cluster image could not issue the commands the shell script depended on.

Lessons

None of these showed up as a failing assertion the first time. Each one showed up as a story that was already believed.

  • A manual pass is about the person who ran it. Their binary, their credentials, the string they typed, and the log they read. The job has to be given those same ingredients or it is a different test.
  • A green pipeline is only as honest as its weakest check. Exit 0 on NOT CONFIRMED is not a result. Pod Ready is not a result. A response that echoes the header is not a result, because the baseline echoes it too. The check needs a negative control that fails when the feature is absent.
  • Keep the log you will debug from. kubectl logs on a selector keeps ten lines per container unless you ask for the rest. The line that explained the failure was in the part that was thrown away.
  • Do not match the word ERROR and call it a failure. A healthy tool prints ERROR for noise. The gate has to name the fatal message. A gate that matches the noise stops the run that was about to show you the real bug.
  • Find the bug on a cluster you can still see. Four failures in a row were each debugged from a log zip after CI had deleted the cluster. Every one of them was a two-minute question with kubectl on a live local cluster. CI is the clean confirmation after that, not the place the diagnosis happens.
  • Write down the path you closed, and why. "E2E passed" was already in the notes from the spring. Without a newer note that says that sentence was wrong, the next session will treat it as the fact and spend another afternoon on it.

The notes were how the next session knew where to start

The experiment has two speeds, and I wanted to know whether one record could serve both.

The fast speed is a batch. Across the other projects the work is a list of bounded items: one check, one hole, one small change, then stop. A session should be able to open a project, read what is left, do that item, and write down where it stopped. Nobody re-briefs it. The vault is the queue. That is the automation. Not a scheduler inside the notes, and not the notes launching the next session. Cursor does the work. Obsidian is what lets the next session start from the item instead of from a blank chat, so eight projects can move without eight briefings.

The slow speed is a problem that will not fit in an item. This intercept was that. It did not fit in one chat. Through the day the story changed: both backends were green, then I rejected a whole-port intercept, then both greens were false, then the in-cluster Telepresence path was closed, then mirrord's own green was a race. A later Cursor session does not remember that. It remembers the last thing someone typed, or an older note that says the test passed. If the notes only knew how to hand out the next batch item, this fix would have been a fresh investigation every time I came back to it, and the other projects would have stalled while I held the context in my head.

The record that survived is in Obsidian, written and read through obsidian-mcp. Three notes, and they do different jobs:

  • Project state says what done means right now. Merge only when a request with the session header shows up in the PR pod's log, and a request without it does not. A green that cannot show that is not done.
  • A working note is the timeline of what we believed against what the artifacts showed. February's "E2E passing" sits in the same table as the sleep loop and the exit code. When the next session starts, it reads the correction before it reads the claim.
  • A decision freezes the choice and the alternatives that were rejected. mirrord is the in-cluster backend. Telepresence stays on the laptop. Do not bring the in-cluster path back without the same routing proof. Debug on the local cluster; let CI confirm.

Cursor calls that vault before the work, not after a wrong turn. get_project_context returns the state, the latest session, and the decisions. search_memory finds the decision by the question you actually have, instead of by which chat happens to be open. When a choice should outlive the session, record_decision writes it as its own note. When the session stops, capture_work_session appends what changed and what the next person should not redo.

That is what kept the solution moving. The next session did not "fix" the red build by letting NOT CONFIRMED exit 0 again, because the state file said the earlier green was empty. It did not spend another round of CI on an in-cluster Telepresence sidecar, because the decision already recorded why that path was closed. It took the next red run to the local cluster, because the decision said a log zip is the wrong tool for a question kubectl can answer while the pod still exists.

The notes were also wrong on the same night, and that is part of the lesson. An early write said mirrord had met the contract. An audit a little later showed its green was the same kind of lie: the proxy died on a forbidden call, Ready flickered, and the response echoed a header the baseline would have echoed anyway. The working note was corrected in place. A vault that cannot be corrected just launders the last confident sentence, which is how "E2E passing" survived from the spring until the check was made fail-closed.

The same notes do both jobs. They hand the next bounded item to a session that is working through a batch, and they hold a deep fix when a problem pops up, including the paths already closed. The notes did not find this bug. The artifacts did. What the experiment showed is that I did not have to drop the other projects to stay inside this one.

Obsidian is the scratch pad. The repo ledger is the lesson.

Something about the relationship to SDLC-SPDD is coming into focus, and I do not want to pretend it was designed this way on day one.

SDLC-SPDD still guides. It says which phase the work is in, what done means, and what is allowed to become a permanent record. It does not have to hold the intermediate work. That gets pushed to Obsidian: the scratch pad a session writes while the work is still messy. Project state, the timeline of what we believed, the decision, the correction an hour later, the CI run that is still red, the guess that turned out to be wrong. That accumulation is the point. A deep fix needs the noise, because the noise is where the last wrong sentence is written down and then crossed out. A batch needs it too, because "where this item stopped" is not a lesson yet. It is a handoff.

That pile should not become the memory of the repository. A later change in tekton-dag does not need the night's chronology, the ten-line log truncation, or the hour where both backends looked green. It needs the sentence that survived the night. A manual pass does not prove the job. A green check needs a negative control. Do not throw away the log you will debug from. Do not fail a healthy tool for printing ERROR. Find the bug on a cluster you can still see, and let CI confirm. Write down the path you closed.

Those sentences are what come back. The guide stays in charge of the return trip. A capture during the work is staged and stays out of git. At the end of the work, an accept step promotes what is worth keeping into the committed lessons ledger. Nothing else is supposed to land there, and the ledger is not edited by hand to make a story fit. The scratch pad can be wrong at 9pm and corrected at 11. The ledger should only receive the correction that still matters after the noise has been thrown away. Intermediate work lives in Obsidian. SDLC-SPDD keeps guiding, and it keeps the lesson.

SDLC-SPDD guides. Intermediate work goes to Obsidian. Only a distilled lesson comes back.
1. SDLC-SPDD guides
Which phase this is. What done means. What is allowed to become a permanent record. The intermediate notes do not go here.
↓ intermediate work pushed out, noise included
2. Obsidian — the scratch pad
Project state, the believed-versus-true timeline, the decision, the handoff ("stopped here"). This pile stays here. It is not the memory of the repository.
Stays in the vault
chronology
false starts
CI run still red
a sentence corrected at 11pm
→ 3. Distill
one lesson that is still true after the noise is thrown away
a manual pass does not prove the job
↓ staged, not committed yet
4. Accept
Review the staged lesson. Promote it, or leave it. The scratch pad is not copied across.
↓ committed
5. SDLC-SPDD lessons ledger
The sentence the next change can retrieve. Not the night. Not edited by hand to make a story fit.
The guide stays. The scratch pad holds the middle. The ledger receives the lesson. Intermediate work is pushed to Obsidian so the repository does not fill up with the night. What comes back is small enough that the next change can retrieve it without replaying that night.

What I will trust a green run to mean

A green intercept job has to print that the PR pod served the matched request and did not serve the unmatched one. Local kind produced that line. The intercept job on pull request 109 then produced it on a clean cluster, and that pull request is merged. A laptop script from last spring is not what made it done.

If you are wiring the same kind of test: run the command your script runs from inside the job that is supposed to replace the script. If that command is not in the image, you are not automating the test. You are automating the exit code.

The change is tekton-dag pull request 109. mirrord's own model is documented at mirrord.dev.

Five additions that improve maintainability and code quality

The goal was to improve maintainability and code quality across the repositories I ship. The two are not the same thing, and both matter. Maintainability is the cost of the next change: how long it takes an engineer to open the code, make a change, and move on. Code quality is whether that change did what they meant and nothing else moved. Low quality makes every change a risk. Low maintainability makes every change slow. In September 2026 I made five additions to every repository to improve both. This post is about what was added, what each addition does, and how the work is using them.

Updated 11 October 2026. The first version of this post, earlier the same day, counted nine repositories with all five checks on the default branch. That count is now 16 of 17.

Why a score for the whole repository fails

The common approach is one number for the whole code base. Every file is graded, and the build goes red when the total is over a line. It sounds like discipline. In practice the number is driven by old files nobody is changing. To move it, an engineer opens a file the product does not need touched, rewrites it, and writes tests for the rewrite. The suite grows. The number moves. Maintainability did not improve, because the next real change was never in that file. Quality did not improve either, because a rewrite of working code is a new place for a defect. The team is working for the number.

The additions below take a different route to both. Each one grades the change in front of it. Code the change did not touch is left alone. Problems that already exist stay written down, and nobody is allowed to delete the list to make the build pass.

The five additions

Each addition is one check in the build, and each check is one question. A manager can ask it of any change and get a yes or a no.

1. Did this change add a new problem on the lines it touched?
Only the lines this change wrote are graded. A small edit in an old, tangled file passes if the edit itself is clean. A new problem on a changed line fails.
Maintainability: the code stops getting worse where people are working. Every change that lands is at least as clean as what it replaced, so the next change in that file is no harder than this one.
Quality: the problems this check catches are the ones that hide defects: a branch nobody can follow, a function doing four jobs, a value used before it is checked. Refusing them on the changed line keeps them out of the product.

2. Is this file both tangled and the one people keep editing?
A file is called out only when both are true. Hard to change, and changed often. Difficulty alone is not a project. A tangled file nobody opens costs nothing until somebody opens it.
Maintainability: cleanup goes to the file that is slowing down every edit. That is where a planned cleanup buys back the most time, and the rest of the debt is left where it is.
Quality: a file that is both tangled and edited often is where defects come from. Every edit to it is a chance to break something nobody can see. Cleaning that file, and only that file, removes the most defect risk for the least work.

3. Did this change break one rule the repository is not allowed to break?
Each repository names one rule that matters more than any style score, and tests it in the build. A post stays a draft unless publishing is turned on. A log must not contain a password. A fork must not grow a path back to the project it came from.
Maintainability: the rule holds without anyone having to remember it. A new engineer, or a busy one, cannot break it by accident, and nobody has to re-learn it by cleaning up after a mistake.
Quality: these are the defects that matter most and are found latest. A post that went live, a password in a log, a change sent to the wrong project. The check turns each one from an incident into a red build.

4. Did someone edit the written list of old problems so the build would pass?
Existing problems are recorded. A new one fails the build. The list may shrink when a problem is actually fixed. It may not shrink because the build was red.
Maintainability: the debt stays visible and readable, so decisions about it are made on facts rather than on a number someone adjusted.
Quality: a green build means the change was clean. It does not mean the list was trimmed. Without this check the other four can be switched off quietly, and the quality signal from the build is gone.

5. Do the tests for one chosen piece of the product still catch a mistake they used to catch?
The build breaks that piece on purpose and expects the tests to notice. If they do not, the build fails. Each repository checks one piece, because doing this to everything on every change costs more than it returns. A check that tests nothing fails.
Maintainability: an engineer can change that piece and trust the tests to catch what they broke. A suite nobody trusts makes every change slower, because the engineer has to check by hand what the tests should have checked.
Quality: a large test suite is not a safe one. Tests that pass no matter what the code does give a green build and no protection. This check is the only one of the five that measures whether the tests can find a defect at all.

How the additions compound

None of these is dramatic on its own. Together, over months, they bring the cost of the next change down and the defect rate down with it.

On maintainability: the parts of the product that get the most attention are also the parts the checks run on most often, so they get steadily easier to change. Old debt does not leak into new work, because the first check refuses it at the line. The second turns cleanup from a reaction to a score into a decision about a named file with a known cost.

On quality: the fifth check keeps the suite honest, so a green build carries information. The fourth keeps the record honest, so the trend is real. The third holds the rules that a busy team would otherwise re-learn by breaking them in production. Together they mean that when the build says a change is fine, it is fine, and when it says stop, there is a defect or a risk behind it.

What a manager should expect to see: fewer surprises in review, because the build already refused the change that made things worse; cleanup work that can be explained in one sentence, because a check named the file; and a build that is red for a reason someone can act on today, rather than for a number the team has learned to route around.

What this does not do: it does not pay down the existing debt on a schedule, and it does not promise the number goes to zero. The debt is written down and left alone until a change touches it or a hotspot earns a cleanup. That is on purpose. The alternative is a team working for the number.

What it costs

No new platform, no new licence, no new role. Each check uses the grading tool the language already has, running inside the build the repository already runs. The first four add minutes to a build. The fifth is the expensive one, which is why it is limited to one piece of the product per repository and not the whole thing.

There is a one-time cost when the checks arrive. The record of existing problems has to be written down once, and someone has to read the first hotspot list and decide which file, if any, earns a cleanup. After that, the cost is paid by the engineer whose change turned the build red, on that change, the same day. It does not become a backlog.

The cost that goes away is the one nobody was tracking: the hours spent on cleanup the product did not ask for, the tests written to cover that cleanup, and the review time spent on both.

How to tell it is working

A manager does not need to read the code to see whether this is holding. The signals are in the build and the review queue.

  • The record of old problems only shrinks when a fix lands. If it drops without a corresponding change, someone edited it, and the fourth check should have failed. If it never drops, the hotspot list is not being acted on.
  • Hotspot cleanups can be named. Each one points at a file that was both tangled and edited often. If cleanup work cannot be tied to a named file from the list, it is the old behaviour coming back.
  • Red builds are fixed inside the change that caused them. Not as a follow-on ticket, not as a cleanup epic. If red builds are turning into tickets, the checks are grading the wrong thing.
  • Review comments move from style to behaviour. The build has already said no to the change that made the code worse. Reviewers can spend their attention on whether the change does what it claims.
  • Time from open to merge does not grow as the code base grows. That is the cost of the next change, measured directly. It is the number this whole thing exists to hold flat.

If the record shrinks honestly, cleanup has a name, red builds are fixed in place, and merge time holds, the checks are doing their job. If the team starts routing around a check, that is the signal to look at the check, not the team.

How the work is using them

The checks land the same way the work does. A repository gets the one check it is still missing. That change stays only when its build is green. A red build is fixed inside the change that caused it. The written list of old problems is not edited so a build will pass.

As of the evening of 11 October 2026, 16 of 17 repositories run all five checks on the default branch. The nine from the first version of this post are still in that set: the documentation generator, the lifecycle orchestrator, the notes server, the chatbot, the learning project, the cost tool, the graph service, the delivery pipeline, and the installer. Seven more finished the same day: the model-setup project, the commerce platform, both guide forks, the assistant, this blog, and the indicator. On all sixteen, every change is graded on the lines it touched. A file is called out only when it is both tangled and edited often. One rule is tested in the build. Old problems stay written down. One piece of the product is broken on purpose, and the tests have to notice.

The rules that were still being added this afternoon are now in the build. On the commerce platform, calls into the commerce engine go through one client. On both guide forks, nothing grows a path back to the project they were forked from. On the assistant, a skill file has to carry the fields the catalog requires. On the indicator, two files dropped in the same second resolve to the later one. On this blog, a post stays a draft unless publishing is turned on, and a log must not contain a credential.

The one repository still short is the memory project. Its one-rule check is waiting, because the file it would touch is both tangled and edited often. That wait is the hotspot check doing the job it was added to do. The camera project already runs the hotspot check, the written list, and the test check. The language project already runs changed-line grading and the hotspot check.

Two products are off this list on purpose. The guide work stays on the fork. Changes are not sent back to the project that fork came from.

Where the checks run

The same five checks, in the form each language already supports, on every repository below. Sixteen of the seventeen on this program run all five on every change. The memory project is the one still short a check. The camera project and the language project are on the list and outside that 17.