Cut unnecessary comment content across the engine and observers - #293
Merged
Conversation
Applies the comment rules: cut history, self-justification, restatements of what the code does, and prose duplicating a CHANGELOG entry. Spec citations stay, compressed to the citation and the obligation. langfuse/observer.py drops 227 comment lines, 31.4% to 25.2%. otel starts here and continues in the next commit. The ratio target of 10-15% is not reachable by cutting alone on files this size, which is the finding the ratio is meant to surface. Tracked separately as the file split. AGENTS.md gains the docstring convention this sweep works alongside: docstrings are published through mkdocstrings, so spec refs and normative language belong in comments instead.
Each of these stated a real constraint and then justified the change that introduced it. The constraint stays, in present tense; the story of how it got there goes to git. Removed: what an earlier version did, what a defect used to be, which coord thread settled a question, and meta-commentary about a previous version of the comment itself. Spec citations and the obligations they carry are untouched, and so is the reasoning that describes what the code currently has to satisfy.
Bulleted walkthroughs of matching semantics, restatements of what the surrounding code does, and reasoning phrased as the story of a fix. Each is rewritten to state the constraint the code satisfies now. The one worth keeping in some form is the branch-axis slice: nothing reaches it today only because branch descent runs with checkpointer set to None, which is a policy in another module. That dependency is a fact about the code as it stands, so it stays.
Same content test applied to events.py, openai.py, fan_out.py and graph/observer.py: keep what describes the code as it stands, drop what records how it got there. The recurring shape in these four was a real invariant followed by the story of the bug that revealed it. The fan-out tracking key is the clearest: the key must carry both concurrency axes or two live executions collide, which stays, while the account of the branch axis having been absent goes. Field docs on the event dataclasses lost their proposal-by-proposal change logs and kept the contract: when the event fires, what is mutually exclusive with what, and that payload fields are populated unconditionally with the privacy gates applied at rendering.
There was a problem hiding this comment.
🟡 Changes recommended
A newly updated comment in otel/observer.py references a non-existent _publish_active_span symbol and should be corrected to avoid misleading future maintainers.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR reduces long-form historical/provenance commentary across core engine and observability modules, keeping only comments that describe current invariants and spec-mandated constraints. It also documents the repo convention for what belongs in docstrings vs # comments in AGENTS.md.
Changes:
- Trimmed/condensed comments across engine + observer modules without changing executable logic.
- Added guidance in
AGENTS.mdclarifying docstrings (published API docs) vs maintainer-facing#comments.
File summaries
| File | Description |
|---|---|
| src/openarmature/observability/otel/observer.py | Comment reductions/condensation around OTel observer span/lineage handling. |
| src/openarmature/observability/metadata.py | Comment trimming around reserved metadata key enforcement. |
| src/openarmature/observability/lineage.py | Comment condensation describing lineage-aware dispatch key canonicalization. |
| src/openarmature/observability/langfuse/observer.py | Comment reductions/condensation around Langfuse mapping and lineage behavior. |
| src/openarmature/llm/providers/openai.py | Comment condensation around managed wire fields, typed events, and canonicalization. |
| src/openarmature/graph/observer.py | Comment trimming around invocation context and checkpointing invariants. |
| src/openarmature/graph/fan_out.py | Comment condensation around fan-out progress keying and resume validation behavior. |
| src/openarmature/graph/events.py | Comment condensation clarifying event field contracts and spec references. |
| src/openarmature/graph/compiled.py | Comment reductions around fan-out progress projection/restore and invoke stepping. |
| AGENTS.md | Added “Docstrings vs # comments” guidance for contributors/agents. |
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The comment pointed at `_publish_active_span`, which exists nowhere in the repo. The lookup it describes is in `prepare_sync`, whose `open_span is None` branch is the callable-parallel-branch path that depends on the key missing. The stale name predates this branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes 556 comment lines across 9 files. No executable code changes.
Verifying that first, since it is the only thing that matters here
Every changed file was compared token by token against
main, with comments and formatting-only tokens stripped:So this cannot change behaviour, independent of the suite. The suite is green anyway (2214 passing), along with ruff and pyright.
What was cut, and the test used
The rule is whether a comment describes the code as it stands. Not how it got there, not what it used to do, not the reasoning that produced it.
The dominant pattern, in every one of the nine files, was a real invariant followed by the story of the change that introduced it. The invariant stays, in present tense; the story goes to git. The fan-out tracking key is the clearest example: the key must carry both concurrency axes or two live executions collide and one rolls forward results it never computed. That stays. The account of the branch axis having been absent, and of why nothing surfaced it, does not.
Specifically removed:
Deliberately kept: every spec citation, and every explanation of a constraint the code currently has to satisfy. Several blocks are still 11-19 lines because they are dense with contract and nothing in them is unnecessary.
Ratios
src/overall moves 23.1% to 21.7%. The ratio barely shifts despite 556 lines going, because the files shrank too, which is the point: these files are long structurally, not merely over-annotated. Closing that gap is the file split, tracked separately and deliberately not attempted during release prep.Also here
AGENTS.mdgains a Docstrings vs#comments section. Docstrings are published through mkdocstrings intodocs/reference/, so they are shipped end-user documentation, which is why spec citations and normative language belong in comments instead. That convention governed this sweep and had never been written down.Not in scope