Skip to content

Commit 520467e

Browse files
committed
추가: 지식 파일 계보 메타데이터 표시
1 parent de88b71 commit 520467e

4 files changed

Lines changed: 126 additions & 1 deletion

File tree

‎ui/packages/contracts/src/universe.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,19 @@ export interface UniverseKnowledgeContentReceipt {
816816
truncated: boolean;
817817
}
818818

819+
export interface UniverseKnowledgeFileMeta {
820+
sizeBytes: number | null;
821+
blobId: string;
822+
lfsOid: string | null;
823+
lfsSizeBytes: number | null;
824+
xetHash: string | null;
825+
lastCommitId: string | null;
826+
lastCommitTitle: string | null;
827+
lastCommitAt: string | null;
828+
securityStatus: string | null;
829+
antivirusStatus: string | null;
830+
}
831+
819832
export interface UniverseKnowledgeContent {
820833
targetId: string;
821834
path: string;
@@ -831,5 +844,6 @@ export interface UniverseKnowledgeContent {
831844
rows: readonly Readonly<Record<string, string>>[];
832845
tree: readonly UniverseKnowledgeTreeNode[];
833846
tableMeta: UniverseKnowledgeTableMeta;
847+
fileMeta: UniverseKnowledgeFileMeta;
834848
receipt: UniverseKnowledgeContentReceipt;
835849
}

‎ui/packages/runtime/src/data/universe/knowledge.test.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ interface ContentCallLog {
3737
parquetRevision?: string;
3838
byteOrigin?: string;
3939
bytePath?: string;
40+
metadataPath?: string;
41+
metadataMethod?: string;
42+
metadataBody?: string;
4043
}
4144

4245
function fakeCore(contentCalls?: ContentCallLog): DataCore {
@@ -45,6 +48,22 @@ function fakeCore(contentCalls?: ContentCallLog): DataCore {
4548
if (spec.path.startsWith('tree/main')) {
4649
return [{ type: 'directory', path: 'dart' }, { type: 'directory', path: 'edgar' }] as T;
4750
}
51+
if (spec.path.startsWith('paths-info/')) {
52+
if (contentCalls) {
53+
contentCalls.metadataPath = spec.path;
54+
contentCalls.metadataMethod = spec.init?.method;
55+
contentCalls.metadataBody = String(spec.init?.body ?? '');
56+
}
57+
const path = new URLSearchParams(String(spec.init?.body ?? '')).get('paths') ?? '';
58+
const payload = [{
59+
type: 'file', path, oid: 'blob-123', size: path.endsWith('.parquet') ? 1_024 : 81,
60+
lfs: path.endsWith('.parquet') ? { oid: 'lfs-456', size: 1_024 } : null,
61+
xetHash: 'xet-789',
62+
lastCommit: { id: 'commit-abc', title: '데이터 갱신', date: '2026-07-16T03:00:00.000Z' },
63+
securityFileStatus: { status: 'queued', avScan: { status: 'queued' } }
64+
}];
65+
return spec.parse(new Response(JSON.stringify(payload), { status: 200 })) as Promise<T>;
66+
}
4867
return {
4968
sha: 'revision-1',
5069
lastModified: '2026-07-17T10:13:00.000Z',
@@ -156,6 +175,18 @@ describe('Universe knowledge runtime', () => {
156175
expect(textContent.receipt.mode).toBe('byteRange');
157176
expect(contentCalls.byteOrigin).toBe('hfRevisionRange');
158177
expect(contentCalls.bytePath).toBe('revision-1/README.md');
178+
expect(contentCalls.metadataPath).toBe('paths-info/revision-1');
179+
expect(contentCalls.metadataMethod).toBe('POST');
180+
expect(contentCalls.metadataBody).toContain('paths=README.md');
181+
expect(contentCalls.metadataBody).toContain('expand=true');
182+
expect(textContent.fileMeta).toMatchObject({
183+
sizeBytes: 81,
184+
blobId: 'blob-123',
185+
xetHash: 'xet-789',
186+
lastCommitId: 'commit-abc',
187+
securityStatus: 'queued',
188+
antivirusStatus: 'queued'
189+
});
159190

160191
const tableContent = await contentRuntime.content('hf:dart/companyProfile.parquet');
161192
expect(tableContent.kind).toBe('table');
@@ -164,6 +195,7 @@ describe('Universe knowledge runtime', () => {
164195
expect(contentCalls.parquetRevision).toBe('revision-1');
165196
expect(tableContent.tableMeta).toMatchObject({ fileSizeBytes: 1_024, totalRows: 30, rowGroupCount: 3, rangeRequestCount: 1, rowStart: 0, rowEnd: 12 });
166197
expect(tableContent.schema[2]).toMatchObject({ name: 'listed', physicalType: 'BOOLEAN' });
198+
expect(tableContent.fileMeta).toMatchObject({ sizeBytes: 1_024, lfsOid: 'lfs-456', lfsSizeBytes: 1_024 });
167199

168200
const nextTableContent = await contentRuntime.content('hf:dart/companyProfile.parquet', 12);
169201
expect(nextTableContent.tableMeta).toMatchObject({ rowStart: 12, rowEnd: 24, totalRows: 30 });

‎ui/packages/runtime/src/data/universe/knowledge.ts‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ interface HfTreeEntry {
5050
path: string;
5151
}
5252

53+
interface HfPathInfo {
54+
type: 'file';
55+
oid?: string;
56+
size?: number;
57+
path: string;
58+
lfs?: { oid?: string; size?: number } | null;
59+
xetHash?: string | null;
60+
lastCommit?: { id?: string; title?: string; date?: string } | null;
61+
securityFileStatus?: {
62+
status?: string;
63+
avScan?: { status?: string } | null;
64+
} | null;
65+
}
66+
5367
interface SkillGraphNode {
5468
id: string;
5569
title: string;
@@ -496,6 +510,34 @@ export function createUniverseKnowledgeRuntime(core: DataCore, loaders: Universe
496510
parse: parseJson
497511
});
498512

513+
const loadFileMeta = (revision: string, path: string) => core.request<UniverseKnowledgeContent['fileMeta']>({
514+
origin: 'hfApi',
515+
path: `paths-info/${encodeURIComponent(revision)}`,
516+
cacheKey: `universe:knowledge:fileMeta:${revision}:${path}`,
517+
init: {
518+
method: 'POST',
519+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
520+
body: new URLSearchParams({ paths: path, expand: 'true' })
521+
},
522+
parse: async (response) => {
523+
const entries = await parseJson<readonly HfPathInfo[]>(response);
524+
const entry = entries.find((candidate) => candidate.type === 'file' && candidate.path === path);
525+
if (!entry) throw new Error(`Universe knowledge file metadata missing: ${path}`);
526+
return Object.freeze({
527+
sizeBytes: typeof entry.size === 'number' ? entry.size : null,
528+
blobId: entry.oid ?? '',
529+
lfsOid: entry.lfs?.oid ?? null,
530+
lfsSizeBytes: typeof entry.lfs?.size === 'number' ? entry.lfs.size : null,
531+
xetHash: entry.xetHash ?? null,
532+
lastCommitId: entry.lastCommit?.id ?? null,
533+
lastCommitTitle: entry.lastCommit?.title ?? null,
534+
lastCommitAt: entry.lastCommit?.date ?? null,
535+
securityStatus: entry.securityFileStatus?.status ?? null,
536+
antivirusStatus: entry.securityFileStatus?.avScan?.status ?? null
537+
});
538+
}
539+
});
540+
499541
async function overview(): Promise<UniverseKnowledgeOverview> {
500542
const [info, rootEntries, graph] = await Promise.all([loadMetadata(), loadRoot(), loaders.loadSkillGraph()]);
501543
const engineSkillCount = graph.nodes.filter((node) => node.category === 'engines').length;
@@ -697,6 +739,7 @@ export function createUniverseKnowledgeRuntime(core: DataCore, loaders: Universe
697739
const path = normalizedPath(targetId.slice('hf:'.length));
698740
if (!path) throw new Error('Universe content path is empty');
699741
const info = await loadMetadata();
742+
const fileMetaPromise = loadFileMeta(info.sha, path);
700743
const kind = universeContentKind(path);
701744
const mimeType = universeContentMime(kind, path);
702745
const extension = path.split('.').at(-1)?.toLocaleLowerCase() ?? '';
@@ -791,9 +834,10 @@ export function createUniverseKnowledgeRuntime(core: DataCore, loaders: Universe
791834
mode = 'mediaReference';
792835
}
793836

837+
const fileMeta = await fileMetaPromise;
794838
return Object.freeze({
795839
targetId, path, title, kind, mimeType, revision: info.sha, sourceRef, contentRef: rawRef, text,
796-
columns, schema, rows, tree, tableMeta,
840+
columns, schema, rows, tree, tableMeta, fileMeta,
797841
receipt: Object.freeze({
798842
mode,
799843
requestedBytes,

‎ui/packages/surfaces/src/universe/components/KnowledgeUniverse.svelte‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@
6767
return `${value.toLocaleString()} B`;
6868
}
6969
70+
function formatDate(value: string | null): string {
71+
if (!value) return '기록 없음';
72+
const date = new Date(value);
73+
if (Number.isNaN(date.getTime())) return value;
74+
return new Intl.DateTimeFormat('ko-KR', { dateStyle: 'medium', timeStyle: 'short' }).format(date);
75+
}
76+
7077
function domainCount(domainId: UniverseKnowledgeDomainId): number | null {
7178
return coverage?.domainCounts[domainId]
7279
?? overview?.domains.find((domain) => domain.domainId === domainId)?.itemCount
@@ -405,6 +412,21 @@
405412
{#if content.receipt.truncated}<b>BOUNDED PREVIEW</b>{/if}
406413
</footer>
407414
</section>
415+
<section class="fileProvenance" aria-label={`${content.title} 파일 계보`}>
416+
<header><span>FILE PROVENANCE</span><b>{content.fileMeta.securityStatus ?? 'UNKNOWN'}</b></header>
417+
<div class="provenanceFacts">
418+
<div><span>FILE SIZE</span><strong>{content.fileMeta.sizeBytes !== null ? formatBytes(content.fileMeta.sizeBytes) : '기록 없음'}</strong></div>
419+
<div><span>LAST COMMIT</span><strong>{formatDate(content.fileMeta.lastCommitAt)}</strong></div>
420+
<div><span>AV SCAN</span><strong>{content.fileMeta.antivirusStatus ?? '기록 없음'}</strong></div>
421+
</div>
422+
{#if content.fileMeta.lastCommitTitle}<p>{content.fileMeta.lastCommitTitle}</p>{/if}
423+
<div class="provenanceHashes">
424+
{#if content.fileMeta.lastCommitId}<div><span>COMMIT</span><code title={content.fileMeta.lastCommitId}>{content.fileMeta.lastCommitId}</code></div>{/if}
425+
{#if content.fileMeta.blobId}<div><span>BLOB</span><code title={content.fileMeta.blobId}>{content.fileMeta.blobId}</code></div>{/if}
426+
{#if content.fileMeta.lfsOid}<div><span>LFS</span><code title={content.fileMeta.lfsOid}>{content.fileMeta.lfsOid}</code></div>{/if}
427+
{#if content.fileMeta.xetHash}<div><span>XET</span><code title={content.fileMeta.xetHash}>{content.fileMeta.xetHash}</code></div>{/if}
428+
</div>
429+
</section>
408430
{/if}
409431
{#if selectedAttributes.length > 0}
410432
<dl>{#each selectedAttributes as [key, value] (key)}<div><dt>{key}</dt><dd>{typeof value === 'number' ? value.toLocaleString() : String(value)}</dd></div>{/each}</dl>
@@ -562,6 +584,19 @@
562584
.contentPreview > footer span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
563585
.contentPreview > footer code { margin-left: auto; color: #6d84a0; }
564586
.contentPreview > footer b { flex: 0 0 auto; color: #bc925b; font-size: 6px; letter-spacing: .06em; }
587+
.fileProvenance { margin-top: 8px; overflow: hidden; border: 1px solid rgba(93, 119, 152, .14); border-radius: 9px; background: rgba(8, 13, 21, .66); }
588+
.fileProvenance > header { min-height: 29px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; border-bottom: 1px solid rgba(84, 108, 139, .11); }
589+
.fileProvenance > header span { color: #58708d; font: 650 7px/1 ui-monospace, monospace; letter-spacing: .1em; }
590+
.fileProvenance > header b { border-radius: 999px; padding: 3px 5px; color: #b29362; background: rgba(178, 147, 98, .1); font: 650 6px/1 ui-monospace, monospace; letter-spacing: .06em; }
591+
.provenanceFacts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
592+
.provenanceFacts div { min-width: 0; padding: 9px; border-right: 1px solid rgba(84, 108, 139, .1); }
593+
.provenanceFacts div:last-child { border-right: 0; }
594+
.provenanceFacts span, .provenanceHashes span { display: block; color: #4f6279; font: 600 6px/1 ui-monospace, monospace; }
595+
.provenanceFacts strong { display: block; margin-top: 5px; overflow: hidden; color: #91a3b8; font: 550 7px/1.2 ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
596+
.fileProvenance > p { margin: 0; padding: 9px 10px; border-top: 1px solid rgba(84, 108, 139, .08); color: #8395aa; font-size: 8px; line-height: 1.45; overflow-wrap: anywhere; }
597+
.provenanceHashes { border-top: 1px solid rgba(84, 108, 139, .08); padding: 5px 10px; }
598+
.provenanceHashes div { min-width: 0; display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 7px; padding: 4px 0; }
599+
.provenanceHashes code { min-width: 0; overflow: hidden; color: #677f9b; font: 500 7px/1 ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; user-select: text; }
565600
dl { margin: 16px 0 0; }
566601
dl div { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px; padding: 7px 0; border-bottom: 1px solid rgba(85, 106, 134, .1); }
567602
dt { color: #53667e; font: 600 7px/1.3 ui-monospace, monospace; overflow-wrap: anywhere; }

0 commit comments

Comments
 (0)