@titan-design/code-graph 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -234,7 +234,9 @@ fail a check.
|
|
|
234
234
|
flags every symbol strictly above the 95th percentile of `symbol_body_lines` over all symbols
|
|
235
235
|
that carry it, interpolated linearly between ranks. `percentile` runs from 50 to 100. The rule
|
|
236
236
|
stays silent until `minSample` nodes (default 20) carry the metric. Each violation's
|
|
237
|
-
`threshold` is the computed percentile value.
|
|
237
|
+
`threshold` is the computed percentile value. For sparse metrics whose percentile sits at or
|
|
238
|
+
near zero, `floor` flags a node only if its value also exceeds that absolute number, and
|
|
239
|
+
`rankNonZero: true` ranks and gates on non-zero carriers only.
|
|
238
240
|
|
|
239
241
|
```ts
|
|
240
242
|
import { checkSnapshot, loadCheckRules, openCodeGraph } from "@titan-design/code-graph";
|
package/dist/index.js
CHANGED
|
@@ -1634,6 +1634,9 @@ function isInsideGitRepo(repoRoot) {
|
|
|
1634
1634
|
function resolveGitRef(repoRoot, ref) {
|
|
1635
1635
|
return runGit(repoRoot, ["rev-parse", ref]);
|
|
1636
1636
|
}
|
|
1637
|
+
function isGitAncestor(repoRoot, ancestor, descendant) {
|
|
1638
|
+
return runGit(repoRoot, ["merge-base", "--is-ancestor", ancestor, descendant]) !== null;
|
|
1639
|
+
}
|
|
1637
1640
|
function detectRenames(options) {
|
|
1638
1641
|
const threshold = options.similarityThreshold ?? 80;
|
|
1639
1642
|
const args = [
|
|
@@ -1805,9 +1808,15 @@ function priorSnapshotForRef(store, ref, options = {}) {
|
|
|
1805
1808
|
const byCommit = commit ? candidates2.find((s) => s.commitHash === commit) : void 0;
|
|
1806
1809
|
return byCommit ?? candidates2.find((s) => s.ref === ref) ?? null;
|
|
1807
1810
|
}
|
|
1808
|
-
function
|
|
1811
|
+
function aliasTargetCommit(target) {
|
|
1812
|
+
return target.commit ?? detectGitHead(target.repoRoot);
|
|
1813
|
+
}
|
|
1814
|
+
function aliasBaseFor(store, ref, target) {
|
|
1809
1815
|
const committed = allSnapshots(store).filter((s) => s.commitHash).reverse();
|
|
1810
|
-
|
|
1816
|
+
const candidate = committed.find((s) => s.ref === ref) ?? committed[0];
|
|
1817
|
+
if (!candidate?.commitHash) return null;
|
|
1818
|
+
const commit = aliasTargetCommit(target);
|
|
1819
|
+
return commit && isGitAncestor(target.repoRoot, candidate.commitHash, commit) ? candidate : null;
|
|
1811
1820
|
}
|
|
1812
1821
|
|
|
1813
1822
|
// src/identity/index-aliases.ts
|
|
@@ -1828,17 +1837,17 @@ function movedSymbolAliases(store, baseSnapshotId, fileAliases, nodes) {
|
|
|
1828
1837
|
}
|
|
1829
1838
|
return out;
|
|
1830
1839
|
}
|
|
1831
|
-
function renameAliases(input, baseCommit) {
|
|
1832
|
-
if (input.detectRenames === false ||
|
|
1833
|
-
const target = input.commitHash ?? detectGitHead(input.rootDir) ?? void 0;
|
|
1834
|
-
if (target === baseCommit) return [];
|
|
1840
|
+
function renameAliases(input, baseCommit, target) {
|
|
1841
|
+
if (input.detectRenames === false || target === baseCommit) return [];
|
|
1835
1842
|
const pairs = detectRenames({ repoRoot: input.rootDir, fromCommit: baseCommit, toCommit: target });
|
|
1836
1843
|
return buildAliases(input.idRoot, pairs);
|
|
1837
1844
|
}
|
|
1838
1845
|
function computeAliasBridge(store, input) {
|
|
1839
|
-
const
|
|
1840
|
-
|
|
1841
|
-
const
|
|
1846
|
+
const target = { repoRoot: input.rootDir, commit: input.commitHash };
|
|
1847
|
+
const base = aliasBaseFor(store, input.ref, target);
|
|
1848
|
+
const commit = base ? aliasTargetCommit(target) : null;
|
|
1849
|
+
if (!base?.commitHash || !commit) return { baseSnapshotId: null, aliases: [] };
|
|
1850
|
+
const fileAliases = renameAliases(input, base.commitHash, commit);
|
|
1842
1851
|
const symbols = movedSymbolAliases(store, base.id, fileAliases, input.nodes);
|
|
1843
1852
|
return { baseSnapshotId: base.id, aliases: [...fileAliases, ...symbols] };
|
|
1844
1853
|
}
|