Skip to content

Commit d229c8e

Browse files
authored
fix(manifest): merge JVM facts components by coordinate (#1557)
* fix(manifest): merge JVM facts components by coordinate Drop the path-sensitive subtree hashing and `resolvedAs` from .socket.facts.json and write it compact. The Socket backend never used the per-path precision, and it inflated facts files for large builds. Reachability still needs each subproject's exact classpath, so the compute-artifacts sidecar now carries `projects[].classpath`: the component ids resolved for that subproject across all its configurations. * feat(manifest): record the socket-cli version in JVM facts metadata A facts file carried no trace of which CLI release generated it, so a stale file uploaded by a newer CLI was indistinguishable from fresh output. * upgrading coana to version 15.10.55
1 parent f7ef5c0 commit d229c8e

16 files changed

Lines changed: 201 additions & 134 deletions

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
77
## [Unreleased]
88

99
### Changed
10-
- Updated the Coana CLI to v `15.10.54`.
10+
- Updated the Coana CLI to v `15.10.55`.
11+
- Generated Maven, Gradle and sbt `.socket.facts.json` files are now substantially smaller, making uploads for large JVM projects faster and more reliable.
1112

1213
## [1.1.178](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.178) - 2026-09-23
1314

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"@babel/preset-typescript": "7.27.1",
106106
"@babel/runtime": "7.28.4",
107107
"@biomejs/biome": "2.2.4",
108-
"@coana-tech/cli": "15.10.54",
108+
"@coana-tech/cli": "15.10.55",
109109
"@cyclonedx/cdxgen": "12.1.2",
110110
"@dotenvx/dotenvx": "1.49.0",
111111
"@eslint/compat": "1.3.2",

‎pnpm-lock.yaml‎

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/commands/manifest/enumerate-workspaces.test.mts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ function okResult(): WorkspaceEnumerationResult {
2020
name: 'root',
2121
subprojectDir: '.',
2222
dependencies: [],
23-
resolvedAs: [],
2423
},
2524
],
2625
stderr: '',

‎src/commands/manifest/generate-recursive-manifests.test.mts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@ describe('generateRecursiveManifests', () => {
6161
name: 'moduleA',
6262
subprojectDir: 'moduleA',
6363
dependencies: [],
64-
resolvedAs: [],
6564
},
6665
{
6766
type: 'maven',
6867
name: 'moduleB',
6968
subprojectDir: 'moduleB',
7069
dependencies: [],
71-
resolvedAs: [],
7270
},
7371
],
7472
}
@@ -137,7 +135,6 @@ describe('generateRecursiveManifests', () => {
137135
name: 'shared-lib',
138136
subprojectDir: `../${sharedLibName}`,
139137
dependencies: [],
140-
resolvedAs: [],
141138
},
142139
],
143140
}

‎src/commands/manifest/run-manifest-facts.mts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,11 @@ export async function runManifestFacts({
221221
return
222222
}
223223

224-
await fs.writeFile(factsPath, JSON.stringify(facts, null, 2), 'utf8')
224+
const socketCliVersion = constants.ENV.INLINED_SOCKET_CLI_VERSION
225+
if (facts.metadata && socketCliVersion) {
226+
facts.metadata.socketCliVersion = socketCliVersion
227+
}
228+
await fs.writeFile(factsPath, JSON.stringify(facts), 'utf8')
225229

226230
if (withFiles && sidecarAcc) {
227231
// Key by the symlink-resolved path so the sidecar's keys are comparable

‎src/commands/manifest/run-manifest-facts.test.mts‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ vi.mock('./scripts/run.mts', () => ({
1010

1111
import { runManifestFacts } from './run-manifest-facts.mts'
1212
import { runManifestScript } from './scripts/run.mts'
13+
import constants from '../../constants.mts'
1314

1415
import type { ManifestRunResult } from './scripts/run.mts'
1516
import type { SidecarAccumulator } from './scripts/sidecar.mts'
@@ -29,6 +30,7 @@ function okResult(): ManifestRunResult {
2930
targetsByGav: new Map(),
3031
sourcesByCoord: new Map(),
3132
coords: new Set(),
33+
classpathByProject: new Map(),
3234
},
3335
stderr: '',
3436
stdout: '',
@@ -122,7 +124,6 @@ describe('runManifestFacts - sidecar', () => {
122124
version: '1.0',
123125
subprojectDir: '.',
124126
dependencies: [],
125-
resolvedAs: [],
126127
},
127128
]
128129
vi.mocked(runManifestScript).mockResolvedValue(result)
@@ -137,4 +138,24 @@ describe('runManifestFacts - sidecar', () => {
137138
const bucket = sidecarAcc.get(expectedFactsFile)
138139
expect(bucket?.projects.find(m => m.name === 'app')).toBeDefined()
139140
})
141+
it('stamps the inlined socket-cli version into the written facts metadata', async () => {
142+
const result = okResult()
143+
result.facts.metadata = {
144+
format: 'socket-facts-sbom',
145+
tool: 'maven',
146+
toolVersion: '3.9.9',
147+
}
148+
vi.mocked(runManifestScript).mockResolvedValue(result)
149+
150+
await runManifestFacts({ ...baseArgs, cwd })
151+
152+
const written = JSON.parse(
153+
await fs.readFile(path.join(cwd, '.socket.facts.json'), 'utf8'),
154+
)
155+
// Unit tests run unbuilt, where the version isn't inlined; the field is
156+
// then omitted rather than written empty.
157+
expect(written.metadata.socketCliVersion).toBe(
158+
constants.ENV.INLINED_SOCKET_CLI_VERSION || undefined,
159+
)
160+
})
140161
})

0 commit comments

Comments
 (0)