# tools/core/readers/gate.reader.ts

> 20 lines of code and 6 definitions.

Tree: Coordination tree
Language: typescript
Layer: processing
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tools-core-readers-gate-reader-ts
Source text: https://banes-lab.com/source/coordination/tools/core/readers/gate.reader.ts.txt

Listed in [tools/core/readers](https://banes-lab.com/api/source/coordination/tools/core/readers.md), after [tools/core/readers/document.reader.ts](https://banes-lab.com/source/coordination/tools/core/readers/document.reader.ts.md) and before [tools/core/readers/invocation.reader.ts](https://banes-lab.com/source/coordination/tools/core/readers/invocation.reader.ts.md).

## Definitions

- `priorKindVerdicts` (lexical_declaration, line 9, exported)
- `publishedKinds` (lexical_declaration, line 21, exported)
- `GATE_REPORT` (lexical_declaration, line 7)
- `path` (lexical_declaration, line 10, exported)
- `parsed` (lexical_declaration, line 11, exported)
- `held` (lexical_declaration, line 12, exported)

## Uses

- [tools/core/predicates/schema.predicate.ts](https://banes-lab.com/source/coordination/tools/core/predicates/schema.predicate.ts.md)

## Source

```typescript
import { existsSync, readFileSync } from "node:fs";
import { fieldOf, tryParse } from "./json.reader.ts";
import { GENERATED_DIR } from "../constants/path.constants.ts";
import { isObject } from "../predicates/schema.predicate.ts";
import { resolve } from "node:path";

const GATE_REPORT = "gate.report.generated.json";

export const priorKindVerdicts = function priorKindVerdicts(repoRoot: string): Record<string, string> {
    const path = resolve(repoRoot, GENERATED_DIR, GATE_REPORT);
    const parsed = existsSync(path) ? tryParse(readFileSync(path, "utf8")) : null;
    const held = parsed !== null && isObject(parsed.value) ? fieldOf(parsed.value, "kindVerdicts") : null;
    if (!isObject(held)) {
        return {};
    }
    return Object.fromEntries(
        Object.entries(held).flatMap(([kind, state]) => (typeof state === "string" ? [[kind, state]] : [])),
    );
};

export const publishedKinds = function publishedKinds(repoRoot: string): string[] {
    return Object.keys(priorKindVerdicts(repoRoot));
};
```
