Green Is Not Tested
Two confirmed defects, a testing gap that hid one of them, and a lifecycle issue we found while fixing them. Each looks obvious in hindsight. All sat on paths the people who built the software never walked.
Two months ago, in Parseable Is Not Valid, we wrote that a green suite says nothing about an invariant you never wrote down. We meant it. Then, over a few days in November, an outside contributor showed us another version of the same lesson, one we had walked straight past.
Sentience Governor evaluates agent actions against declared governance context and records governance evidence without blocking execution. It is open source, and that turned out to matter more than any test we had. The contributor found two real defects. Reviewing those fixes, we found a gap in our testing that had helped hide one of them, and a lifecycle issue in the same code that we have not yet reproduced. Our suite was green throughout.
What connects them is not carelessness. We had a handler, we had tests for it, and the suite was green, so we believed the integration worked. Everything looked fine, and we never asked why we believed it. Our tests checked the paths we knew, with the dependencies we happened to have installed and the inputs we had in mind. Someone who didn’t share those assumptions ran it differently, and found where they stopped.
Defect one: the quickstart we never ran
The LangChain integration ships a callback handler, and our quickstart tells you to pass it straight into callbacks. Do exactly that, and LangChain’s callback manager raises AttributeError into your own invoke() before a single event is recorded. The handler worked everywhere except the one line we told people to write.
The mechanism is small. LangChain’s callback manager reads a set of attributes, such as raise_error, from every handler it is given, not only the callback methods. BaseCallbackHandler defines them. Our handler did not inherit from it, so the plain handler had none of them: the manager’s first read failed, and its error handling then looked for raise_error, which wasn’t there either.
Our tests never saw this because LangChain was never in them. Every test built the handler and called its methods directly, one callback at a time, the way we think about the handler: as the methods we wrote. None of them handed it to LangChain’s callback manager, which is the one thing every user does. A subclass that mixes our handler with BaseCallbackHandler, shown further down our own guide, would have worked, because it inherits every attribute the manager reads. We tested the way we use the product, not the way we tell others to use it.
From the inside, calling the methods was the usage. Nobody on the team had a reason to run the quickstart’s line through real LangChain, so nobody did. The contributor had never seen our tests. They read the quickstart and did what it said.
The fix makes the plain handler usable as documented and adds end-to-end tests that run a real LangChain runnable through it. It is merged into main.
What helped hide it: tests that skipped themselves
This is not a defect in the product. It is part of why the first defect survived, and why it could have survived again, and we only noticed it while reviewing the fix.
Until the fix, no test ran real LangChain at all. The fix added end-to-end tests that do, and like our other optional-dependency tests, they begin by skipping themselves if the library is missing. Our continuous integration installs the core package with its development and MCP extras. The LangChain library is only in the demo extra. So in CI, those new tests skip, every run. A skipped test does not fail. It adds to a count nobody was reading.
Where real LangChain did not run, our tests stood in for it, calling the handler’s methods directly. They never read the attributes the real callback manager reads, because they were not the real callback manager. They tested our understanding of LangChain, which was exactly the thing that was wrong.
The same habit is at work. We built against the dependency we had in our heads, on machines set up the way we set them up. Installing LangChain in CI is proposed and has not been done, so today those tests still skip there. When it is done, one of the new tests will deliberately fail whenever a LangChain release adds a callback our handler doesn’t define. That will turn CI red with no change on our side, and it is meant to.
Defect two: valid, but not what we expected
Sentience Governor writes its execution record as JSON lines, and several commands read those lines back. Every reader was careful about malformed input: a line that failed to parse was skipped. Our tests fed in lines that fail to parse and events with fields missing, and they passed. None fed in a line that parses to something other than an object.
The contributor fed in lines that do parse. [], null, 123 and a bare string are all valid JSON. Each parsed cleanly and was passed on as though it were an object, and the next line of code called .get() on it and raised. Two fixes, both merged into main, make the command-line tools skip any line that is not an object, the same way they skip a line that doesn’t parse.
The uncomfortable part: two of our readers already handled this correctly. The guard existed in our own code. Four other readers still catch only parse errors, and they are not fixed yet. One of them is on the path the Claude Code hook uses, which runs on every governed tool call. We have not yet established what happens there when such a line arrives, whether something above it catches the error or the hook fails, and we are not going to guess in print. Checking that comes before changing it.
Here, too, our tests asked the question we already knew how to answer. Somewhere along the way, “malformed” had quietly come to mean a line that doesn’t parse, or an object with something wrong inside it.
Found in review, not yet reproduced: the session that never closes
The last finding is different in kind, and we want to be precise about it. Nobody hit it. We found it by reading the LangChain handler while reviewing the quickstart fix.
The handler closes a governance session when the root run ends normally. When a run raises instead, LangChain calls a different callback, and ours does nothing there. Reading the code, a run that errors would leave its session open: never marked closed in the record, still open in the session manager, and still held in memory for as long as the handler lives.
That is what the code says. We have not yet reproduced it with a running script, so we are describing an expected behavior, not an observed one. It may turn out to be narrower than it reads.
Fixing it is also not only a code change. Should an errored session close the same way a completed one does, or should the record say the run failed? That is a question about what governance evidence means, and we have opened it for discussion before writing a fix.
Every session test we had used a run that finished. We had tested failure where it was loud. We had not tested a run that simply stops.
Where things stand
The article is being published before the next software release, so here is the state of each item as of today.
Merged into main:
- The plain LangChain handler works as the quickstart documents, with end-to-end tests against a real LangChain runnable.
- The command-line trace readers skip lines that are valid JSON but not objects.
Awaiting a release: both merged fixes. The current published release, 0.3.2.1, does not include them. Until the next release ships, installing from PyPI gives you the behavior described above.
Open or under investigation:
- Four more trace readers need the same guard. What happens on the hook path today has not been established.
- Errored LangChain runs appear to leave sessions open. Not reproduced, and the expected behavior is under discussion.
- CI does not install LangChain, so the real-LangChain tests still skip there.
Proposed, not implemented:
- Run the documentation’s examples as tests, against real dependencies.
- Treat the number of skipped tests as part of the release check, read as carefully as failures.
- Give every integration at least one test for a run that errors and one for input of an unexpected type.
When everything looks fine
None of this needed new knowledge. The quickstart was in our own docs, the guard was in our own code, the skip was in our own CI configuration, and the missing callback sat next to the one we did implement. We thought we had done the diligence. We had a LangChain handler, we had tests for it, and the suite was green. We had not gone through the one thing a user does first, and nothing told us to look, because nothing looked wrong.
That is the variation on “Parseable Is Not Valid” we walked past. There, a validator certified the shape of a file, not what the runtime would do with it. Here, our tests certified the handler we had in mind, not the one a user would run. Both times the check was real, and both times it answered a narrower question than the one we thought we had asked.
So the lesson is not really about tests. It is a question, and it applies to anyone who has set up agents and believes they are working: when everything looks fine, ask why you believe it. What did you actually check, and what did you assume? Which path does a real user take that you never have? A green suite, a quiet log and a dashboard with no alerts are all statements about what someone thought to check.
We asked ourselves that question only because someone outside the team ran our quickstart and it failed. They copied one line:
config={"callbacks": [handler]}
We wrote that line. We never ran it. Everything looked fine.