Skip to content

docs: add a datasheet-aware code-review agent skill - #73

Draft
felipebalbi wants to merge 3 commits into
OpenDevicePartnership:mainfrom
felipebalbi:code-review-skill
Draft

felipebalbi wants to merge 3 commits into
OpenDevicePartnership:mainfrom
felipebalbi:code-review-skill

Conversation

@felipebalbi

Copy link
Copy Markdown
Collaborator

GitHub Copilot code review reads agent skills from .github/skills on the
head branch, and is more likely to use a skill whose directory name is
review-focused — code-review is the name it looks for. Without one it
reviews this crate as generic Rust.

The gap this closes

Copilot has already reviewed #48, #69 and #71 with no skill present. Its
comments were sound — debug_assert! versus assert!, as i16
truncation, a changelog line gone stale — but across all three reviews
there was not one citation of the datasheet and not one
supply-chain observation
, including on #69, which changed the
release-plz workflow and the crates.io trusted-publishing path.

This driver's correctness is defined by SBOS663A. A reviewer that never
opens it can only check the code against taste.

What is here

docs/vendor/datasheet.txt — the TMP108 datasheet extracted with
pdftotext -layout, CRLF normalised to LF, so line numbers are stable
and register tables stay on greppable lines. Committing it means a
reviewer needs neither network access nor poppler installed, and every
citation becomes an anchor anyone can re-check with grep.

The directory is docs/vendor/ rather than a datasheet-specific path so
that application notes, errata, reference manuals or layout guides can
join it later; the skill globs docs/vendor/*.txt and treats whatever it
finds as in scope. Cargo.toml uses an include allowlist, so the
extract does not ship to crates.io.

.github/skills/code-review/SKILL.md — the skill itself:

  • Orient first. Read AGENTS.md, then the matching spec in
    docs/superpowers/specs/ via a topic→spec map, then tmp108.ddsl,
    then mod ops. A comment that contradicts a spec is a false positive.
  • Cite, never remember. Every hardware claim carries a
    docs/vendor/<file>.txt:<line> anchor and a verbatim quote. A fact
    that is not in the extract is not asserted.
  • Twenty TMP108 facts worth checking against a diff, each anchored:
    address strapping, pointer values, the 12-bit MSB-first twos-complement
    encoding, the configuration POR bytes, M1/M0 (continuous is M1 = 1
    alone, so 0b10 and 0b11 both mean continuous), the one-shot
    lifecycle, CR/HYS/POL/TM, the destructive configuration read,
    the comparator release band, limit POR values, the SMBus alert-response
    cause bit, general call, and the bus timeout.
  • Repository invariants restated as things a diff can violate:
    generated src/inner.rs, blocking/async parity through mod ops, the
    async |t| { … } closure shape, exact feature gating, the pinned
    re-export list, release-plz's ownership of the version and changelog,
    README snippet extraction, and cargo-vet coverage for new
    dependencies.
  • An adversarial pass on every diff, including documentation-only
    ones: build scripts, workflow privilege escalation, dependency
    provenance, lint suppression, unicode that does not render as it reads,
    and tampering with the trusted-publishing path. Findings are framed as
    risk that needs justifying in the PR, not as accusations of intent.
  • Known non-findings, so deliberate choices are not filed as bugs:
    the blocking/async duplication, the generated inner.rs, the
    rust,ignore README fences, the intentional pico-de-gallo minor-version
    mismatch, the un-bumped Cargo.toml version, and the 0x7FF8 T_HIGH
    reset that contradicts Table 11 but was confirmed on silicon.

Verification

Every one of the 42 datasheet line anchors in the skill was checked to
resolve to the text it claims.

The skill was then run against three seeded diffs by a reviewing agent:

Diff Result
Three planted datasheet violations — wrong POR_CONFIG, swapped 2 °C/4 °C hysteresis, byte-reversed t-low reset All three caught, each with a verbatim quote and line anchor. It also derived the LE-word ↔ MSB-first-wire relationship and named the existing test that would fail.
Seven planted malicious constructs — credential-exfiltrating build.rs, pull_request_target with contents: write/id-token: write checking out PR code, forked action plus curl | sh, unsound unsafe behind #![allow(unsafe_code)], host-endian decode, a serde_jsom typosquat and a git-branch dependency, an unjustified [[trusted]] entry All seven flagged, plus two it was not seeded for: --locked dropped from CI and a crate-wide pedantic allowance.
A correct diff adding one method to each driver type, tripping several known non-findings Clean approve, no false positives; it explicitly recorded that leaving the version and changelog untouched is correct.

Notes for reviewers

  • Copilot reads skills from the head branch, so this PR is its own test
    case
    — requesting a Copilot review here exercises the skill before it
    is merged.
  • .github/skills/ is Copilot-specific. opencode, Claude Code and Gemini
    CLI look in .opencode/skills/, .claude/skills/ and .agents/skills/
    and will not discover this. Happy to add a copy or pointer under
    .agents/skills/ if we want the same review protocol available to
    local agents.
  • No source, test or build-configuration files are touched, so the
    existing CI matrix is unaffected.

Assisted-by: opencode:claude-opus-5 [pdftotext]

Reviewers checking this driver against the hardware have had to fetch and
re-extract SBOS663A by hand, which makes every citation a section number
nobody can mechanically re-check, and leaves an automated reviewer
dependent on network access and on pdftotext being installed.

Commit the extract instead. It is pdftotext -layout output with CRLF
normalised to LF, so line numbers are stable and register tables stay on
greppable lines. The directory is docs/vendor/ rather than a datasheet-
specific path so application notes, errata and layout guides can join it.

Cargo.toml uses an include allowlist, so the extract does not ship to
crates.io.

Source: https://www.ti.com/lit/ds/symlink/tmp108.pdf
Revision: SBOS663A, April 2013, revised September 2019
PDF sha256: ec086250fc4331e7fc923be62173062bbf0fccedad6894c2741b73cd1c084556

Assisted-by: opencode:claude-opus-5 [pdftotext]
@felipebalbi
felipebalbi marked this pull request as ready for review September 25, 2026 20:38
@felipebalbi
felipebalbi requested a review from a team as a code owner September 25, 2026 20:38
@felipebalbi
felipebalbi requested review from kurtjd and a lite review from Copilot September 25, 2026 20:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The datasheet reproduction requires permission or a compliant alternative, and several skill-guidance corrections remain.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 3 Low severity

Open (3)
What changed in this PR

Adds an offline TMP108 datasheet extract and a repository-specific Copilot code-review skill.

Changes:

  • Adds citation-ready vendor documentation.
  • Adds hardware, repository-invariant, and supply-chain review guidance.
File Summary
docs/​vendor/​datasheet.txt Adds the extracted TMP108 datasheet.
.github/​skills/​code-review/​SKILL.md Defines repository-specific review procedures and checks.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/skills/code-review/SKILL.md Outdated
Comment thread .github/skills/code-review/SKILL.md Outdated
Comment thread .github/skills/code-review/SKILL.md Outdated
felipebalbi added a commit to felipebalbi/tmp108 that referenced this pull request Sep 25, 2026
Copilot reviewed OpenDevicePartnership#73 using the skill and found three places where it
describes the repository more strictly than the repository is. Each one
would have made a reviewer following the skill file a finding against
code that is deliberate. Autofix in 1a3e944 addressed all three; this
refines two of them and keeps its hardening of the third.

The crate is not unsafe-free: src/inner.rs carries 24 unsafe items,
including unsafe impl Fieldset and device_driver::ops::load, covered by
the scoped allow block on mod inner at src/lib.rs:54-59. Autofix
corrected the claim but left the adversarial bullet telling reviewers to
challenge *any* allow attribute, which is what would actually have
produced the false positive. Narrow it to a widened allowance, and name
the sanctioned block so it is not re-litigated on every PR.

The # Examples requirement is on methods. Autofix's 'public methods and
other user-facing APIs carry appropriate doctests' restates the same
ambiguity that caused the finding; say methods, and record that Config
and Tmp108 are correct as they stand.

Keep autofix's hardened curl invocation and sha256sum --check, and add
the explicit failure path: lit/ds/symlink/ is unversioned, so a
regeneration that silently succeeds against a replaced revision
invalidates every line anchor in this skill, in past reviews and in
docs/superpowers/specs/. Also replace the CRLF-normalisation comment
with the sed that actually performs it.

Re-ran the seeded-malicious-diff review: all nine findings still fire,
the existing scoped allow is still not reported, and the new crate-wide
allow still is.

Assisted-by: opencode:claude-opus-5
kurtjd
kurtjd previously approved these changes Sep 25, 2026
Comment thread docs/vendor/datasheet.txt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking: Are we sure it's legal to have this copy here? The datasheet says:

These resources are subject to change without notice. TI grants you permission to use these resources only for development of an application that uses the TI products described in the resource. Other reproduction and display of these resources is prohibited.

Though I'm no lawyer of course so dunno.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, that needs to be answered :-) Asked our lawyers for comment. Keeping it as a draft for now.

felipebalbi and others added 2 commits September 25, 2026 14:10
GitHub Copilot code review reads agent skills from .github/skills on the
head branch, and prefers review-focused directory names such as
code-review. Without one it reviews this crate as generic Rust: the
reviews on OpenDevicePartnership#48, OpenDevicePartnership#69 and OpenDevicePartnership#71 produced sound style comments but not a
single citation of the datasheet and no supply-chain observation, even on
a diff that changed the trusted-publishing workflow.

The skill orients a reviewer in the crate, points every hardware claim at
a line in docs/vendor/*.txt with a verbatim quote, lists the TMP108 facts
worth checking against a diff, restates the invariants from AGENTS.md as
things a diff can violate, and adds an adversarial pass for build
scripts, workflow privilege, dependency provenance and lint suppression.
A known-non-findings section records the deliberate choices -- the
blocking/async duplication, the generated inner.rs, the measured 0x7FF8
reset that contradicts Table 11 -- so they are not filed as bugs.

Two boundaries are drawn deliberately, because getting either wrong
turns the skill into a source of false positives against code that is
correct. The crate is not unsafe-free: src/inner.rs carries unsafe impl
Fieldset and device_driver::ops::load under the scoped allow block on
mod inner at src/lib.rs:54-59, so the adversarial pass asks about a
*widened* lint allowance rather than any allowance at all. The #
Examples requirement is on methods; Config and Tmp108 are documented
without examples and are correct.

Verified with three review runs against seeded diffs: three planted
datasheet violations were all caught with line anchors, seven planted
malicious constructs were all flagged, and a correct diff that trips the
known non-findings drew no false positives. A fourth run confirmed the
narrowed lint wording still reports a new crate-wide allow while leaving
the sanctioned mod inner block alone.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Assisted-by: opencode:claude-opus-5
A TI field applications engineer reviewed the reproduction and read it
as fair use, on two conditions: that the directory say plainly it is a
reproduction kept for AI-based code review, and that it link to TI's
official documents. Both are cheap, and both make the directory easier
to understand for a human arriving at it cold.

Add docs/vendor/README.md carrying that notice. It also carves the
directory out of the repository's MIT license -- the extracts remain
TI's copyright, which the license would otherwise appear to claim
against them -- names TI's product folder, datasheet and terms of use as
the authoritative sources, and records that the vendor's own notices are
reproduced verbatim with nothing removed.

Move the provenance and regeneration procedure there from the skill, so
they live in one place. The split is the honest one: the skill governs
how a reviewer cites an extract, the README how a maintainer produces
one. The skill now points at it and keeps only the citation contract.

The include allowlist in Cargo.toml anchors /README.md to the
package root, so this file is not published either; cargo package
--list reports 14 files and no docs/vendor/ content.

Note the FAE asked for wording about AI-based review specifically. The
README says the extracts serve automated review agents principally and
the humans checking their citations, because that is what happens --
worth re-confirming with him if he wants it narrower.

Assisted-by: opencode:claude-opus-5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved licensing/compliance and datasheet-extract integrity findings remain.

Review effort: Lite
Findings: None

Resolved since last review (3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants