Skip to content

Commit 85d381a

Browse files
committed
refactor: address fallow audit findings on the settle tail
- drop the unused export on buildSettleTail (tests exercise the trigger through the public interaction path and the filter via buildSettleTailEntries) - extract the digest tail capping from interactionSettleView into a module-private helper to stay under the complexity gate
1 parent e4f3952 commit 85d381a

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎src/commands/interaction/runtime/settle.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function buildSettleDiffAndTail(
175175
* present on the diff's added lines are excluded so the tail never repeats
176176
* what the diff already handed the caller.
177177
*/
178-
export function buildSettleTail(
178+
function buildSettleTail(
179179
diff: NonNullable<SettleObservation['diff']>,
180180
settledNodes: SnapshotNode[],
181181
): Pick<SettleObservation, 'tail' | 'tailTruncated'> {

‎src/daemon/response-views.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,17 @@ function interactionSettleView(data: DaemonResponseData, level: ResponseLevel):
165165
settle: {
166166
...rest,
167167
...(refs.length > 0 ? { refs } : {}),
168-
...(Array.isArray(tail) && tail.length > 0 ? { tail: tail.slice(0, DIGEST_REF_LIMIT) } : {}),
168+
...cappedSettleDigestTail(tail),
169169
diff: { summary },
170170
},
171171
};
172172
}
173173

174+
function cappedSettleDigestTail(tail: unknown): Record<string, unknown> {
175+
if (!Array.isArray(tail) || tail.length === 0) return {};
176+
return { tail: tail.slice(0, DIGEST_REF_LIMIT) };
177+
}
178+
174179
type DigestRef = { ref: string };
175180

176181
function readSettleDigestRefs(lines: unknown): DigestRef[] {

0 commit comments

Comments
 (0)