Skip to content

feat(cli): bundle and upload jvm sources with hog - #144749

Merged
trunk-io[bot] merged 7 commits into
masterfrom
ab/feat/cli-jvm-upload-sources
Dec 3, 2026
Merged

trunk-io[bot] merged 7 commits into
masterfrom
ab/feat/cli-jvm-upload-sources

Conversation

@ablaszkiewicz

@ablaszkiewicz ablaszkiewicz commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Source code for JVM server exceptions, in release order:

  1. feat(error-tracking): show source code for jvm frames #142847 cymbal: read JVM source bundles
  2. feat(cli): bundle and upload jvm sources with hog #144749 hog: hog error-tracking bundle 👈 this PR
  3. feat(server): read the map id and release id from posthog-meta.properties posthog-android#1019 posthog-server: send the IDs from posthog-meta.properties
  4. feat(maven-plugin): add posthog-maven-plugin to upload jvm sources with hog posthog-android#1011 Maven plugin: upload the sources at build time
  5. feat(gradle-plugin): add com.posthog.jvm to upload jvm sources with hog posthog-android#1012 Gradle plugin com.posthog.jvm: upload the sources at build time

What each step waits for:

Problem

Changes

  • hog et bundle <folders> writes Java and Kotlin files into one .jvmbundle, whose ID comes from the files.
  • upload sends .jvmbundle files without a release, and process bundles jvm folders first.
  • hog never detects a source folder: code leaves only with --kind jvm or "kind": "jvm".
  • --meta-out writes the bundle and release IDs to posthog-meta.properties after the upload.
  • hog-worker pins posthog-symbol-data 0.6.0. posthog-cli is frozen on 0.5.2, so worker-pins.test.ts now lets this one crate be newer, never older. The container goldens still pass.
Terminal output
$ hog et bundle app --output-dir build/posthog
✓ Bundled 2 source files as c57b25b0-09dd-52e3-a4e4-c5c2572002f1
  Wrote build/posthog/c57b25b0-09dd-52e3-a4e4-c5c2572002f1.jvmbundle
$ hog et bundle app --output-dir build/posthog
✓ Bundled 1 source file as b8c0a0d6-c645-5d83-a526-b9a871c1ddcd
  Wrote build/posthog/b8c0a0d6-c645-5d83-a526-b9a871c1ddcd.jvmbundle
  Removed build/posthog/c57b25b0-09dd-52e3-a4e4-c5c2572002f1.jvmbundle

Left out com/example/shop/Cart.java: app/src/main/java/com/example/shop/Cart.java and app/src/main/kotlin/billing/Cart.java have the same package and file name, so PostHog can't tell which one a stack frame points at.
$ hog et upload build/posthog --meta-out build/meta --dry-run
• Dry run: 1 symbol set would be uploaded. Nothing was sent
┌──────────────────────────────────────────────────┬──────┬──────────────────────────────────────┬──────┬─────────┐
│ path                                             │ kind │ chunk id                             │ size │ status  │
├──────────────────────────────────────────────────┼──────┼──────────────────────────────────────┼──────┼─────────┤
│ build/posthog/b8c0a0d6-c645-5d83-a526-b9a871c1d… │ jvm  │ b8c0a0d6-c645-5d83-a526-b9a871c1ddcd │  139 │ planned │
└──────────────────────────────────────────────────┴──────┴──────────────────────────────────────┴──────┴─────────┘
$ hog et upload app --kind jvm
Error: app holds JVM source files, and upload sends only the bundle made from them.
Run `hog error-tracking bundle` on the folder first, or use `hog error-tracking process`, which does both.
# exit 2

A real upload that writes posthog-meta.properties is covered by a test against a fake PostHog, not run against a real one.

How did you test this code?

Test rationale: new tests catch a bundle sent with a release, a stale bundle, a meta file left after a failed upload, wrong skip rules, a source that decodes past the size limit, and an unbundled folder upload. Each failed against a broken copy.

  • Not run: a real upload, or the Gradle and Maven plugins.
  • The comment density warning stays, because the added comments give reasons the code can't show.

Release status

  • No feature flag controls this change

Docs update

  • The hog README.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Agent: Claude Code, Claude Opus 5.5

Skills: /developing-the-cli, /writing-tests, /writing-code-comments, /writing-user-facing-copy, /writing-pr-descriptions

Driver checked: Decided the hog-only move, the separate bundle and upload steps, the bundle name, and the jvm kind for process. Not yet checked the diff.

Security review: not needed

More context for AI agents
  • Session: https://claude.ai/code/session_01FkuJA9vNowLRRGH1hbFyhv and https://claude.ai/code/session_01FkuJADQzM8ma8T9RauvMg5 wrote the posthog-cli version; a later Claude Code session moved it to hog.
  • Decisions: the release travels with the exception as $release_id, so the bundle ID is the sources alone, as in the posthog-cli version.
  • Decisions: keys come from each file's package line, not its folder, because Kotlin allows them to differ.
  • Decisions: hog walks the folders and applies ignore globs. hog-worker reads files, parses packages and writes the bundle with posthog-symbol-data.
  • Decisions: upload recomputes the ID from the bundle contents rather than trusting the file name.
  • Decisions: worker protocol 2 adds jvm_bundle and jvm_read.
  • Decisions: no --skip-without-credentials: plugins treat exit 3 (not_authenticated) as a skipped upload.
  • Follow-ups: no parity golden, because posthog-cli never shipped JVM upload.
  • Read closely: hog/src/error-tracking/run.ts (the JVM block in uploadFrom), jvmSourceRoots, and the skip rules in hog/src/error-tracking/jvm.ts.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

✅ Trunk lane — non-backend lane (hog)

This PR is assigned to the non-backend lane (hog). It does not run backend Python tests and may merge in parallel with PRs in other lanes.

✅ Duplication (Python) — clean

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

✅ Duplication (TypeScript) — clean

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

⚠️ Comment density — 6% of added code lines are comments (70 of 1220)

This section warns when comments are more than 3% of the code lines a PR adds, and alerts above 6%. Before agent-assisted PRs, the typical share was about 2%. Only full-line comments count. Docstrings, generated files, snapshots, migrations, and workflow files are left out.

Comments that restate the code, record how the change came about, or narrate the next line add noise for the next reader. Keep the comments that explain a reason the code cannot show, and remove the rest. See .agents/skills/writing-code-comments/SKILL.md for the house rules.

Files with the most added comment lines:

File Comment lines Added lines
hog/worker/src/jvm.rs 28 539
hog/src/error-tracking/jvm.ts 15 192
hog/src/error-tracking/run.ts 9 131
hog/worker/src/main.rs 8 27
hog/src/commands/error-tracking/error-tracking.test.ts 3 126
hog/test/parity/worker-pins.test.ts 3 16
hog/src/error-tracking/discover.ts 2 16
hog/src/error-tracking/session.ts 1 2

This check does not block merging. It updates on every push and clears when the share drops.

✅ Dependency scan — clean, 1 package scanned

GuardDog scans each registry package this pull request adds to a lockfile or a go.mod file. This check is advisory and does not block the merge. Most findings are false positives, so read the rule names before acting.

Scanned 1 package.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@PostHog/team-mobile-app This PR may need a new production iOS or Android build. See why the check flagged it.

Anyone with repository write access, including the PR author, can acknowledge this commit.

  1. Post /ack-mobile-rebuild a0fae48d8fc74c60cdef0f06629f39242d828003 as a separate PR comment.
  2. Select Re-run failed jobs on the workflow run so the check reads your acknowledgement.

@ablaszkiewicz
ablaszkiewicz force-pushed the ab/feat/cli-jvm-upload-sources branch 2 times, most recently from ec963d0 to 5a9ee97 Compare December 1, 2026 16:25
@ablaszkiewicz
ablaszkiewicz marked this pull request as ready for review December 1, 2026 17:36
@parameterai

parameterai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Risk: Low · 1 low

This increment only swaps hog-worker's posthog-symbol-data dependency from an in-repo path to the published "=0.6.0" from crates.io (lock-pinned with a checksum, no dependency-set change) and relaxes the worker-pins test to allow that one crate to be newer than posthog-cli's frozen version. It touches no runtime input, auth, secret or upload logic, and I found no security weakness in it.

Sentinel reviewed feb5436 · Review settings

@veria-ai

veria-ai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

Reviews

@ablaszkiewicz

Copy link
Copy Markdown
Contributor Author

@PostHog review --deep

@posthog

posthog Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@ablaszkiewicz PostHog Review is reviewing this pull request.

@posthog posthog Bot 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.

PostHog Review · Standard · reviewed 5a9ee97: 1 Must fix, 6 Should fix.

New pushes to this pull request won't start an automatic review. Comment @posthog review to review new changes.

Comment thread cli/Cargo.toml Resolved
Comment thread cli/src/commands.rs Resolved
Comment thread cli/src/jvm/sources.rs Resolved
Comment thread cli/src/jvm/sources.rs Resolved
Comment thread cli/src/jvm/sources.rs Resolved
Comment thread cli/src/jvm/upload.rs Resolved
Comment thread cli/src/jvm/upload.rs Resolved
@posthog

posthog Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

PostHog Review · Deep · reviewed 5a9ee97

Posted 1 finding: 1 Consider.

Step Status Result
Prepare the diff done 10 files, 2 chunks
Pick perspectives done 3 perspectives
Run review passes done 17 issues (+2 blind-spot)
Merge overlapping findings done 19 → 7
Validate findings done 1 kept, 6 dismissed
Publish done 1 posted (view review)

@posthog
posthog Bot requested review from a team, MattBro, fercgomes and rafaeelaudibert and removed request for a team December 1, 2026 17:39
Comment thread cli/src/commands.rs Resolved
Comment thread cli/src/utils/auth.rs Resolved
Comment thread cli/src/jvm/sources.rs Resolved

@rafaeelaudibert rafaeelaudibert left a comment

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.

Requesting changes just until I can come back to this and make this work for hog only, posthog-cli is frozen now.

I'll fix this as soon as I'm finished with the launch of hog, probably tomorrow.

@rafaeelaudibert rafaeelaudibert changed the title feat(cli): add jvm upload for java and kotlin sources feat(cli): bundle and upload jvm sources with hog Dec 2, 2026
Base automatically changed from ab/feat/jvm-source-context to master December 3, 2026 12:28
@trunk-io

trunk-io Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

😎 Stack merged successfully - details.

Comment thread hog/worker/src/jvm.rs Resolved
rafaeelaudibert and others added 5 commits December 3, 2026 14:12
hog error-tracking bundle writes the Java and Kotlin files of a build
into one bundle whose id comes from the files. upload sends it, and
process bundles folders of the jvm kind and uploads them in one step.
--meta-out writes posthog-meta.properties after a successful upload,
and --skip-without-credentials lets build plugins pass without
credentials.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hog already exits 3 with not_authenticated when it finds no credentials,
and removes the old posthog-meta.properties first, so build plugins can
treat that exit as a skipped upload without a separate flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- upload refuses unbundled source folders itself, so the shared upload
  flow needs no flag for it
- bundle reuses select's root resolution and the discover walk
- hog-worker reads sources with the bounded read from sources.rs and
  writes the bundle through Container
- jvm_read no longer returns a file count nobody reads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Read a package declaration through comments and line breaks, accept `$` in package names, and let Kotlin block comments nest, so these files get the key cymbal looks up.
- Check the file count and the total source size before any file is read, so a source tree too large to bundle fails without its text in memory.
- Skip every `src/*Test` source set, which covers the Kotlin Multiplatform `commonTest` and `jvmTest` sets.
- Leave posthog-meta.properties in place on a dry run.

Unverified: tooling (hogli verify runs hog tests with jest; bun test passes, 1194 tests)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…meta-out

- Decode a source file that is not UTF-8, such as Latin-1 Java, with replacement characters instead of leaving it out, so its frames still show code.
- Warn when a JVM bundle uploads without --meta-out: the SDK reads the bundle ID and the release ID only from posthog-meta.properties, so nothing would point at the upload.

Unverified: tooling (hogli verify runs hog tests with jest; bun test passes)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ablaszkiewicz
ablaszkiewicz force-pushed the ab/feat/cli-jvm-upload-sources branch from b50f862 to fb4b90d Compare December 3, 2026 13:12
A source file that is not valid UTF-8 grows when each invalid byte becomes a three-byte replacement character. A file under the 1 MiB limit on disk could therefore go over it in the bundle. Every reader refuses a bundle with a source over that limit, so one such file hid the code of every frame in the app. hog now checks the decoded text against the limit and leaves the file out with the same reason as a file that is too large on disk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ablaszkiewicz

Copy link
Copy Markdown
Contributor Author

@rafaeelaudibert I've tested everything on my end and it looks good - can you remove your "changes requested" marker?

@rafaeelaudibert rafaeelaudibert left a comment

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.

Oops, forgot to approve!

Ty aleks

…0.6.0

hog CI and the release build check out only hog/, so hog-worker could not build the crate from rust/common/symbol_data. It now pins 0.6.0 from crates.io.

posthog-cli is frozen on 0.5.2, which has no JVM bundles, so worker-pins.test.ts now lets posthog-symbol-data be newer than posthog-cli's version, but never older. The container goldens in hog/worker/src/parity.rs pass on 0.6.0, so the other symbol set types still match posthog-cli byte for byte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trunk-io
trunk-io Bot merged commit 645556d into master Dec 3, 2026
235 of 236 checks passed
@trunk-io
trunk-io Bot deleted the ab/feat/cli-jvm-upload-sources branch December 3, 2026 16:53
@deployment-status-posthog

deployment-status-posthog Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-12-03 17:50 UTC Run
prod-us ✅ Deployed 2026-12-03 18:20 UTC Run
prod-eu ✅ Deployed 2026-12-03 18:26 UTC Run

This table shows the posthog release only. Hogstation shows every service that this PR reaches, Kargo services included.

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.

2 participants