Files
whetstone_DSL/editor/src/LanguageSeamFrameDetector.h
Bill 3808caa1d5 Sprint 279: DAP Orchestration Core (steps 1923-1927)
- DAPProxyServer: DAP JSON dispatcher, routes by command, default handlers for
  all standard DAP commands, response envelope with seq/type/request_seq/success
- DebugAdapterRouter: per-language adapter capability registry; routeCommand gates
  on active language AND adapter support
- PolyglotStackTraceDecoder: infers language from source extension, marks boundary
  frames where adjacent frames differ in language, sets astNodeId per frame
- LanguageSeamFrameDetector: detectSeams/primarySeam/seamCount/frameLanguages/
  crossesBoundary over decoded polyglot stacks
- Sprint279IntegrationSummary: poly-sort (Python+Rust) end-to-end DAP pipeline

26/26 tests passing (5+5+5+5+6). All new headers well under 600 lines.
LoRA recorded: sprint279-2026-03-01 (7 calls, 5535 tokens).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 21:08:37 -07:00

52 lines
1.7 KiB
C++

#pragma once
#include "PolyglotStackTraceDecoder.h"
#include <string>
#include <vector>
namespace whetstone {
class LanguageSeamFrameDetector {
public:
// Returns indices of all frames where isBoundary == true.
std::vector<int> detectSeams(const std::vector<StackFrame>& frames) const {
std::vector<int> seams;
for (int i = 0; i < static_cast<int>(frames.size()); ++i)
if (frames[i].isBoundary) seams.push_back(i);
return seams;
}
// Index of first seam frame, -1 if none.
int primarySeam(const std::vector<StackFrame>& frames) const {
for (int i = 0; i < static_cast<int>(frames.size()); ++i)
if (frames[i].isBoundary) return i;
return -1;
}
int seamCount(const std::vector<StackFrame>& frames) const {
return static_cast<int>(detectSeams(frames).size());
}
// Unique languages in order of first appearance.
std::vector<std::string> frameLanguages(const std::vector<StackFrame>& frames) const {
std::vector<std::string> result;
for (const auto& f : frames) {
bool found = false;
for (const auto& l : result) if (l == f.language) { found = true; break; }
if (!found) result.push_back(f.language);
}
return result;
}
// True if any adjacent pair transitions from fromLang to toLang.
bool crossesBoundary(const std::vector<StackFrame>& frames,
const std::string& fromLang,
const std::string& toLang) const {
for (std::size_t i = 0; i + 1 < frames.size(); ++i)
if (frames[i].language == fromLang && frames[i+1].language == toLang)
return true;
return false;
}
};
} // namespace whetstone