This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

137 lines
2.7 KiB
Swift

// Swift CFG hazard fixture (#2195) — one of every control-flow shape the Swift
// CfgVisitor models, so the worker-roundtrip / integration passes exercise the
// real grammar end-to-end. Mirrors the sibling fixtures (go-hazards, rust-hazards).
import Foundation
// if / else + optional binding (`if let`)
func branching(_ x: Int, opt: Int?) -> Int {
if x > 0 {
positive()
} else if x < 0 {
negative()
} else {
zero()
}
if let y = opt {
use(y)
}
return x
}
// guard let early-exit — the else MUST diverge, the body continues
func guarded(opt: Int?) -> Int {
guard let value = opt else {
return -1
}
guard ready() else {
return -2
}
return value
}
// for-in / while / repeat-while (bottom-test) + `where`
func loops() {
for item in collection where item > 0 {
consume(item)
}
while running() {
tick()
}
repeat {
retry()
} while shouldRetry()
}
// switch — no implicit fallthrough + explicit `fallthrough` + `where` guard
func dispatch(_ x: Int) {
switch x {
case 1:
one()
fallthrough
case 2 where x > 0:
two()
case let n where n > 10:
big(n)
default:
other()
}
}
// do / catch (Swift error handling) with `try` / `try?` / `try!`
func errorHandling() {
do {
try risky()
let cached = try? maybe()
try! forced()
deeper(cached)
} catch let error {
handle(error)
} catch {
fallbackHandler()
}
afterDo()
}
// defer — runs at scope exit, LIFO
func deferred() -> Int {
defer { cleanupA() }
defer { cleanupB() }
let result = compute()
return result
}
// labeled break / continue
func labeled() {
outer: for i in rows {
for j in cols {
if skip(i, j) {
continue outer
}
if stop(i, j) {
break outer
}
process(i, j)
}
}
done()
}
// `while true {}` — non-terminating; EXIT must stay reverse-reachable
func eventLoop(_ active: Bool) {
while true {
if active {
poll()
}
}
}
// tuple destructuring + straight-line def/use
func destructure(pair: (Int, Int)) {
let (a, b) = pair
let sum = a + b
use(sum)
}
// init / deinit are CFG-bearing
class Resource {
var handle: Int
init(handle: Int) {
self.handle = handle
}
deinit {
release(handle)
}
// a closure is its own CFG
func register() {
events.forEach { event in
if event.isValid {
accept(event)
}
}
}
}